zloirock / core-js

Standard Library
MIT License
24.59k stars 1.66k forks source link

Plans for ES6 module support? #385

Open joliss opened 6 years ago

joliss commented 6 years ago

So I'm a big fan of ES6 modules, because they have statically analyzable import/export syntax with well-defined semantics, which means that bundling doesn't need to rely on any sorts of heuristics.

Babel's transform-runtime plugin has the ability to emit either require or import statements when it pulls in core-js modules. I was trying to get this to work with import statements and Rollup, so that our app would only include the parts of core-js that it needs, rather than the whole library.

But since core-js uses CommonJS internally, it seems to be necessary to convert it to ES6 modules with rollup-plugin-commonjs before feeding it into the Rollup pipeline. I haven't been able to get this to work at all, which is probably due to the limitations of using heuristics to parse require calls.

I'll provide below a sampling of error message that I ran into as I tried to get it working. I don't expect these will be useful to track down any particular issue, but perhaps they'll illustrate the difficulty of getting require-based bundling to work.

So I'm wondering if there are any plans to have first-class ES6 module support in core-js?

``` SyntaxError: /home/ubuntu/src/solitr/node_modules/@babel/runtime/core-js/array/from.js: Support for the experimental syntax 'exportDefaultFrom' isn't currently enabled (6:8): 4 | var from = require$$0; 5 | > 6 | export default from; | ^ 7 | export { from as __moduleExports }; Add @babel/plugin-proposal-export-default-from (https://git.io/vb4yH) to the 'plugins' section of your Babel config to enable transformation. at error (/home/ubuntu/src/broccoli-rollup/x/node_modules/rollup/dist/rollup.js:85:10) at Object.error (/home/ubuntu/src/broccoli-rollup/x/node_modules/rollup/dist/rollup.js:3:1) at /home/ubuntu/src/broccoli-rollup/x/node_modules/rollup/dist/rollup.js:3:1 at :null:null ``` With an older version of Rollup: ``` TypeError: Line must be greater than or equal to 1, got null at BasicSourceMapConsumer.SourceMapConsumer_findMapping [as _findMapping] (/home/ubuntu/src/solitr/node_modules/rollup/dist/rollup.js:3:1) at BasicSourceMapConsumer.SourceMapConsumer_originalPositionFor [as originalPositionFor] (/home/ubuntu/src/solitr/node_modules/rollup/dist/rollup.js:3:1) at Module.getOriginalLocation (/home/ubuntu/src/solitr/node_modules/rollup/dist/rollup.js:3:1) at Module.error (/home/ubuntu/src/solitr/node_modules/rollup/dist/rollup.js:3:1) at then.resolvedId (/home/ubuntu/src/solitr/node_modules/rollup/dist/rollup.js:3:1) at :null:null ``` Yet another configuration compiles but with a lot of warnings ... ``` src/main.js → public/bundle.js... (!) Circular dependency: node_modules/core-js/library/modules/_export.js -> node_modules/core-js/library/modules/_hide.js -> node_modules/core-js/library/modules/_object-dp.js -> node_modules/@babel/runtime/core-js/object/define-property.js -> node_modules/core-js/library/fn/object/define-property.js -> node_modules/core-js/library/modules/es6.object.define-property.js -> node_modules/core-js/library/modules/_export.js (!) Circular dependency: node_modules/core-js/library/modules/_object-dp.js -> node_modules/@babel/runtime/core-js/object/define-property.js -> node_modules/core-js/library/fn/object/define-property.js -> node_modules/core-js/library/modules/es6.object.define-property.js -> node_modules/core-js/library/modules/_object-dp.js (!) Circular dependency: node_modules/core-js/library/modules/_export.js -> node_modules/core-js/library/modules/_hide.js -> node_modules/core-js/library/modules/_object-dp.js -> node_modules/@babel/runtime/core-js/object/define-property.js -> node_modules/core-js/library/fn/object/define-property.js -> node_modules/core-js/library/modules/es6.object.define-property.js -> commonjs-proxy:/home/ubuntu/src/rollup-starter-app/node_modules/core-js/library/modules/_export.js -> node_modules/core-js/library/modules/_export.js (!) Circular dependency: node_modules/core-js/library/modules/_object-dp.js -> node_modules/@babel/runtime/core-js/object/define-property.js -> node_modules/core-js/library/fn/object/define-property.js -> node_modules/core-js/library/modules/es6.object.define-property.js -> commonjs-proxy:/home/ubuntu/src/rollup-starter-app/node_modules/core-js/library/modules/_object-dp.js -> node_modules/core-js/library/modules/_object-dp.js (!) Circular dependency: node_modules/@babel/runtime/helpers/typeof.js -> node_modules/@babel/runtime/helpers/typeof.js (!) Circular dependency: node_modules/core-js/library/modules/_iter-define.js -> node_modules/core-js/library/modules/_export.js -> node_modules/core-js/library/modules/_hide.js -> node_modules/core-js/library/modules/_object-dp.js -> node_modules/core-js/library/modules/_an-object.js -> node_modules/core-js/library/modules/_is-object.js -> node_modules/@babel/runtime/helpers/typeof.js -> node_modules/@babel/runtime/core-js/symbol/iterator.js -> node_modules/core-js/library/fn/symbol/iterator.js -> node_modules/core-js/library/modules/es6.string.iterator.js -> node_modules/core-js/library/modules/_iter-define.js (!) Circular dependency: node_modules/core-js/library/modules/_iter-define.js -> node_modules/core-js/library/modules/_export.js -> node_modules/core-js/library/modules/_hide.js -> node_modules/core-js/library/modules/_object-dp.js -> node_modules/core-js/library/modules/_an-object.js -> node_modules/core-js/library/modules/_is-object.js -> node_modules/@babel/runtime/helpers/typeof.js -> node_modules/@babel/runtime/core-js/symbol/iterator.js -> node_modules/core-js/library/fn/symbol/iterator.js -> node_modules/core-js/library/modules/es6.string.iterator.js -> commonjs-proxy:/home/ubuntu/src/rollup-starter-app/node_modules/core-js/library/modules/_iter-define.js -> node_modules/core-js/library/modules/_iter-define.js (!) Circular dependency: node_modules/core-js/library/modules/web.dom.iterable.js -> node_modules/core-js/library/modules/es6.array.iterator.js -> node_modules/core-js/library/modules/_iter-define.js -> node_modules/core-js/library/modules/_export.js -> node_modules/core-js/library/modules/_hide.js -> node_modules/core-js/library/modules/_object-dp.js -> node_modules/core-js/library/modules/_an-object.js -> node_modules/core-js/library/modules/_is-object.js -> node_modules/@babel/runtime/helpers/typeof.js -> node_modules/@babel/runtime/core-js/symbol/iterator.js -> node_modules/core-js/library/fn/symbol/iterator.js -> node_modules/core-js/library/modules/web.dom.iterable.js (!) Circular dependency: node_modules/core-js/library/modules/web.dom.iterable.js -> node_modules/core-js/library/modules/es6.array.iterator.js -> node_modules/core-js/library/modules/_iter-define.js -> node_modules/core-js/library/modules/_export.js -> node_modules/core-js/library/modules/_hide.js -> node_modules/core-js/library/modules/_object-dp.js -> node_modules/core-js/library/modules/_an-object.js -> node_modules/core-js/library/modules/_is-object.js -> node_modules/@babel/runtime/helpers/typeof.js -> node_modules/@babel/runtime/core-js/symbol/iterator.js -> node_modules/core-js/library/fn/symbol/iterator.js -> commonjs-proxy:/home/ubuntu/src/rollup-starter-app/node_modules/core-js/library/modules/web.dom.iterable.js -> node_modules/core-js/library/modules/web.dom.iterable.js (!) Circular dependency: node_modules/@babel/runtime/helpers/typeof.js -> node_modules/@babel/runtime/core-js/symbol.js -> node_modules/core-js/library/fn/symbol/index.js -> node_modules/core-js/library/modules/es6.symbol.js -> node_modules/@babel/runtime/helpers/typeof.js (!) Circular dependency: node_modules/core-js/library/modules/_export.js -> node_modules/core-js/library/modules/_hide.js -> node_modules/core-js/library/modules/_object-dp.js -> node_modules/core-js/library/modules/_an-object.js -> node_modules/core-js/library/modules/_is-object.js -> node_modules/@babel/runtime/helpers/typeof.js -> node_modules/@babel/runtime/core-js/symbol.js -> node_modules/core-js/library/fn/symbol/index.js -> node_modules/core-js/library/modules/es6.symbol.js -> node_modules/core-js/library/modules/_export.js (!) Circular dependency: node_modules/core-js/library/modules/_hide.js -> node_modules/core-js/library/modules/_object-dp.js -> node_modules/core-js/library/modules/_an-object.js -> node_modules/core-js/library/modules/_is-object.js -> node_modules/@babel/runtime/helpers/typeof.js -> node_modules/@babel/runtime/core-js/symbol.js -> node_modules/core-js/library/fn/symbol/index.js -> node_modules/core-js/library/modules/es6.symbol.js -> node_modules/core-js/library/modules/_redefine.js -> node_modules/core-js/library/modules/_hide.js (!) Circular dependency: node_modules/core-js/library/modules/_hide.js -> node_modules/core-js/library/modules/_object-dp.js -> node_modules/core-js/library/modules/_an-object.js -> node_modules/core-js/library/modules/_is-object.js -> node_modules/@babel/runtime/helpers/typeof.js -> node_modules/@babel/runtime/core-js/symbol.js -> node_modules/core-js/library/fn/symbol/index.js -> node_modules/core-js/library/modules/es6.symbol.js -> node_modules/core-js/library/modules/_redefine.js -> commonjs-proxy:/home/ubuntu/src/rollup-starter-app/node_modules/core-js/library/modules/_hide.js -> node_modules/core-js/library/modules/_hide.js (!) Circular dependency: node_modules/@babel/runtime/helpers/typeof.js -> node_modules/@babel/runtime/core-js/symbol.js -> node_modules/core-js/library/fn/symbol/index.js -> node_modules/core-js/library/modules/es6.symbol.js -> node_modules/core-js/library/modules/_meta.js -> node_modules/@babel/runtime/helpers/typeof.js (!) Circular dependency: node_modules/core-js/library/modules/_is-object.js -> node_modules/@babel/runtime/helpers/typeof.js -> node_modules/@babel/runtime/core-js/symbol.js -> node_modules/core-js/library/fn/symbol/index.js -> node_modules/core-js/library/modules/es6.symbol.js -> node_modules/core-js/library/modules/_meta.js -> node_modules/@babel/runtime/core-js/object/prevent-extensions.js -> node_modules/core-js/library/fn/object/prevent-extensions.js -> node_modules/core-js/library/modules/es6.object.prevent-extensions.js -> node_modules/core-js/library/modules/_is-object.js (!) Circular dependency: node_modules/core-js/library/modules/_meta.js -> node_modules/@babel/runtime/core-js/object/prevent-extensions.js -> node_modules/core-js/library/fn/object/prevent-extensions.js -> node_modules/core-js/library/modules/es6.object.prevent-extensions.js -> node_modules/core-js/library/modules/_meta.js (!) Circular dependency: node_modules/core-js/library/modules/_export.js -> node_modules/core-js/library/modules/_hide.js -> node_modules/core-js/library/modules/_object-dp.js -> node_modules/core-js/library/modules/_an-object.js -> node_modules/core-js/library/modules/_is-object.js -> node_modules/@babel/runtime/helpers/typeof.js -> node_modules/@babel/runtime/core-js/symbol.js -> node_modules/core-js/library/fn/symbol/index.js -> node_modules/core-js/library/modules/es6.symbol.js -> node_modules/core-js/library/modules/_meta.js -> node_modules/@babel/runtime/core-js/object/prevent-extensions.js -> node_modules/core-js/library/fn/object/prevent-extensions.js -> node_modules/core-js/library/modules/es6.object.prevent-extensions.js -> node_modules/core-js/library/modules/_object-sap.js -> node_modules/core-js/library/modules/_export.js (!) Circular dependency: node_modules/core-js/library/modules/_is-object.js -> node_modules/@babel/runtime/helpers/typeof.js -> node_modules/@babel/runtime/core-js/symbol.js -> node_modules/core-js/library/fn/symbol/index.js -> node_modules/core-js/library/modules/es6.symbol.js -> node_modules/core-js/library/modules/_meta.js -> node_modules/@babel/runtime/core-js/object/prevent-extensions.js -> node_modules/core-js/library/fn/object/prevent-extensions.js -> node_modules/core-js/library/modules/es6.object.prevent-extensions.js -> commonjs-proxy:/home/ubuntu/src/rollup-starter-app/node_modules/core-js/library/modules/_is-object.js -> node_modules/core-js/library/modules/_is-object.js (!) Circular dependency: node_modules/core-js/library/modules/_meta.js -> node_modules/@babel/runtime/core-js/object/prevent-extensions.js -> node_modules/core-js/library/fn/object/prevent-extensions.js -> node_modules/core-js/library/modules/es6.object.prevent-extensions.js -> commonjs-proxy:/home/ubuntu/src/rollup-starter-app/node_modules/core-js/library/modules/_meta.js -> node_modules/core-js/library/modules/_meta.js (!) Circular dependency: node_modules/core-js/library/modules/_is-object.js -> node_modules/@babel/runtime/helpers/typeof.js -> node_modules/@babel/runtime/core-js/symbol.js -> node_modules/core-js/library/fn/symbol/index.js -> node_modules/core-js/library/modules/es6.symbol.js -> node_modules/core-js/library/modules/_meta.js -> node_modules/@babel/runtime/core-js/object/is-extensible.js -> node_modules/core-js/library/fn/object/is-extensible.js -> node_modules/core-js/library/modules/es6.object.is-extensible.js -> node_modules/core-js/library/modules/_is-object.js (!) Circular dependency: node_modules/core-js/library/modules/_is-object.js -> node_modules/@babel/runtime/helpers/typeof.js -> node_modules/@babel/runtime/core-js/symbol.js -> node_modules/core-js/library/fn/symbol/index.js -> node_modules/core-js/library/modules/es6.symbol.js -> node_modules/core-js/library/modules/_meta.js -> node_modules/core-js/library/modules/_is-object.js (!) Circular dependency: node_modules/core-js/library/modules/_object-dp.js -> node_modules/core-js/library/modules/_an-object.js -> node_modules/core-js/library/modules/_is-object.js -> node_modules/@babel/runtime/helpers/typeof.js -> node_modules/@babel/runtime/core-js/symbol.js -> node_modules/core-js/library/fn/symbol/index.js -> node_modules/core-js/library/modules/es6.symbol.js -> node_modules/core-js/library/modules/_meta.js -> node_modules/core-js/library/modules/_object-dp.js (!) Circular dependency: node_modules/core-js/library/modules/_object-dp.js -> node_modules/core-js/library/modules/_an-object.js -> node_modules/core-js/library/modules/_is-object.js -> node_modules/@babel/runtime/helpers/typeof.js -> node_modules/@babel/runtime/core-js/symbol.js -> node_modules/core-js/library/fn/symbol/index.js -> node_modules/core-js/library/modules/es6.symbol.js -> node_modules/core-js/library/modules/_set-to-string-tag.js -> node_modules/core-js/library/modules/_object-dp.js (!) Circular dependency: node_modules/core-js/library/modules/_object-dp.js -> node_modules/core-js/library/modules/_an-object.js -> node_modules/core-js/library/modules/_is-object.js -> node_modules/@babel/runtime/helpers/typeof.js -> node_modules/@babel/runtime/core-js/symbol.js -> node_modules/core-js/library/fn/symbol/index.js -> node_modules/core-js/library/modules/es6.symbol.js -> node_modules/core-js/library/modules/_wks-define.js -> node_modules/core-js/library/modules/_object-dp.js (!) Circular dependency: node_modules/core-js/library/modules/_object-keys.js -> node_modules/@babel/runtime/core-js/object/keys.js -> node_modules/core-js/library/fn/object/keys.js -> node_modules/core-js/library/modules/es6.object.keys.js -> node_modules/core-js/library/modules/_object-keys.js (!) Circular dependency: node_modules/core-js/library/modules/_object-keys.js -> node_modules/@babel/runtime/core-js/object/keys.js -> node_modules/core-js/library/fn/object/keys.js -> node_modules/core-js/library/modules/es6.object.keys.js -> commonjs-proxy:/home/ubuntu/src/rollup-starter-app/node_modules/core-js/library/modules/_object-keys.js -> node_modules/core-js/library/modules/_object-keys.js (!) Circular dependency: node_modules/core-js/library/modules/es6.symbol.js -> node_modules/core-js/library/modules/_enum-keys.js -> node_modules/core-js/library/modules/_object-gops.js -> node_modules/@babel/runtime/core-js/object/get-own-property-symbols.js -> node_modules/core-js/library/fn/object/get-own-property-symbols.js -> node_modules/core-js/library/modules/es6.symbol.js (!) Circular dependency: node_modules/core-js/library/modules/es6.symbol.js -> node_modules/core-js/library/modules/_enum-keys.js -> node_modules/core-js/library/modules/_object-gops.js -> node_modules/@babel/runtime/core-js/object/get-own-property-symbols.js -> node_modules/core-js/library/fn/object/get-own-property-symbols.js -> commonjs-proxy:/home/ubuntu/src/rollup-starter-app/node_modules/core-js/library/modules/es6.symbol.js -> node_modules/core-js/library/modules/es6.symbol.js (!) Circular dependency: node_modules/core-js/library/modules/_an-object.js -> node_modules/core-js/library/modules/_is-object.js -> node_modules/@babel/runtime/helpers/typeof.js -> node_modules/@babel/runtime/core-js/symbol.js -> node_modules/core-js/library/fn/symbol/index.js -> node_modules/core-js/library/modules/es6.symbol.js -> node_modules/core-js/library/modules/_an-object.js (!) Circular dependency: node_modules/core-js/library/modules/_is-object.js -> node_modules/@babel/runtime/helpers/typeof.js -> node_modules/@babel/runtime/core-js/symbol.js -> node_modules/core-js/library/fn/symbol/index.js -> node_modules/core-js/library/modules/es6.symbol.js -> node_modules/core-js/library/modules/_is-object.js (!) Circular dependency: node_modules/core-js/library/modules/_is-object.js -> node_modules/@babel/runtime/helpers/typeof.js -> node_modules/@babel/runtime/core-js/symbol.js -> node_modules/core-js/library/fn/symbol/index.js -> node_modules/core-js/library/modules/es6.symbol.js -> node_modules/core-js/library/modules/_to-primitive.js -> node_modules/core-js/library/modules/_is-object.js (!) Circular dependency: node_modules/core-js/library/modules/_export.js -> node_modules/core-js/library/modules/_hide.js -> node_modules/core-js/library/modules/_object-dp.js -> node_modules/core-js/library/modules/_an-object.js -> node_modules/core-js/library/modules/_is-object.js -> node_modules/@babel/runtime/helpers/typeof.js -> node_modules/@babel/runtime/core-js/symbol.js -> node_modules/core-js/library/fn/symbol/index.js -> node_modules/core-js/library/modules/es6.symbol.js -> node_modules/core-js/library/modules/_object-create.js -> node_modules/@babel/runtime/core-js/object/create.js -> node_modules/core-js/library/fn/object/create.js -> node_modules/core-js/library/modules/es6.object.create.js -> node_modules/core-js/library/modules/_export.js (!) Circular dependency: node_modules/core-js/library/modules/_object-create.js -> node_modules/@babel/runtime/core-js/object/create.js -> node_modules/core-js/library/fn/object/create.js -> node_modules/core-js/library/modules/es6.object.create.js -> node_modules/core-js/library/modules/_object-create.js (!) Circular dependency: node_modules/core-js/library/modules/_object-create.js -> node_modules/@babel/runtime/core-js/object/create.js -> node_modules/core-js/library/fn/object/create.js -> node_modules/core-js/library/modules/es6.object.create.js -> commonjs-proxy:/home/ubuntu/src/rollup-starter-app/node_modules/core-js/library/modules/_object-create.js -> node_modules/core-js/library/modules/_object-create.js (!) Circular dependency: node_modules/core-js/library/modules/_an-object.js -> node_modules/core-js/library/modules/_is-object.js -> node_modules/@babel/runtime/helpers/typeof.js -> node_modules/@babel/runtime/core-js/symbol.js -> node_modules/core-js/library/fn/symbol/index.js -> node_modules/core-js/library/modules/es6.symbol.js -> node_modules/core-js/library/modules/_object-create.js -> node_modules/core-js/library/modules/_an-object.js (!) Circular dependency: node_modules/core-js/library/modules/_export.js -> node_modules/core-js/library/modules/_hide.js -> node_modules/core-js/library/modules/_object-dp.js -> node_modules/core-js/library/modules/_an-object.js -> node_modules/core-js/library/modules/_is-object.js -> node_modules/@babel/runtime/helpers/typeof.js -> node_modules/@babel/runtime/core-js/symbol.js -> node_modules/core-js/library/fn/symbol/index.js -> node_modules/core-js/library/modules/es6.symbol.js -> node_modules/core-js/library/modules/_object-create.js -> node_modules/core-js/library/modules/_object-dps.js -> node_modules/@babel/runtime/core-js/object/define-properties.js -> node_modules/core-js/library/fn/object/define-properties.js -> node_modules/core-js/library/modules/es6.object.define-properties.js -> node_modules/core-js/library/modules/_export.js (!) Circular dependency: node_modules/core-js/library/modules/_object-dps.js -> node_modules/@babel/runtime/core-js/object/define-properties.js -> node_modules/core-js/library/fn/object/define-properties.js -> node_modules/core-js/library/modules/es6.object.define-properties.js -> node_modules/core-js/library/modules/_object-dps.js (!) Circular dependency: node_modules/core-js/library/modules/_object-dps.js -> node_modules/@babel/runtime/core-js/object/define-properties.js -> node_modules/core-js/library/fn/object/define-properties.js -> node_modules/core-js/library/modules/es6.object.define-properties.js -> commonjs-proxy:/home/ubuntu/src/rollup-starter-app/node_modules/core-js/library/modules/_object-dps.js -> node_modules/core-js/library/modules/_object-dps.js (!) Circular dependency: node_modules/core-js/library/modules/_object-dp.js -> node_modules/core-js/library/modules/_an-object.js -> node_modules/core-js/library/modules/_is-object.js -> node_modules/@babel/runtime/helpers/typeof.js -> node_modules/@babel/runtime/core-js/symbol.js -> node_modules/core-js/library/fn/symbol/index.js -> node_modules/core-js/library/modules/es6.symbol.js -> node_modules/core-js/library/modules/_object-create.js -> node_modules/core-js/library/modules/_object-dps.js -> node_modules/core-js/library/modules/_object-dp.js (!) Circular dependency: node_modules/core-js/library/modules/_an-object.js -> node_modules/core-js/library/modules/_is-object.js -> node_modules/@babel/runtime/helpers/typeof.js -> node_modules/@babel/runtime/core-js/symbol.js -> node_modules/core-js/library/fn/symbol/index.js -> node_modules/core-js/library/modules/es6.symbol.js -> node_modules/core-js/library/modules/_object-create.js -> node_modules/core-js/library/modules/_object-dps.js -> node_modules/core-js/library/modules/_an-object.js (!) Circular dependency: node_modules/core-js/library/modules/_an-object.js -> node_modules/core-js/library/modules/_is-object.js -> node_modules/@babel/runtime/helpers/typeof.js -> node_modules/@babel/runtime/core-js/symbol.js -> node_modules/core-js/library/fn/symbol/index.js -> node_modules/core-js/library/modules/es6.symbol.js -> node_modules/core-js/library/modules/_object-create.js -> node_modules/core-js/library/modules/_object-dps.js -> commonjs-proxy:/home/ubuntu/src/rollup-starter-app/node_modules/core-js/library/modules/_an-object.js -> node_modules/core-js/library/modules/_an-object.js (!) Circular dependency: node_modules/core-js/library/modules/_is-object.js -> node_modules/@babel/runtime/helpers/typeof.js -> node_modules/@babel/runtime/core-js/symbol.js -> node_modules/core-js/library/fn/symbol/index.js -> node_modules/core-js/library/modules/es6.symbol.js -> node_modules/core-js/library/modules/_object-create.js -> node_modules/core-js/library/modules/_dom-create.js -> node_modules/core-js/library/modules/_is-object.js (!) Circular dependency: node_modules/core-js/library/modules/_object-gopn-ext.js -> node_modules/@babel/runtime/core-js/object/get-own-property-names.js -> node_modules/core-js/library/fn/object/get-own-property-names.js -> node_modules/core-js/library/modules/es6.object.get-own-property-names.js -> node_modules/core-js/library/modules/_object-gopn-ext.js (!) Circular dependency: node_modules/core-js/library/modules/_object-gopn-ext.js -> node_modules/@babel/runtime/core-js/object/get-own-property-names.js -> node_modules/core-js/library/fn/object/get-own-property-names.js -> node_modules/core-js/library/modules/es6.object.get-own-property-names.js -> commonjs-proxy:/home/ubuntu/src/rollup-starter-app/node_modules/core-js/library/modules/_object-gopn-ext.js -> node_modules/core-js/library/modules/_object-gopn-ext.js (!) Circular dependency: node_modules/@babel/runtime/helpers/typeof.js -> node_modules/@babel/runtime/core-js/symbol.js -> node_modules/core-js/library/fn/symbol/index.js -> node_modules/core-js/library/modules/es6.symbol.js -> node_modules/core-js/library/modules/_object-gopn-ext.js -> node_modules/@babel/runtime/helpers/typeof.js (!) Circular dependency: node_modules/core-js/library/modules/_object-gopd.js -> node_modules/@babel/runtime/core-js/object/get-own-property-descriptor.js -> node_modules/core-js/library/fn/object/get-own-property-descriptor.js -> node_modules/core-js/library/modules/es6.object.get-own-property-descriptor.js -> node_modules/core-js/library/modules/_object-gopd.js (!) Circular dependency: node_modules/core-js/library/modules/_object-gopd.js -> node_modules/@babel/runtime/core-js/object/get-own-property-descriptor.js -> node_modules/core-js/library/fn/object/get-own-property-descriptor.js -> node_modules/core-js/library/modules/es6.object.get-own-property-descriptor.js -> commonjs-proxy:/home/ubuntu/src/rollup-starter-app/node_modules/core-js/library/modules/_object-gopd.js -> node_modules/core-js/library/modules/_object-gopd.js (!) Circular dependency: node_modules/core-js/library/modules/_object-dp.js -> node_modules/core-js/library/modules/_an-object.js -> node_modules/core-js/library/modules/_is-object.js -> node_modules/@babel/runtime/helpers/typeof.js -> node_modules/@babel/runtime/core-js/symbol.js -> node_modules/core-js/library/fn/symbol/index.js -> node_modules/core-js/library/modules/es6.symbol.js -> node_modules/core-js/library/modules/_object-dp.js (!) Circular dependency: node_modules/core-js/library/modules/_hide.js -> node_modules/core-js/library/modules/_object-dp.js -> node_modules/core-js/library/modules/_an-object.js -> node_modules/core-js/library/modules/_is-object.js -> node_modules/@babel/runtime/helpers/typeof.js -> node_modules/@babel/runtime/core-js/symbol.js -> node_modules/core-js/library/fn/symbol/index.js -> node_modules/core-js/library/modules/es6.symbol.js -> node_modules/core-js/library/modules/_hide.js (!) Circular dependency: node_modules/core-js/library/modules/_object-gpo.js -> node_modules/@babel/runtime/core-js/object/get-prototype-of.js -> node_modules/core-js/library/fn/object/get-prototype-of.js -> node_modules/core-js/library/modules/es6.object.get-prototype-of.js -> node_modules/core-js/library/modules/_object-gpo.js (!) Circular dependency: node_modules/core-js/library/modules/_object-gpo.js -> node_modules/@babel/runtime/core-js/object/get-prototype-of.js -> node_modules/core-js/library/fn/object/get-prototype-of.js -> node_modules/core-js/library/modules/es6.object.get-prototype-of.js -> commonjs-proxy:/home/ubuntu/src/rollup-starter-app/node_modules/core-js/library/modules/_object-gpo.js -> node_modules/core-js/library/modules/_object-gpo.js created public/bundle.js in 3.9s ``` ... and throws a runtime error: ``` Uncaught TypeError: Cannot read property 'S' of undefined at bundle.js:104 at bundle.js:2183 on this line: }).a != 7; }); > _export(_export.S + _export.F * !_descriptors, 'Object', { defineProperty: _objectDp.f }); var $Object = _core.Object; ```
zloirock commented 6 years ago

Your issue sounds like a rollup-plugin-commonjs issue - in this case, from is a variable name, not a keyword.

ES6 modules support added to NodeJS recently, to webpack - not so recently, but it does not work in engines without descriptors support (IE8-), it's still not added to browserify, etc.

So, for core-js now makes no sense change the modular system. I think that in the future makes sense add a version of core-js package where CommonJS will be transpiled to ES6 modules, but not soon.

For better support transpiling CommonJS -> ES6 modules feel free to propose changes and add a pull request.

polson136 commented 6 years ago

@joliss Did you ever end up getting this to work? I'm fighting the same battle right now.

hlehmann commented 6 years ago

@zloirock currently webpack concatenation doesn't work with core-js because it needs es6 modules.

Because core-js is made by a lot of small modules, concatenation could have a big impact in bundle size and loading time. This could also be used for your bundled version of core-js.

I fully understand that the priority is to ensure v3 to be ready and fully integrated, with babel for example.

The transcription from commonjs to es6 modules could be done later but there is a breaking change that could be addressed today:

In esm it would be written export default function() {...} which is equivalent to module.exports.default = function () {}.

So I'm suggesting to use the module.exports.default = function () {...} instead of module.exports = function () {...}. That way switching from commonjs to esm would have no breaking change and core-js could became a transpiled version of a core-js-es.

zloirock commented 6 years ago

@hlehmann I am thinking about something like that, but for core-js@4.

brettz9 commented 5 years ago

Besides the use case for bundlers, if core-js source can be converted into ESM, it should also be easier for your build process to use Rollup (webpack doesn't support ESM yet) to provide an ESM distribution file so that the likes of apps that don't want to bother with build steps and the resulting burden it places on the debugging feedback loop (e.g., for demos or test files)--could, now that @babel/polyfill is deprecated, once again be able to reference a single file to get the abilities of the @babel/polyfill/dist/polyfill.js build back (e.g., something like import "./node_modules/core-js/dist/core-es.js";).

nicolo-ribaudo commented 5 years ago

Doesn't

<script type="text/javascript" src="./node_modules/core-js-bundle/index.js"></script>

Work for your usecase?

brettz9 commented 5 years ago

I guess it would, thanks! :)

adriengibrat commented 4 years ago

I dream to be able to use proposals only covered by core-js@3 (thank you @zloirock by the way) like:

<script src="https://unpkg.com/core-js/proposals/iterator-helpers?module"  type="module"></script>

But this will be a possible only if the published package contains an esm version ;)

I also tried to convert core-js to es modules but ran into a lot of issues (the same as described above) and finally dropped.

As of core-js-bundle, it may be usefull for quick dev, IE or old safari; but it's way too heavy (~50kb minified) for this!

@hlehmann I am thinking about something like that, but for core-js@4.

:+1: that's a great news!