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

coffeescript registration lost after esm import #11

Closed
dbushong opened this issue Jul 4, 2019 · 4 comments
Closed

coffeescript registration lost after esm import #11

dbushong opened this issue Jul 4, 2019 · 4 comments

Comments

@dbushong
Copy link
Member

dbushong commented Jul 4, 2019

If you have an object-graph file that ultimately somewhere tries to require() a coffeescript file, it doesn't seem to work.

I'm guessing it's related to the esm importing magic; if you console.log(require.extensions) right before this line:

const esmResult = this._importESM(id);

you see coffee, but if you do the same at the top of one of the object-graph.js files, the coffee registration is gone.

I'm not sure the right way to fix this; setting extensions: true in the cjs options to esm() didn't trivially fix it - do we still need ESM? Can we just tell people to use NODE_OPTIONS=--experimental-modules if they want mjs support?

@jkrems
Copy link
Collaborator

jkrems commented Jul 4, 2019

I assume that import(absoluteFileURL) would work with --experimental-modules and its presence should be fine in modern node w/o the flag as long as nothing tries to actually call it. In other words: I think getting rid of esm is fairly reasonable. Hopefully sometime in the next few month we'll get a "real" modules implementation in node without a flag 🤞.

@dbushong
Copy link
Member Author

dbushong commented Jul 8, 2019

Hmm. Is there any way, let alone a good way to feature-detect and branch ESM-supporting code?

@dbushong
Copy link
Member Author

dbushong commented Jul 8, 2019

I guess I could put the import-loading function into a .mjs file of its own, and try/catch requiring it?

@jkrems
Copy link
Collaborator

jkrems commented Jul 9, 2019

Starting at node 10, import('./x') isn't a syntax error. So in theory you could put it into a separate file right now and then remove that indirection once node 8 goes out of support.

dbushong added a commit that referenced this issue Nov 5, 2019
BREAKING CHANGE: now if you want to use `.mjs` files, you need to run
with `NODE_OPTIONS=--experimental-modules` on Node 10.x+

Fixes: #11
dbushong added a commit that referenced this issue Dec 6, 2019
BREAKING CHANGE: now if you want to use `.mjs` files, you need to run
with `NODE_OPTIONS=--experimental-modules` on Node 10.x+

Fixes: #11
dbushong added a commit that referenced this issue Dec 6, 2019
BREAKING CHANGE: now if you want to use `.mjs` files, you need to run
with `NODE_OPTIONS=--experimental-modules` on Node 10.x+.  Also, native
ES module loading is NOT compatible with coffeescript/register

Fixes: #11
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

No branches or pull requests

2 participants