ES-Feature-Tests
ES-Feature-Tests copied to clipboard
Module tests don't make sense
The module tests don't make sense. They will always fail, even in environments supporting ES6 modules:
-
import
/export
statements are allowed only in top-level scope sonew Function('export var a = 1')
will always fail. -
import
/export
are only allowed in modules, not scripts; in browsers JS code will be able to be loaded as a module via<script type="module" src="path.js"><script>
, in Node it's not fully clear yet. In any case, those tests will need to be run in a different way then every other one. - For
import {a} from 'b'
to not fail the environment needs to first be able to resolve the module'b'
.
To sum up, the tests in their current form don't really make any sense, they will always fail for multiple reasons so they should be removed.
Yes I'm aware. I don't have any knowledge of how to actually test this.
But no, I'm not going to remove them. Modules are far too important to be not tested.
What I'm saying is that the current tests are only creating an illusion of testing; you might as well hardcode false in their results as that's what's effectively happening anyway.
Generic tests would require a standard way of loading JS code in module mode.
Michał Gołębiowski
If it turns out there is no way to parse modules inside non-modules, we may load a module to set the test to true. But I think eventually the tests will probably just infer module support by checking for the system loader API. For now it's a known issue.