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 bcoe commented Nov 11, 2020

helpers Outdated
// 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,
};
Comment on lines 1 to 15

This comment has been minimized.

@ljharb

ljharb Nov 11, 2020
Contributor

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)

This comment has been minimized.

@bcoe

bcoe Nov 11, 2020
Author Member

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 ljharb commented Nov 13, 2020

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

@bcoe
Copy link
Member Author

@bcoe 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
8 checks passed
8 checks passed
@github-actions
test (10)
Details
@github-actions
test (12)
Details
@github-actions
test (13)
Details
@github-actions
test (14)
Details
@github-actions
windows
Details
@github-actions
esm (14)
Details
@github-actions
deno
Details
@github-actions
coverage
Details
@bcoe bcoe deleted the node-10-fix branch Nov 15, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Linked issues

Successfully merging this pull request may close these issues.

2 participants