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
$ node --input-type=module -e "import { foo } from './index.cjs';"
file:///xxx/[eval1]:1
import { foo } from './index.cjs';
^^^
SyntaxError: Named export 'foo' not found. The requested module './index.cjs' is a CommonJS module, which may not support all module.exports as named exports.
CommonJS modules can always be imported via the default export, for example using:
import pkg from './index.cjs';
const { foo } = pkg;
at ModuleJob._instantiate (node:internal/modules/esm/module_job:123:21)
at async ModuleJob.run (node:internal/modules/esm/module_job:189:5)
at async ESMLoader.eval (node:internal/modules/esm/loader:390:24)
at async loadESM (node:internal/process/esm_loader:91:5)
at async handleMainPromise (node:internal/modules/run_main:65:12)
Version
1.3.66
Additional context
No response
The text was updated successfully, but these errors were encountered:
This closed issue has been automatically locked because it had no new activity for a month. If you are running into a similar issue, please create a new issue with the steps to reproduce. Thank you.
Describe the bug
Two or more named exports will yield a file that cannot be parsed by the CJS lexer and has issues with being imported.
Input code
Config
Playground link
https://play.swc.rs/?version=1.3.66&code=H4sIAAAAAAAAA0utKMgvKlFIzs8rLlFIy89XsFVQB1Lq1lypyDJJiUUgGSClbg0Aikj%2FLjMAAAA%3D&config=H4sIAAAAAAAAA6vmUlBQyipOVrJSqAYygZyCxKLi1CI4HyhSXJlXklgBFFFKTc5NLE4uyiwoUQJL1gLJWh2QEbn5KaU5qQhTSioLQDyl5Pzc3Py8rGKQ%2BlquWgCZ2NHCbwAAAA%3D%3D
Expected behavior
Typescript compiler with similar settings will output the following:
This is analyzable by the node CJS lexer and will work with a destructuring import.
Actual behavior
We get the following which cannot be statically analyzed and gives errors
Version
1.3.66
Additional context
No response
The text was updated successfully, but these errors were encountered: