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

TypeScript path mapping is not working. #626

Closed
lightyen opened this issue Nov 24, 2021 · 3 comments
Closed

TypeScript path mapping is not working. #626

lightyen opened this issue Nov 24, 2021 · 3 comments
Assignees
Labels
bug Something isn't working

Comments

@lightyen
Copy link

Output

Error: Cannot find module 'x/t'

Reproduction

@Brooooooklyn Brooooooklyn self-assigned this Nov 24, 2021
@Brooooooklyn Brooooooklyn added the bug Something isn't working label Nov 24, 2021
@dmregister
Copy link
Contributor

@Brooooooklyn is this still an issue? If so, is there a workaround?

One thing I did notice is, there isn't a way to pass paths through to swc-node/core. When I add paths to the tsCompilerOptionsToSwcConfig, that's when I get the Cannot find module error. Otherwise I basically get Deprecation warnings on startup, but I dont actually need to have the dist folder built:

(node:87854) [DEP0128] DeprecationWarning: Invalid 'main' field in '...package.json' of 'dist/index.js'. Please either fix that or report it to the module author

@Brooooooklyn
Copy link
Member

@dmregister thanks for your report, I'll check it

@dmregister
Copy link
Contributor

dmregister commented Mar 29, 2022

@Brooooooklyn after some digging I found 2 issues I was facing:

  1. SWC_NODE_PROJECT or TS_NODE_PROJECT always need to be the fully resolved path (I was using relative)
  2. paths were not being mapped inside the tsCompilerOptionsToSwcConfig function

I've created a PR with the changes. Let me now if you have any feedback
#646

Also something I noticed, when specifying paths, it needs to be in the format:
"@swc-node/core": ["@swc-node/core/index.ts"],
instead of a relative path:
"@swc-node/*": ["./*/src/index.ts"]

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Development

Successfully merging a pull request may close this issue.

3 participants