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

jsc.paths didnt work on dynamic import #2724

Closed
aelbore opened this issue Nov 11, 2021 · 3 comments · Fixed by #3879
Closed

jsc.paths didnt work on dynamic import #2724

aelbore opened this issue Nov 11, 2021 · 3 comments · Fixed by #3879
Assignees
Labels
Milestone

Comments

@aelbore
Copy link

aelbore commented Nov 11, 2021

Describe the bug

jsc.paths didnt work on dynamic import

Input code

File => packages/a/src/index.ts

export function displayA() {
  return 'Display A'
}

File => src/index.ts

(async function() {
  const { displayA } = await import('@print/a')

  console.log(displayA())
})()

File => package.json

{
  "name": "swc-tsconfig-paths",
  "main": "index.ts",
  "scripts": {
    "swc": "swc-node ./src/index.ts",
  },
  "devDependencies": {
    "@swc/core": "^1.2.108",
     "@swc/register": "^0.1.7"
  }
}

Error =>

> start
> swc-node ./src/index.ts

(node:26122) UnhandledPromiseRejectionWarning: Error: Cannot find module '@print/a'

Config

{
  "jsc": {
    "parser": {
      "syntax": "typescript",
      "dynamicImport": true
    },
    "target": "es2020",
    "baseUrl": ".",
    "paths": {
      "@print/a": [ "./packages/a/src/index.ts" ]
    }
  },
  "module": {
    "type": "commonjs"
  }
}

Playground link

No response

Expected behavior

Should work properly and recognise the paths

Version

1.2.108

Additional context

No response

@aelbore aelbore added the C-bug label Nov 11, 2021
@aelbore
Copy link
Author

aelbore commented Nov 11, 2021

#2126

@kdy1 kdy1 modified the milestones: v1.2.109, v1.2.110, v1.2.111, v1.2.112 Nov 12, 2021
@kdy1 kdy1 modified the milestones: v1.2.116, v1.2.117, v1.2.118, v1.2.119 Dec 1, 2021
@kdy1 kdy1 modified the milestones: v1.2.119, v1.2.120, v1.2.121 Dec 10, 2021
@kdy1 kdy1 modified the milestones: v1.2.121, v1.2.122 Dec 19, 2021
@kdy1 kdy1 modified the milestones: v1.2.140, v1.2.141, v1.2.142, v1.2.143 Feb 12, 2022
@kdy1 kdy1 modified the milestones: v1.2.143, v1.2.144, v1.2.145, v1.2.146 Feb 19, 2022
@kdy1 kdy1 modified the milestones: v1.2.146, v1.2.147, v1.2.148, v1.2.149 Feb 27, 2022
@kdy1 kdy1 modified the milestones: v1.2.149, v1.2.150 Mar 6, 2022
@kdy1 kdy1 self-assigned this Mar 6, 2022
kdy1 added a commit to kdy1/swc that referenced this issue Mar 6, 2022
@kdy1 kdy1 modified the milestone: v1.2.150 Mar 6, 2022
@kdy1 kdy1 closed this as completed in #3879 Mar 6, 2022
@aelbore
Copy link
Author

aelbore commented Mar 6, 2022

🎉

@swc-bot
Copy link
Collaborator

swc-bot commented Oct 18, 2022

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.

@swc-project swc-project locked as resolved and limited conversation to collaborators Oct 18, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Development

Successfully merging a pull request may close this issue.

3 participants