-
Notifications
You must be signed in to change notification settings - Fork 1.4k
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
With esm
: AVA 2 supports type: module
, AVA 3 doesn't
#2432
Comments
Yea sorry about that. The |
I don’t have mjs files, but But fair enough |
Right. On mobile, need to check what is supported and what isn’t. |
There's nothing extra to be supported: the module is a real ES Module and should be loaded as an ES Module just like Node can. This combination doesn't seem to be supported:
I think this issue should be reopened (but it should mention JSX/babel) It'd be great to have a full recipe with those 3 ingredients. |
This fails as soon as you:
Here's a full repro that should work, repro.zip with: package.json{
"main": "index.js",
"type": "module",
"scripts": {
"test": "ava"
},
"dependencies": {
"@ava/babel": "^1.0.1",
"@babel/preset-react": "^7.9.4",
"ava": "^3.5.1"
},
"ava": {
"babel": {
"testOptions": {
"plugins": [
"@babel/plugin-syntax-jsx",
"@babel/plugin-transform-react-jsx"
]
},
"extensions": [
"js",
"jsx"
]
}
}
} tests.jsximport same from './index.js' // Only this line is enough to make it crash
import test from 'ava';
test('base', t => {
t.throws(() => <br/>);
}); index.jsexport default x => x; Error
|
@fregante I did not notice you were using |
[sorry if I don't understand the complexity here]
There's a comment that this (or something) needs to be solved in avajs/babel, so should this issue remain open waiting for that instead? |
@dimaqq if you're using JSX with our Babel provider, then yes avajs/babel#13 is the issue you're looking for. In short, ESM only really works without on-the-fly compilers at this point. That's a general observation, nothing to do with AVA really. |
I'm sure that in the easiest of setups (e.g. every file is a true ESM file + no external modules), some on-the-fly compilers will work, but:
|
I know that full ESM support is WIP (#2293) but I wanted to document this regression.
This exact combination fails:
ava.require
: esmtype: module
in the current package.jsonI also tried dropping the internal
supportsESM
function but it fails regardless.A live demo can be seen on vadimdemedes/dom-chef#56 (commits)
I also tried
ava --experimental-modules
(changing therequire().default
toimport
and droppingesm
) but for some reason it says it's still arequire
. I probably don't want to get into that since a dependency isn'ttype: module
eitherThe text was updated successfully, but these errors were encountered: