-
Notifications
You must be signed in to change notification settings - Fork 2
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
stop using esm
for ES module loading
#14
Conversation
Additional worthy notes:
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
❤️
@@ -1,2 +1,3 @@ | |||
/node_modules | |||
/tmp | |||
/lib/esm/import.js |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: Would this be better as a glob-based override of the eslint settings in .eslintrc
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In the next PR i'll upgrade our lint settings to ones that we can more usefully override to parse this correctly
Unfortunately there's no good way yet to tell if the current version of node has "real" ESM support. But I'm pretty sure that node 10 won't get backported, so maybe it would be best to restrict this to node 12+? P.S.: Even for node 12 it's only "very likely" that we'll backport the final implementation over next few months. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
💚
Sounds reasonable. Restrict with |
I don't think I personally would bother with |
BREAKING CHANGE: now if you want to use `.mjs` files, you should run with `NODE_OPTIONS=--experimental-modules` on Node 12.x+. Also, native ES module loading is NOT compatible with coffeescript/register Fixes: #11
57a71df
to
5608968
Compare
esm
for ES module loadingesm
for ES module loading
Turned on tests for 12.x and looks like there some bugs that need addressing if we'll be telling people to use 12. Will remove [WIP] when ready for re-review |
Can you try it with 13.x, potentially even without the experimental flag? There's quite a big delta between what's in 12/experimental and the code in 13. |
The 12.x issue is something we've seen before that's not related (AFAWCT) directly to ES Modules - it seems to be related to a change in how paths are cached inside the under-documented |
e.g.:
for 'use strict';
const Module = require('module');
const { _nodeModulePaths: getPaths } = Module;
const m1 = new Module('<project>');
m1.filename = `${__dirname}/examples/project/app`;
m1.paths = getPaths(m1.filename);
const m2 = new Module('<cli>');
m2.filename = `${__dirname}/examples/cli/app`;
m2.paths = getPaths(m2.filename);
console.log(m1.require('./package.json'));
console.log(m2.require('./package.json')); |
Seems like maybe we should just move to using createRequire(): 'use strict';
const Module = require('module');
const { createRequire, createRequireFromPath } = Module;
const createReq = createRequire || createRequireFromPath;
const r1 = createReq(`${__dirname}/examples/project/app`);
const r2 = createReq(`${__dirname}/examples/cli/app`);
console.log(r1('./package.json'));
console.log(r2('./package.json'));
(maybe leaving the current implementation in to make 8 happy) |
Oh, yeah. |
Fun interesting node 10 -> 12 behavior change in Proxy:
'use strict';
const INSPECT = require('util').inspect.custom;
const a = {
x: 1,
[INSPECT]() {
return `inspected: ${this.x}`;
},
};
const b = new Proxy(a, { get: () => 2 });
console.log(b); |
Maybe related: nodejs/node#26241 |
BREAKING CHANGE: Node 8.x is no longer supported
0cb2b14
to
9b5b703
Compare
esm
for ES module loadingesm
for ES module loading
Ready for re-review; thanks |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
💚
BREAKING CHANGE: now if you want to use
.mjs
files, you need to runwith
NODE_OPTIONS=--experimental-modules
on Node 10.x+. Also, nativeES module loading is NOT compatible with coffeescript/register
This PR was started by: git wf pr