-
Notifications
You must be signed in to change notification settings - Fork 1.4k
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
Inline require
opts to process.argv
#1512
Comments
The relevant bit in Mocha's implementation is here. |
We won't support You should be able to use |
Tried this:
This sounds possible, but (I think) we would have to overwrite the global // Nope
require('module').prototype.require = require('@std/esm')(module, { cjs: true, esm: 'js' });
// Nah
require('module').prototype.require = require('@std/esm')(module, true);
// Still no
require('module').prototype.require = require('@std/esm')(module); Different errors with each one, but none of them work. Is this the right approach to take? Any other ideas? |
AVA seems to be using its own loader
// Nope
// Nah
// Still no That's not the right approach. If the esm loader can be the entry point for all tests then you can do: require("@std/esm")(module)("./testForAll.js") but there is no way to enable global require overwriting with its programmatic API (that's a feature). It looks like AVA sends commands as JSON string arguments to its forked processes. I should be able to sniff them. Is this a standard thing or something AVA cooked up? |
It looks like patching
but then it's running into AVA's built-in Babel use (AVA is transpiling the |
@jdalton Ava transpiles its test files by default, but not external files. I'm trying to use |
@mAAdhaTTah I'm saying once |
If AVA is handling transforming the test files via babel, shouldn't |
The problem is that when AVA transpiles the test file
will transpile it to:
So because Update: I made the |
Awesome. We can close this out then, yeah? |
@mAAdhaTTah , I had assumed that would be propagated to the workers, but maybe not.
@jdalton it's our own thing. Note that we do have a stalled PR that aims to forward remaining arguments to the workers, but they'd come after the filename argument so that wouldn't quite help with
It is possible to disable this, yes. You'd lose all other transforms though (currently not a problem with Node.js 8, but it'll hurt the compatibility of your tests with earlier versions). But we can find a way of running https://github.com/avajs/babel-preset-stage-4 without the module transform. |
Can you go into detail. I know some Babel presets like babel-env allow you to disable module transpilation with |
@jdalton to disable module transform you can try with @dinoboff/babel-preset-stage-4 (scoped package for this avajs/babel-preset-stage-4#8):
And in
|
@jdalton we currently do not have that option, but we should. @dinoboff helpfully opened avajs/babel-preset-stage-4#8. Besides this detail, is there anything that prevents |
I patched
That hasn't been brought up. I'd be concerned that deps of deps of deps using |
Description
From @jdalton:
Source: standard-things/esm#89 (comment)
The reason this would be needed/helpful is so that std/esm parses the command line arguments to tell whether it should augment the module require to compile ESM.
May be related to #1393.
Config
If I have this:
std/esm will be able to compile my app code's ESM in the tests without requiring babel.
Relevant Links
The text was updated successfully, but these errors were encountered: