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: expose helpers for legacy versions of Node.js #1801

Merged
merged 3 commits into from Nov 15, 2020
Merged

fix: expose helpers for legacy versions of Node.js #1801

merged 3 commits into from Nov 15, 2020

Conversation

bcoe
Copy link
Member

@bcoe bcoe commented Nov 11, 2020

Expose helpers in extensionless helpers file, which older Node.js versions will interpret as a JavaScript file.

This is the only approach I have found to circumvent exceptions thrown when loading .js files when type is set to module.

Fixes #1789

@bcoe
Copy link
Member Author

bcoe commented Nov 11, 2020

CC: @ljharb, @gpoole

helpers Outdated
Comment on lines 1 to 15
// TODO: remove this file once Node 10 is EOL:
const {
applyExtends,
cjsPlatformShim,
Parser,
processArgv,
} = require('./build/index.cjs');

module.exports = {
applyExtends: (config, cwd, mergeExtends) => {
return applyExtends(config, cwd, mergeExtends, cjsPlatformShim);
},
hideBin: processArgv.hideBin,
Parser,
};
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i'm confused, why an extensionless file instead of a helpers dir with a package.json that has "type": "commonjs" and an index.js file?

The current approach will be way more likely cause problems with parsers and resolvers (admittedly, ones with bugs, but i can't even confidently say resolve would work properly with this)

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I appreciate that having a subfolder would cleanup the top level a bit too, we could pull the mjs in there

@ljharb
Copy link
Contributor

ljharb commented Nov 13, 2020

Does this fix #1799, or does it fix #1798 and #1789?

@bcoe
Copy link
Member Author

bcoe commented Nov 13, 2020

@ljharb Deno was type issues, which should be fixed on the main branch already... I might have to move away from TypeScript for Deno unless someone wants to submit and maintain types that work.

@bcoe bcoe merged commit 107deaa into master Nov 15, 2020
@bcoe bcoe deleted the node-10-fix branch November 15, 2020 17:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Readme CJS example fails with versions of Node older than 12.17
2 participants