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

Support resolving ./foo.js to ./foo.ts #342

Closed
gustavopch opened this issue Jul 5, 2023 · 3 comments
Closed

Support resolving ./foo.js to ./foo.ts #342

gustavopch opened this issue Jul 5, 2023 · 3 comments

Comments

@gustavopch
Copy link

gustavopch commented Jul 5, 2023

For some reason, to use ESM in TypeScript, to import ./foo.ts we need to use import foo from './foo.js', so @esbuild-kit/esm-loader should support that.

Basically, try resolving .js to .ts and .jsx to .tsx.

Related:

BTW, consider distributing the library without minification. Minifying just makes it harder to debug locally and use patch-package while providing no benefit.

@SettingDust
Copy link

It works fine with import {foo} from 'foo/index.js' on my end
But not with exports map in foo that make . mapping to index.js

Error [ERR_MODULE_NOT_FOUND]: Cannot find module 'E:\javascript\esbuild-exports-map-ts\packages\foo\node_modules\@esbuild-exports-map-ts\exports-map\index.js' imported from E:\javascript\esbuild-exports-map-ts\packages\foo\index.ts
    at __node_internal_captureLargerStackTrace (node:internal/errors:496:5)
    at new NodeError (node:internal/errors:405:5)
    at finalizeResolution (node:internal/modules/esm/resolve:324:11)
    at moduleResolve (node:internal/modules/esm/resolve:943:10)
    at defaultResolve (node:internal/modules/esm/resolve:1129:11)
    at nextResolve (node:internal/modules/esm/loader:163:28)
    at u (file:///E:/javascript/esbuild-exports-map-ts/node_modules/.pnpm/@[email protected]/node_modules/@esbuild-kit/esm-loader/dist/index.js:1:2406)
    at nextResolve (node:internal/modules/esm/loader:163:28)
    at ESMLoader.resolve (node:internal/modules/esm/loader:835:30)
    at ESMLoader.getModuleJob (node:internal/modules/esm/loader:424:18)
    at ModuleWrap.<anonymous> (node:internal/modules/esm/module_job:77:40)
    at link (node:internal/modules/esm/module_job:76:36)
    at process.processTicksAndRejections (node:internal/process/task_queues:95:5) {
  code: 'ERR_MODULE_NOT_FOUND'
}

@privatenumber privatenumber transferred this issue from esbuild-kit/esm-loader Oct 18, 2023
@privatenumber
Copy link
Owner

Closing as a duplicate of #112

@spearmootz
Copy link

i am getting this error. i posted a similar comment on 112.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Mar 10, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

4 participants