'DragulaModule' 未由 node_modules\ng2-dragula\index.js 导出
'DragulaModule' is not exported by node_modules\ng2-dragula\index.js
'DragulaModule' is not exported by node_modules\ng2-dragula\index.js
https://github.com/rollup/rollup/wiki/Troubleshooting#name-is-not-exported-by-module
app\app.module.js (13:9)
11: import { BrowserModule } from '@angular/platform-browser';
12: import { AppComponent } from './app.component';
13: import { DragulaModule } from 'ng2-dragula';
^
14: import { FileUploadModule } from "ng2-file-upload";
rollup.config.js
import rollup from 'rollup'
import nodeResolve from 'rollup-plugin-node-resolve'
import commonjs from 'rollup-plugin-commonjs';
import uglify from 'rollup-plugin-uglify';
export default {
entry: 'app/main.js',
dest: 'dist/build.js',
sourceMap: false,
format: 'iife',
plugins: [
nodeResolve({jsnext: true, module: true}),
commonjs({
include: 'node_modules/rxjs/**',
}),
uglify()
]
}
使用 Rollup 进行 tree-shaking 和构建在使用 aot 成功生成文件后出现上述错误。非常感谢任何建议。
尝试在您的 rollup.config
中添加命名导出
commonjs({
include: 'node_modules/rxjs/**',
namedExports: {
'node_modules/ng2-dragula/ng2-dragula.js': [ 'DragulaModule', 'DragulaService' ]
}
})
您可以在此处阅读有关自定义命名导出的更多信息:https://github.com/rollup/rollup-plugin-commonjs#custom-named-exports
如果你使用 angular 6
将此行添加到 pollyfills.ts 解决了我的问题
(window 任意).global = window;
'DragulaModule' is not exported by node_modules\ng2-dragula\index.js
https://github.com/rollup/rollup/wiki/Troubleshooting#name-is-not-exported-by-module
app\app.module.js (13:9)
11: import { BrowserModule } from '@angular/platform-browser';
12: import { AppComponent } from './app.component';
13: import { DragulaModule } from 'ng2-dragula';
^
14: import { FileUploadModule } from "ng2-file-upload";
rollup.config.js
import rollup from 'rollup'
import nodeResolve from 'rollup-plugin-node-resolve'
import commonjs from 'rollup-plugin-commonjs';
import uglify from 'rollup-plugin-uglify';
export default {
entry: 'app/main.js',
dest: 'dist/build.js',
sourceMap: false,
format: 'iife',
plugins: [
nodeResolve({jsnext: true, module: true}),
commonjs({
include: 'node_modules/rxjs/**',
}),
uglify()
]
}
使用 Rollup 进行 tree-shaking 和构建在使用 aot 成功生成文件后出现上述错误。非常感谢任何建议。
尝试在您的 rollup.config
中添加命名导出commonjs({
include: 'node_modules/rxjs/**',
namedExports: {
'node_modules/ng2-dragula/ng2-dragula.js': [ 'DragulaModule', 'DragulaService' ]
}
})
您可以在此处阅读有关自定义命名导出的更多信息:https://github.com/rollup/rollup-plugin-commonjs#custom-named-exports
如果你使用 angular 6
将此行添加到 pollyfills.ts 解决了我的问题
(window 任意).global = window;