-
-
Notifications
You must be signed in to change notification settings - Fork 358
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
todo: figure out how to instrument .mjs files #659
Comments
In newer builds of v8, code coverage is built in. I would say looking at https://chromedevtools.github.io/devtools-protocol/tot/Profiler/#method-startPreciseCoverage first might be the quickest approach. Web compatible hooks for ESM are still being looked at and don't have a spec yet. |
~workflow:
|
Btw, there's a POC for implementing it here: https://github.com/bcoe/c8 |
link to ESM? |
oh I thought it was WebAssembly for Node, but I guess it's ES6 modules for Node? |
Relating to what @bmeck was talking about nodejs/node#22527 was just merged. |
Still an issue. |
I am also looking to use NYC with ESM here is a SO. Is there a way to manually import the files for coverage? |
@coreyfarrell @jrgleason the ESM module implementation in Node.js completely overhauls how |
I just tested |
Is there a resolution to this yet? @bcoe I tried using |
c8 works perfectly for me with .js and type module |
@mikeal c8 works for the subset of modules I've tested with, mind opening an issue on |
Some quick details, I’ll come back to this later to debug a bit more.
One or both of these things may be messing up c8. |
Ok, this seems to be working for me now. I don’t what was going on there but it just works entirely now 🤷🏽♀️ |
@mikeal You are supposed to use mjs to signify it is a moduled javascript file. Another example is cjs for commonJs file. Eventually this may be enforced the same way extensions are required now so better to do it from the start ;-) |
@jrgleason that's not true with That said the current status of node.js is that it doesn't support live transpilation of files loaded by the node.js native ES module loader (regardless of extension). There are a couple proposals to address this but for now using nyc with native ES modules requires that you test pre-instrumented files. As mentioned earlier the alternative is to use c8 instead of nyc. |
Is this necessary anymore given the recommended shift to ESM now that Node's support for it is no longer experimental? |
@bmeck has some amazing work close to landing that introduces ESM modules to node:
nodejs/node#14369
Our strategy for hooking require statements (using require.extensions) will no longer work for
.mjs
files (which use the new ESM module syntax). @bmeck indicates that we might be able to pull off something similar using import()Let's try to stay in the loop, and make sure we have an implementation ready to go for
.mjs
as soon as it's possible.The text was updated successfully, but these errors were encountered: