Open Nathan-Ryan opened 7 years ago
Looks like this issue was also reported here and closed.
I'm running into this same issue with the following rollup configuration:
Error:
Error: 'NgxDatatableModule' is not exported by node_modules\@swimlane\ngx-datatable\release\index.js
https://github.com/rollup/rollup/wiki/Troubleshooting#name-is-not-exported-by-module
build\temp\src\app\iq\design\ui\ui.module.js (18:9)
16: import { AppNavTabsComponent } from './components/navigation/app-nav/components/app-nav-tabs/app-nav-tabs.component';
17: import { DatagridComponent } from './components/datagrid/datagrid.component';
18: import { NgxDatatableModule } from '@swimlane/ngx-datatable';
^
19: var IQDesignUIModule = (function () {
20: function IQDesignUIModule() {
rollup.config.js:
import commonjs from 'rollup-plugin-commonjs';
import nodeResolve from 'rollup-plugin-node-resolve';
export default {
entry: './build/index.js',
dest: './dist/index.js',
onwarn: function (warning) {
if (warning.code === 'THIS_IS_UNDEFINED') return;
console.warn(warning.message);
},
plugins: [
nodeResolve({ jsnext: true, module: true }),
commonjs({
include: ['node_modules/rxjs/**', 'node_modules/@swimlane/**']
})
]
};
We can suppress the above error by including the modulesOnly: true
field in the nodeResolve
plugin, but we will still get the following warnings:
'@swimlane/ngx-datatable' is imported by build\temp\src\app\company\design\ui\ui.module.js, but could not be resolved – treating it as an external dependency
@mgmarlow Thanks but unfortunately that seems to cause issues with rxjs. Here's my rollup.config.js with your workaround.
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/SecureApp.Aot.js',
dest: 'Js/app-secure.js',
sourceMap: false,
format: 'iife',
onwarn: function (warning) {
if (warning.code === 'THIS_IS_UNDEFINED')
return;
console.warn(warning.message);
},
plugins: [
nodeResolve({ jsnext: true, module: true, modulesOnly: true }),
commonjs({
include: [
'node_modules/rxjs/**',
'node_modules/@swimlane/**'
]
}),
uglify()
]
}
Which causes many of these kind of errors
No name was provided for external module 'rxjs/operator/last' in options.globals – guessing 'rxjs_operator_last'
No name was provided for external module 'rxjs/operator/mergeAll' in options.globals – guessing 'rxjs_operator_mergeAll'
No name was provided for external module 'rxjs/operator/filter' in options.globals – guessing 'rxjs_operator_filter'
The process seems to complete, however, the dest file is corrupt.
Do we have a consensus on this? Open to changes to improve this...
@amcdnl Perhaps one solution is to export both the UMD modules and the ES2015 modules. This library uses that method. The UMD output is provided in the node_modules/ng-lightning/bundles/
directory, rather than the base ng-lightning.js
file.
@amcdnl Would you recommend using Webpack over Rollup?
In the commonjs plugin you can add the namedExports option, where you can add missing exports. https://github.com/rollup/rollup-plugin-commonjs#custom-named-exports Here my rollup-config.js:
import nodeResolve from 'rollup-plugin-node-resolve';
import commonjs from 'rollup-plugin-commonjs';
import uglify from 'rollup-plugin-uglify';
export default {
entry: 'src/main.js',
dest: '../build.js', // output a single application bundle
sourceMap: true,
format: 'iife',
onwarn: function(warning) {
// Skip certain warnings
// should intercept ... but doesn't in some rollup versions
if ( warning.code === 'THIS_IS_UNDEFINED' ) { return; }
// console.warn everything else
console.warn( warning.message );
},
plugins: [
nodeResolve({jsnext: true, module: true}),
commonjs({
namedExports: {
'node_modules/@swimlane/ngx-datatable/release/index.js': ['NgxDatatableModule']
},
include:
['node_modules/rxjs/**',
'node_modules/@swimlane/**']
}),
uglify()
]
};
To add to @Niro003's comment - in my rollup config I added 'node_modules/@swimlane/ngx-datatable/release/index.js': ['NgxDatatableModule', 'DatatableComponent']
so that I could use the DatatableComponent with AOT.
I'm submitting a ... (check one with "x")
Current behavior Using rollup with module importing NgxDatatableModule fails due to missing exports.
Expected behavior Rollup completes as normal.
Reproduction of the problem Include NgxDatatableModule in your module which is used by rollup.
What is the motivation / use case for changing the behavior? Would like to use this in production.
Please tell us about your environment: Windows 10, NPM 4.2, Node 7.9
Table version: 9.0.0
Angular version: 4.0
Browser: N/A
Language: Typescript 2.3