Skip to content
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

Will core-js supports exports ESM field? #893

Closed
Tracked by #1310
JLHwung opened this issue Dec 1, 2020 · 4 comments
Closed
Tracked by #1310

Will core-js supports exports ESM field? #893

JLHwung opened this issue Dec 1, 2020 · 4 comments
Milestone

Comments

@JLHwung
Copy link

JLHwung commented Dec 1, 2020

Node.js ESM introduces an "exports" field to instruct whether submodule imports like

import "core-js/modules/es6.array.copy-within"

is allowed.

@babel/preset-env generate imports of core-js as import "core-js/modules/es6.array.copy-within". However core-js package does not specify exports in its package.json. Thus it throws on Node.js and Webpack 5: babel/babel#12378

For such imports to work, core-js can specify exports like

{
  "exports" : {
    "./modules/es6.array.copy-within" : "./modules/es6.array.copy-within.js"
  }
}

similar to what Babel did for @babel/runtime-corejs3: https://unpkg.com/@babel/runtime-corejs3@7.12.5/package.json

In babel/babel#10862 Babel tries to workaround this issue by adding .js to such imports

import "core-js/modules/es6.array.copy-within.js"

However it will break if core-js later adds exports but do not support exporting ./, or core-js decides to ship the .mjs version. I feel it is better to coordinate here.

@zloirock
Copy link
Owner

zloirock commented Dec 3, 2020

I'm thinking about adding it to core-js@4.

@zloirock
Copy link
Owner

zloirock commented Dec 19, 2020

After adding all core-js entries to this field, CI randomly dies (2 / 3 chance) on MacOS https://github.com/zloirock/core-js/actions/runs/432880677 - seems 3k+ entries in this field is too much -/ (sure, we can use patterns and don't specify entries with file extensions - it will reduce the number of lines 3x, but it was planned to increase the number of entries 6x in the next version of core-js for allowing maximal optimization).

@zloirock
Copy link
Owner

zloirock commented Mar 11, 2021

Removing some unnecessary entries allowed to reduce the number of patterns to a reasonable number.

@zloirock
Copy link
Owner

Added in v4 branch.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants