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

New ECMAScript module._compile doesn't being called for "import from" #2379

Closed
mamaniv opened this issue Dec 30, 2019 · 2 comments
Closed

New ECMAScript module._compile doesn't being called for "import from" #2379

mamaniv opened this issue Dec 30, 2019 · 2 comments

Comments

@mamaniv
Copy link

mamaniv commented Dec 30, 2019

  • **Node.js Version 13.5.0 **:
  • OS Windows 7:
  • Scope runtime:

We wrap the function module._compile in order to monitor and replace the compilation of JS files, right before it is being loaded. Using that technique, we can replace the source-code of JS files.

With the new ECMAScript modules, using import from keywords, we are no longer get those invocations, so we can't monitor the module compiling.

Is there any other function that is being called and also exported that we can instrument, in order to "catch" the compilation call?

Note:
We could maybe instrument to a function such as ESMLoader.import, but unfortunately this module is an internal module, lib/internal/process/esm_loader, which is not exported as public to the node.js library and therefore can't be reached.

Thanks,
Niv

@gireeshpunathil
Copy link
Member

@nodejs/loaders

@GeoffreyBooth
Copy link
Member

The ESM loader intentionally isn’t exposed for patching the way the CommonJS one was. There is currently no way to achieve what you’re requesting, though there are efforts to try to support what we’ve been calling hot reloading: nodejs/loaders#22. It’s one of the use cases that ES module loaders aim to support, though there’s a lot to build before it can be achieved so it won’t be implemented soon.

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

3 participants