根据此处提供的建议,我无法使用Rollupjs构建我的Angular2应用程序: http://blog.mgechev.com/2016/06/26/tree-shaking-angular2-production-build-rollup-javascript/
在执行" npm run rollup"时,rollupjs会抛出上述错误。我的设置如下:
rollup.config.js
import nodeResolve from 'rollup-plugin-node-resolve';
import commonjs from 'rollup-plugin-commonjs';
class RollupNG2 {
constructor(options) {
this.options = options;
}
resolveId(id, from) {
if (id.startsWith('rxjs/')) {
return `${__dirname}/node_modules/rxjs-es/${id.replace('rxjs/', '')}.js`;
}
}
}
const rollupNG2 = (config) => new RollupNG2(config);
export
default {
entry: 'src/main.js',
sourceMap: true,
moduleName: 'main',
plugins: [
rollupNG2(),
nodeResolve({
jsnext: true,
main: true
}),
commonjs({ // https://github.com/rollup/rollup-plugin-commonjs
exclude: ['node_modules/@angular/**', 'node_modules/rxjs-es'],
ignoreGlobal: false,
sourceMap: false,
})
]
}

的package.json:
{
"name": "Public Transit App",
"version": "1.0.0",
"scripts": {
"start": "tsc && concurrently \"npm run tsc:w\" \"npm run lite\" ",
"lite": "lite-server",
"postinstall": "typings install",
"tsc": "tsc",
"tsc:w": "tsc -w",
"typings": "typings",
"build": "tscg",
"clean": "rmdir /S /Q dist",
"minify": "uglifyjs dist/bundle.js --screw-ie8 --compress --mangle --output dist/bundle.min.js",
"rollup": "rollup -f iife -c -o dist/bundle.es2015.js"
},
"license": "ISC",
"dependencies": {
"@angular/common": "2.0.0-rc.5",
"@angular/compiler": "2.0.0-rc.5",
"@angular/core": "2.0.0-rc.5",
"@angular/forms": "0.3.0",
"@angular/http": "2.0.0-rc.5",
"@angular/platform-browser": "2.0.0-rc.5",
"@angular/platform-browser-dynamic": "2.0.0-rc.5",
"@angular/router": "3.0.0-rc.1",
"@angular/router-deprecated": "2.0.0-rc.2",
"@angular/upgrade": "2.0.0-rc.5",
"@angular2-material/button": "^2.0.0-alpha.7-3",
"@angular2-material/core": "^2.0.0-alpha.7-3",
"@angular2-material/input": "^2.0.0-alpha.7-3",
"@angular2-material/list": "^2.0.0-alpha.7-4",
"@vaadin/angular2-polymer": "^1.0.0-beta2",
"angular2-in-memory-web-api": "0.0.15",
"bootstrap": "^3.3.6",
"core-js": "^2.4.0",
"es6-promise": "^3.2.1",
"lodash": "^4.15.0",
"modernizr": "^3.3.1",
"moment": "^2.14.1",
"moment-timezone": "^0.5.5",
"node-fetch": "^1.5.3",
"reflect-metadata": "^0.1.3",
"rxjs": "5.0.0-beta.6",
"rxjs-es": "^5.0.0-beta.12",
"systemjs": "0.19.27",
"whatwg-fetch": "^1.0.0",
"zone.js": "^0.6.12"
},
"devDependencies": {
"concurrently": "^2.0.0",
"jasmine-core": "^2.4.1",
"jshint": "^2.9.2",
"lite-server": "^2.2.0",
"rollup": "^0.34.13",
"rollup-plugin-commonjs": "^4.1.0",
"rollup-plugin-node-resolve": "^2.0.0",
"tslint": "^3.14.0",
"typescript": "^1.8.10",
"typescript-with-globs": "^0.1.4",
"typings": "^1.3.3"
}
}

整个项目(例如它)在这里: https://github.com/evelbulgroz/public-transit-app-rc52
有点新手,所以不确定我是否遗漏了一些明显的东西?并且相当困难,所以任何帮助都非常受欢迎。