-
-
Notifications
You must be signed in to change notification settings - Fork 1.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Bare import should not assign to a variable in generated CommonJS code #765
Comments
I'm struggling to reproduce this – any chance you can put together a minimal gist/repo showing the problem? |
I am having the same issue with Module /node_modules/react-redux/lib/index.js does not export Provider (imported by /src/containers/App.js)
Error: Module /node_modules/react-redux/lib/index.js does not export Provider (imported by /src/containers/App.js)
at Module.trace (/node_modules/rollup/src/Module.js:676:30)
at /node_modules/rollup/src/Module.js:218:35
at Array.forEach (native)
at /node_modules/rollup/src/Module.js:215:25
at Array.forEach (native)
at Module.bindAliases (/node_modules/rollup/src/Module.js:204:29)
at /node_modules/rollup/src/Bundle.js:100:44
at Array.forEach (native)
at /node_modules/rollup/src/Bundle.js:100:18 |
@raphaelokon Seems like youare trying to load commonjs module without commonjs plugin. Rollup itself looks for es-modules. Plugin converts commonjs to es. |
Hey @TrySound. I am using the following config: import babel from "rollup-plugin-babel";
import cjs from "rollup-plugin-commonjs";
import replace from "rollup-plugin-replace";
import resolve from "rollup-plugin-node-resolve";
export default {
dest : "dist/app.js",
entry : "src/main.js",
format : "iife",
plugins : [
babel({
babelrc: false,
exclude: "node_modules/**",
presets: ["es2015-rollup", "stage-0", "react"]
}),
cjs({
exclude: "node_modules/process-es6/**",
include: ["node_modules/fbjs/**", "node_modules/object-assign/**", "node_modules/react/**", "node_modules/react-dom/**"]
}),
// globals(),
replace({
"process.env.NODE_ENV": JSON.stringify("development")
}),
resolve({browser: true, main: true})
],
sourceMap : true
}; Interestingly this minimal file builds: import React from "react";
import ReactDOM from "react-dom";
import {Provider} from "react-redux"; |
There are two problems:
|
Thanks. Now I am getting the following:
|
I guess I have to whitelist this as well |
@TrySound Thanks. I tried removing the include opts for the
Relates to #524 and rollup/rollup-plugin-commonjs/pull/44 |
I have an ES6 library which I'm building to CJS and using in a browser-based app (also ES6). The library depends on
webcomponents.js
, which is a shim and has no exports, only side effects. The CJS export assigns the bare import to a variable:library/index.js
:library/build/index.cjs.js
:In my app which imports the library (via NPM), I'm using the CommonJS Rollup plugin to get back to ES6. The reason I'm not using ES6 all the way through is because the app has a collection of other dependencies (react, react-router, redux) which have a mixture of
main
/jsnext:main
support and I found that impossible to resolve with any combination of includes and excludes.The error I get on rolling my app is
Module /Users/me/app/node_modules/webcomponents.js/webcomponents.js does not export default (imported by /Users/me/app/node_modules/library/build/index.cjs.js)
. Is there a way to get Rollup not to generate thevar webcomponents_js
declaration? It works if I manually remove the variable assignment.The text was updated successfully, but these errors were encountered: