Tag: systemjs

systemjs – 映射到不同的URL

我是新来的angular2和systemjs,我有一个示例node.js项目,我试图将子文件夹'./client/dashboard'中的angular2应用程序映射到一个子URL'本地主机:3000 /仪表板'使用express.static中间件: app.use('/dashboard', express.static(__dirname + '/client/dashboard', { maxAge: 86400000 })); angular2个应用文件夹结构 我的index.html有以下代码: <base href="/dashboard"> <link rel="stylesheet" href="dashboard/styles.css"> <script src="dashboard/node_modules/angular2/bundles/angular2-polyfills.js"></script> <script src="dashboard/node_modules/systemjs/dist/system.src.js"></script> <script src="dashboard/node_modules/rxjs/rx.js"></script> <script src="dashboard/node_modules/angular2/bundles/angular2.dev.js"></script> <script src="dashboard/node_modules/angular2/bundles/router.dev.js"></script> <script src="dashboard/node_modules/angular2/bundles/http.dev.js"></script> <script> System.config({ baseURL: '/dashboard', // paths: { // '*': 'dashboard/*' // }, map: { app: '/dashboard/app', rxjs: '/dashboard/node_modules/rxjs', angular2: '/dashboard/node_modules/angular2' }, packages: { app: { format: […]

Angular2&SystemJS:在构buildmoduleLoader时找不到模块

什么是上下文? 我正在使用SystemJS,Angular2和@ ngrx / store开展一个项目。 目前,我试图做一个简单的模块加载器。 它运作良好。 这是事情: 我在它自己的文件夹中编写一个名为“ namespace @ moduleName ”的“模块”。 我将这个文件夹添加到另一个命名modules 。 当我的应用程序启动时,我的ModuleLoader (基本上通过import {} from 'namespace@moduleName提供的模块可以请求一个服务器API(使用Node)。 在这个API旁边,启动一个脚本。 使用FS ,我正在阅读modules文件夹的内容,以响应一些关于模块的数据(哪些模块被安装,版本是什么)。 回到ModuleLoader,我读取这些信息并configurationSystemJS来添加这些模块(使用map和package )。 ModuleLoader的工作已经结束。 我可以用System.import('core/app').then(null, console.error.bind(console));启动我的应用程序System.import('core/app').then(null, console.error.bind(console)); 我的应用程序启动。 这很简单吧? core/app是指public/core/components/app.component.ts这是我的引导组件Angular 2。 有什么问题? 一切工作正常之前,我更新我的代码。 我遇到了Angular 2,所以我的app.component.ts看起来像这样: import { Component, View } from "angular2/core"; import { RouteConfig, ROUTER_DIRECTIVES, Router } from "angular2/router"; import { Devtools […]

如何使用es6风格导入导入MongoDB?

希望这是一个简单的问题。 我正在尝试使用es6 import-from样式导入MongoDB。 如果我导入使用节点要求它工作正常。 let mongo = require('mongodb'); let MongoClient = mongo.MongoClient; 但是如果我导入es6的方式,它没有错误或日志打破。 import {MongoClient} from 'mongodb'; 但编译/运行时,它不会中断,只有在我尝试使用MongoClient时才会中断。 这是我的Db经理类, import {MongoClient} from 'mongodb'; export class DbManager { constructor() { console.log('Constructing DB Connection'); } } 当我运行我的服务器时,我从其他pipe理器和事件中获得了几个日志。 mycomputer myuser$ ./start.sh Server Constructing Route Manager Constructing Initializing Route: Static Constructing DB Connection http server started on port: 8000 […]

如何在Webpack 2.x中debuggingSystemJS ENOENT没有这样的错误错误?

升级到Webpack 2.x后,编译和重新编译(在HMR模式下)出现此错误: (SystemJS) Error: ENOENT: no such file or directory, open … 有没有人find解决办法? 这里是源代码: https://github.com/kriasoft/react-static-boilerplate/tree/webpack2 (见PR #102 )

在node.js上使用systemjs(&Angular 2)

说我有一个foo.ts和app.ts如下: foo.ts: export interface Foo { id: number; label: string; }; app.ts: import {Foo} from './foo' var myfoo: Foo = { "id": 1, "label": "One" }; console.log(JSON.stringify(myfoo)); 在编译之后,如果我在我的tsconfig.json使用"module"="commonjs" ,那么从命令行执行'node app.js'将按预期运行。 切换到追逐,我想要做的是使用我的Foo接口客户端与Angular 2,服务器端与节点。 不方便的是,我在这里build模的Angular 2 quickstart在tsconfig.json "module"="system" 。 尝试运行'node app.js'时,此configuration会导致错误: System.register([], function(exports_1) { ^ ReferenceError: System is not defined` 我已经尝试按照说明在github上使用systemjs与节点,但在这一点上,我只是糖化键,可以使用一些帮助。 我怎么(a)让我的app.ts代码运行在服务器端使用systemjs,或者(b)得到运行commonjs的Angular 2快速启动?

SystemJS插件可以修改已经传输的文件吗?

当试图让Angular(1.x)与systemjs一起工作时,我意识到目前还没有能力(我知道)将$inject自动插入到angular度组件中,即使当函数的参数是被缩小器弄坏了。 手动创build$inject注释注解是单调乏味的,容易出错,违反了DRY本体 。 有一个称为ng-annotate的成熟的npm模块可以解决这个问题,并且在许多类似的情况下用于捆绑。 正如我一直在探索SystemJS,我看到有一个插件系统,包括翻译源代码的能力,这正是ng-annotate所做的。 但是,从我所看到的,SystemJS只允许您将特定文件扩展名映射到单个加载程序,并且插件的所有示例都将支持新的文件types。 我想要做的是后处理SystemJS的transpilation过程的输出,而不是添加一个新的文件types。 看起来像SystemJS应该能够做到这一点,因为它有一个处理pipe道,但我不能完全弄清楚如何正确的方法。 现在我正在使用Browserify来达到同样的效果,但是我最终得到了一组相当复杂的构build任务,如果可能的话,我想用SystemJS来简化它。 其他能够在SystemJS的加载器pipe道中使用ng-annotate的策略也是值得赞赏的。

在SystemJS加载器环境中将相对path映射到绝对path的方法

我正在使用SystemJS加载程序(与commonJS模块,但不应该是重要的),主要是直接访问node_modules下的node_modules 。 现在在运行时,是否有可能从相对位置查找当前环境中的绝对path? 也就是说,如果我require('./myComponent') ,它将获取http://localhost:3000/app/myComponent.js但如果通过npm install (因此驻留在node_modules下) npm install该组件,SystemJS将正确加载http://localhost:3000/node_modules/dist/myComponent.js 。 有没有办法从相对的一个查找这个绝对path? 即类似var absPath = SystemJS.lookup('./myComponent') ?

什么是angular2中使用system.config.js文件?

var map,packages,var config做什么? 还解释了map和package对象的所有configuration属性。 有没有可用的configuration文件? 这是我的系统configuration文件 /** * System configuration for Angular samples * Adjust as necessary for your application needs. */ (function (global) { System.config({ paths: { // paths serve as alias 'npm:': 'node_modules/' }, // map tells the System loader where to look for things map: { // our app is within the […]

使用SystemJS生成工作stream,并通过CDN托pipe外部依赖项

我试图找出一个良好的生产工作stream程,与开发工作stream程很好。 需要从构build中排除1MB的外部库,然后使用CDN分别托pipe它们。 所以我们有这个: <script src="jspm_packages/system.js"></script> <script src="config.js"></script> <script src="build.js"></script> <script> System.import('app/main.js'); </script> 这很好,main.js中的任何内容都被忽略,因为它已经包含在build.js中。 虽然我猜这意味着什么时候该回到开发热门的时候,我们必须先删除build.js? 所以现在我想分开生产的外部依赖关系: builder.buildStatic('app/main.js', 'build.js', { externals: ['jquery'], globalName: 'App', globalDeps: { 'jquery': 'jQuery' } }); 当我们这样做时,我们需要添加一行: <script src="https://ajax.googleapis.com/ajax/libs/jquery/2.2.2 jquery.min.js"></script> <script src="jspm_packages/system.js"></script> <script src="config.js"></script> <script src="build.js"></script> <script> System.import('app/main.js'); </script> 这意味着,当我们切换回开发版本时,jQuery将被双重捆绑到main.js中? 然后是SystemJS的片段: System.config({ bundles: { 'build/core': ['jquery'] } }); System.import('app/main.js'); 不知道如何使用这个,因为现在我们不会使用CDN来托pipejQuery。 所以对我来说,这种感觉就像一个捕捉22. JSPM是伟大的,因为它给你的包pipe理,但要在生产中使用的包,你希望他们在外面。 所以如果我们不得不在页面中包含脚本标签,那么这不就是JSPM的目的呢? […]