swc-project / jest

Super-fast alternative for babel-jest or ts-jest without type checking. Please use main repository for issues
757 stars 37 forks source link

ReferenceError: Cannot access 'store' before initialization #173

Closed a-lba closed 2 months ago

a-lba commented 2 months ago

When moving from babel-jest to @swc/jest I am getting "ReferenceError: Cannot access 'store' before initialization" error.

swc configuration: transform: { '^.+\\.jsx?$': [ require.resolve('@swc/jest'), { jsc: { target: 'es2017', parser: { syntax: 'ecmascript', jsx: true, decorators: true, dynamicImport: false, }, transform: { legacyDecorator: true, react: { runtime: 'automatic' } }, }, module: { type: 'commonjs' }, sourceMaps: 'inline' } ] },

kdy1 commented 2 months ago

https://github.com/swc-project/swc/issues/7435

Evaluation order of module: "commonjs" is different from tsc. The behavior of tsc is wrong. ESM is an established standard, and the specification explicitly says that ESM imports are hoisted.