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

feat: use swc for ts-node #55

Merged
merged 6 commits into from
Feb 12, 2022
Merged

feat: use swc for ts-node #55

merged 6 commits into from
Feb 12, 2022

Conversation

jasonkuhrt
Copy link
Owner

@jasonkuhrt jasonkuhrt commented Feb 9, 2022

closes #44

TASKS

  • docs external

@jasonkuhrt
Copy link
Owner Author

related swc-project/swc#1935

@jasonkuhrt
Copy link
Owner Author

Not working:

❯ yarn ts-node src/index
Error: Cannot find module '~/lib/utils'
Require stack:
- /home/debian/projects/jasonkuhrt/template-typescript-lib/src/index.ts
    at Function.Module._resolveFilename (node:internal/modules/cjs/loader:933:15)
    at Function.Module._resolveFilename.sharedData.moduleResolveFilenameHook.installedValue [as _resolveFilename] (/home/debian/projects/jasonkuhrt/template-typescript-lib/node_modules/@cspotcode/source-map-support/source-map-support.js:679:30)
    at Function.Module._load (node:internal/modules/cjs/loader:778:27)
    at Module.require (node:internal/modules/cjs/loader:1005:19)
    at require (node:internal/modules/cjs/helpers:102:18)
    at Object.<anonymous> (/home/debian/projects/jasonkuhrt/template-typescript-lib/src/index.ts:5:14)
    at Module._compile (node:internal/modules/cjs/loader:1101:14)
    at Module.m._compile (/home/debian/projects/jasonkuhrt/template-typescript-lib/node_modules/ts-node/src/index.ts:1459:23)
    at Module.m._compile (/home/debian/projects/jasonkuhrt/template-typescript-lib/node_modules/ts-node/src/index.ts:1459:23)
    at Module.m._compile (/home/debian/projects/jasonkuhrt/template-typescript-lib/node_modules/ts-node/src/index.ts:1459:23) {
  code: 'MODULE_NOT_FOUND',
  requireStack: [
    '/home/debian/projects/jasonkuhrt/template-typescript-lib/src/index.ts'
  ]
}

@Jolg42
Copy link

Jolg42 commented Feb 10, 2022

@jasonkuhrt I just cloned the project, added a console in the index.ts, and it works for me

❯ yarn ts-node src/index
hello

@jasonkuhrt
Copy link
Owner Author

@Jolg42 are you sure you were on this branch?

@jasonkuhrt
Copy link
Owner Author

@Jolg42 also where is hello coming from? It's not in the codebase... 🤔

@Jolg42
Copy link

Jolg42 commented Feb 11, 2022

@jasonkuhrt Ok I was probably not on the branch, now I get

Error: Cannot find module '~/lib/utils'
Require stack:
- /Users/j42/Dev/template-typescript-lib/src/index.ts
    at Function.Module._resolveFilename (node:internal/modules/cjs/loader:941:15)
    at Function.Module._resolveFilename.sharedData.moduleResolveFilenameHook.installedValue [as _resolveFilename] (/Users/j42/Dev/template-typescript-lib/node_modules/@cspotcode/source-map-support/source-map-support.js:679:30)
    at Function.Module._load (node:internal/modules/cjs/loader:774:27)
    at Module.require (node:internal/modules/cjs/loader:1013:19)
    at require (node:internal/modules/cjs/helpers:93:18)
    at Object.<anonymous> (/Users/j42/Dev/template-typescript-lib/src/index.ts:5:14)
    at Module._compile (node:internal/modules/cjs/loader:1109:14)
    at Module.m._compile (/Users/j42/Dev/template-typescript-lib/node_modules/ts-node/src/index.ts:1459:23)
    at Module.m._compile (/Users/j42/Dev/template-typescript-lib/node_modules/ts-node/src/index.ts:1459:23)
    at Module.m._compile (/Users/j42/Dev/template-typescript-lib/node_modules/ts-node/src/index.ts:1459:23) {
  code: 'MODULE_NOT_FOUND',
  requireStack: [ '/Users/j42/Dev/template-typescript-lib/src/index.ts' ]
}

@Jolg42
Copy link

Jolg42 commented Feb 11, 2022

But in index.ts replacing the tilde by a period works

- export * from '~/lib/utils'
+ export * from './lib/utils'

And you can then delete the .swcrc file

@jasonkuhrt
Copy link
Owner Author

jasonkuhrt commented Feb 11, 2022

@Jolg42 that works because its no longer using path aliases. The goal is to have path aliases working.

@jasonkuhrt
Copy link
Owner Author

thread about this TypeStrong/ts-node#1640.

@jasonkuhrt jasonkuhrt merged commit e0e16bc into main Feb 12, 2022
@jasonkuhrt jasonkuhrt deleted the feat/use-swc-for-ts-node branch February 12, 2022 14:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Replace ts-node with tsm
2 participants