regression of Unexpected token import when using es2015 modules
See original GitHub issueSyntaxError: Unexpected token import when using es2015 modules with following config:
//tsconfig
{
"compilerOptions": {
"target": "es5",
"module": "es2015",
"moduleResolution": "node",
...
}
}
// jest
{
"moduleFileExtensions": [
"ts",
"tsx",
"js"
],
"transform": {
".(ts|tsx)": "<rootDir>/node_modules/ts-jest/preprocessor.js"
},
"globals": {
"__TS_CONFIG__": "<rootDir>/src/tsconfig.json"
}
}
- Fix If following line is taken out of enclosing if statement, problem is fixed.
- Expected behavior
should set config.module = 'commonjs';
when loading external tsconfig
with "module": "es2015"
- Actions
- add a new test case to prevent further regressions of this case: https://github.com/kulshekhar/ts-jest/blob/master/tests/__tests__/tsconfig-default.spec.ts#L87
Issue Analytics
- State:
- Created 6 years ago
- Comments:17 (11 by maintainers)
Top Results From Across the Web
Unexpected Token Import for ES6 modules · Issue #2081
It seems that Jest is missing the babel configuration in my package.json and the test suite is failing with 'Unexpected Token Import'.
Read more >Jest not parsing es6: SyntaxError: Unexpected token import
Jest encountered an unexpected token This usually means that you are trying to import a file which Jest cannot parse, e.g. it's not...
Read more >SyntaxError: Unexpected token import in Node.js
The "SyntaxError: Unexpected token import" occurs when we use the ES6 import syntax in a version of Node that doesn't support it. To...
Read more >Node 13 must use import to load es module - Seba Online
You might get errors like SyntaxError: Unexpected token. ... Node 12 implemented ES6 modules If you worked with both React and Node, you...
Read more >unexpected token, expected "," jest
It's trying to use ES modules syntax (import / export) but to do that, it needs to declare ... Unexpected token, expected ";"...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
@kulshekhar count on me if you need help for that refactor, you’re not alone 😉 I’d like to help if I can
@kulshekhar I understand, this is not an easy work, I really appreciate your work don’t get me wrong, just wanted to suggest a way to improve it somehow, maybe it’s not the best solution but might be some direction to follow 😃
Suggested workaround is the best solution possible right now and should be fine for now, and I’m still open to help in the future.