Closed BryanCrotaz closed 4 years ago
same issue here. it seems this plugin is unmaintained?
@boussou it is maintained. @BryanCrotaz show your config. Also changing to export default
will prevent converting require to import in this module.
@TrySound I am glad to know ;-)
I myself just treid the sample from the repo:
// cjs_exporter.js
This does not work::
//module.exports = { show_named: show_named };
//exports.show_named=show_named;
I am forced to do this :
export { show_named };
Error log:
or
rollup v1.19.4
bundles src/example-script.js → built/main.js...
[!] Error: 'show_named' is not exported by src/modules/cjs_importer.js
https://rollupjs.org/guide/en/#error-name-is-not-exported-by-module
src/modules/another-module.js (21:9)
19:
20:
21: import { show_named } from './cjs_importer';
^
22:
23: show_named();
Error: 'show_named' is not exported by src/modules/cjs_importer.js
at error (/usr/lib/node_modules/rollup/dist/rollup.js:9435:30)
at Module.error (/usr/lib/node_modules/rollup/dist/rollup.js:13407:9)
at handleMissingExport (/usr/lib/node_modules/rollup/dist/rollup.js:13327:21)
at Module.traceVariable (/usr/lib/node_modules/rollup/dist/rollup.js:13712:17)
at ModuleScope.findVariable (/usr/lib/node_modules/rollup/dist/rollup.js:12422:39)
at Identifier$1.bind (/usr/lib/node_modules/rollup/dist/rollup.js:8348:40)
at CallExpression$1.bind (/usr/lib/node_modules/rollup/dist/rollup.js:7977:23)
at CallExpression$1.bind (/usr/lib/node_modules/rollup/dist/rollup.js:10377:15)
at ExpressionStatement$1.bind (/usr/lib/node_modules/rollup/dist/rollup.js:7977:23)
at Program$1.bind (/usr/lib/node_modules/rollup/dist/rollup.js:7973:31)
my config
import serve from 'rollup-plugin-serve';
import livereload from 'rollup-plugin-livereload';
import commonjs from "rollup-plugin-commonjs";
import node_resolve from "rollup-plugin-node-resolve";
import buble from 'rollup-plugin-buble';
import sizes from 'rollup-plugin-sizes';
export default {
input: 'src/example-script.js',
output: {
file: 'built/main.js',
format: 'iife',
name: 'App',
sourcemap: true,
},
plugins: [
buble(),
node_resolve(),
commonjs(),
sizes(),
serve({
open: true,
openPage: '/example-pour-rollup-dev.html',
verbose: true,
contentBase: 'built',
host: 'localhost',
port: 3000,
headers: {
'Access-Control-Allow-Origin': '*',
foo: 'bar'
}
}),
livereload(),
],
};
In your case named export is probably hard to recognise. For such cases there is namedExports option where you may explicitly describe all possible exports. If your code can be run in node try this
import * as reactDom from 'react-dom';
commonjs({
namedExports: {
'react-dom': Object.keys(reactDom)
}
}
Maybe I misunderstood the usage of this plugin.
I basically need to migrate a Backbone application. We made the effort to move from AMD to CJS. And to keep things compatible with existing projects, we would like to keep the commonJS way require/exports/modules (if possible without using es6 imports - but I think it is not).
Thanks for your reactivity btw ;-)
Hey folks (this is a canned reply, but we mean it!). Thanks to everyone who participated in this issue. We're getting ready to move this plugin to a new home at https://github.com/rollup/plugins, and we have to do some spring cleaning of the issues to make that happen. We're going to close this one, but it doesn't mean that it's not still valid.
We've got some time yet before the move while we resolve pending Pull Requests, so if this issue is still relevant, please @ me and I'll make sure it gets reopened and transferred to the new repo. :beer:
example from
aws-promised
The above results in the error
'\'default\' is not exported by node_modules/aws-promised/cloudFront.js
Changing the last line to this makes it work: