Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cannot find module error after upgrading @swc/core #161

Closed
sacummings91 opened this issue Sep 1, 2023 · 1 comment
Closed

Cannot find module error after upgrading @swc/core #161

sacummings91 opened this issue Sep 1, 2023 · 1 comment

Comments

@sacummings91
Copy link

sacummings91 commented Sep 1, 2023

Hello, I recently upgraded @swc/core from 1.3.74 -> 1.3.82. After doing this when I run tests I get Cannot find module '../types/index.js' from '...'. For some reason it is trying to find the file as a .js file instead of a .ts file.

I tested each @swc/core version incrementally and can confirm that it is working up to 1.3.78 but breaks when switching to 1.3.79.

Here are my config files:

.swcrc

{
  "$schema": "https://json.schemastore.org/swcrc",
  "exclude": ["./lib"],
  "jsc": {
    "parser": {
      "syntax": "typescript",
      "tsx": false,
      "decorators": true,
      "dynamicImport": true
    },
    "target": "es2022",
    "paths": {
      "@ternary/api-lib/*": ["./sub-modules/api-lib/src/*"],
      "@ternary/web-ui-lib/*": ["./sub-modules/api-lib/src/ui-lib/*"]
    },
    "baseUrl": "."
  },
  "module": {
    "type": "commonjs"
  }
}

jest.config.js

module.exports = {
  transform: {
    "^.+\\.(t|j)sx?$": "@swc/jest",
  },
  testEnvironment: "node",
  collectCoverage: true,
  moduleNameMapper: {
    "^@ternary/api-lib/(.*)$": "<rootDir>/sub-modules/api-lib/src/$1",
  },
};
@sacummings91 sacummings91 changed the title Cannot find module error after upgrading @swc/core & @swc/jest Cannot find module error after upgrading @swc/core Sep 1, 2023
@sacummings91 sacummings91 changed the title Cannot find module error after upgrading @swc/core Cannot find module error after upgrading @swc/core Sep 1, 2023
@kdy1
Copy link
Member

kdy1 commented Sep 1, 2023

Already fixed by swc-project/swc#7906

@kdy1 kdy1 closed this as completed Sep 1, 2023
powerfulyang added a commit to powerfulyang/api.powerfulyang.com that referenced this issue Sep 6, 2023
powerfulyang added a commit to powerfulyang/api.powerfulyang.com that referenced this issue Sep 7, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

2 participants