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

fix: supply '.' subpath for backward compatibility with node.js 13.0-13.1 #11006

Merged
merged 1 commit into from Jan 15, 2020

Conversation

JLHwung
Copy link
Contributor

@JLHwung JLHwung commented Jan 14, 2020

Q                       A
Fixed Issues? https://stackoverflow.com/questions/59706130/error-package-exports-for-path-to-project-folder-node-modules-babel-helper-c
Patch: Bug Fix? Yes
Tests Added + Pass? Manually tested
License MIT

The following snippet will throw on Node.js <= 13.2

require("@babel/helper-compilation-targets")
Error: Package exports for '<path_to_project_folder>/node_modules/@babel/helper-compilation-targets' do not define a '.' subpath

This issue is blocking the preset-env users on Node.js 13.0 - 13.1

The issue is from upstream, which was fixed in https://github.com/nodejs/node/pull/29978/files#diff-76195ce57689942222a27f0dbda6d3b7R495 and later shipped in Node.js 13.2.

Since Node 13 is still current, we offer a . subpath for backward compatibility to Node.js 13.0 - 13.1. Technically if users are running at node.js 12 with --experimental-modules on, they will also see this error, but practically it is a rare situation.

I suggest we simply drop node 13.0 - 13.1 support on Babel v8 so we can continue to use exports: false, it is not a big deal because node 13 is not a LTS candidate and will go EOL at June.

@JLHwung JLHwung added PR: Bug Fix 🐛 A type of pull request used for our changelog categories i: regression labels Jan 14, 2020
@ljharb
Copy link
Member

ljharb commented Feb 24, 2020

Wouldn’t node 13.3+ have failed with exports false too?

Keeping the dot is the correct change, since exports replaces main.

@JLHwung
Copy link
Contributor Author

JLHwung commented Feb 24, 2020

Wouldn’t node 13.3+ have failed with exports false too?

I don't think so. Actually the docs says that exports: false should be specified if

the package does not intend for submodules to be exposed.

When exports: false is specified, node.js will fallback to main field, (link) which exactly fit our need since we are not shipping modern babel builds currently. This behaviour is introduced in Node.js 13.2 so we have to specify a . entry for Node.js 13.0 - 13.2.

@ljharb
Copy link
Member

ljharb commented Feb 24, 2020

ah, good point.

@github-actions github-actions bot added the outdated A closed issue/PR that is archived due to age. Recommended to make a new issue label May 26, 2020
@github-actions github-actions bot locked as resolved and limited conversation to collaborators May 26, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
i: regression outdated A closed issue/PR that is archived due to age. Recommended to make a new issue PR: Bug Fix 🐛 A type of pull request used for our changelog categories
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants