You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I have a stencil component that imports a npm package that has mixed ESM and UMD files in the library. My stencil components builds and runs fine but Jest testing fails because the .mjs file extensions are preferred over the .js file extensions without transforming them. This results in errors like:
TestsuitefailedtorunJestencounteredanunexpectedtokenThisusuallymeansthatyouaretryingtoimportafilewhichJestcannotparse,e.g.it's not plain JavaScript. Details: ......./node_modules/graphql/language/parser.mjs:1 import inspect from '../jsutils/inspect';
^^^^^^
SyntaxError: Cannot use import statement outside a module
Expected behavior:
Jest tests should pass
Steps to reproduce:
Test any component that imports from graphql package or any package that imports from a npm package with mixed ESM and UMD files
Related code:
This started appearing following the commits in
This commit 7 days ago.. 781180d
reordered the moduleFileExtensions from
['ts','tsx','js','mjs','jsx','json','d.ts']
to
['ts','tsx','mjs','js','jsx']
NOTE mjs now precedes js
Other information:
WORKAROUND
To work around this issue you can override the ordering by setting the moduleFileExtensions in stencil.config.ts to...
I should add that there's nothing wrong preferring mjs over js but then the appropriate and necessary changes also have to be made to jest config such that jest can natively support es modules which it is only now starting to address. See jestjs/jest#9430
Stencil version:
I'm submitting a:
[x ] bug report
[ ] feature request
[ ] support request => Please do not submit support requests here, use one of these channels: https://stencil-worldwide.herokuapp.com/ or https://forum.ionicframework.com/
Current behavior:
I have a stencil component that imports a npm package that has mixed ESM and UMD files in the library. My stencil components builds and runs fine but Jest testing fails because the
.mjs
file extensions are preferred over the.js
file extensions without transforming them. This results in errors like:Expected behavior:
Jest tests should pass
Steps to reproduce:
Test any component that imports from graphql package or any package that imports from a npm package with mixed ESM and UMD files
Related code:
This started appearing following the commits in
This commit 7 days ago..
781180d
reordered the
moduleFileExtensions
fromto
NOTE
mjs
now precedesjs
Other information:
WORKAROUND
To work around this issue you can override the ordering by setting the
moduleFileExtensions
in stencil.config.ts to...The text was updated successfully, but these errors were encountered: