Module not found for TypeScript 4.7
See original GitHub issueExpected Behaviour
Able to bundle.
Actual Behaviour
errors such as:
Module not found: Error: Can't resolve './tersible.js'
Steps to Reproduce the Problem
In TypeScript 4.7, the NodeNext
module resolution requires the source code to specify the extension as .js
.
e.g.:
// index.ts
export * from './tersible.js' // for `tersible.ts`
For ts-jest
on the jest
side,
it solves that by doing a transformation:
moduleNameMapper: {
'^(\\.{1,2}/.*)\\.js$': '$1',
},
Maybe something similar is needed? Would be great to add a section in the readme specifically for that.
Location of a Minimal Repository that Demonstrates the Issue.
Not a minimal repo, but here is an example: https://github.com/unional/tersify.
Run yarn bundle
in the repo
🌷
Issue Analytics
- State:
- Created a year ago
- Comments:54 (50 by maintainers)
Top Results From Across the Web
Documentation - TypeScript 4.7
js files are interpreted as ES modules or CommonJS modules, and defaults to CommonJS when not set. When a file is considered an...
Read more >Typescript cannot find modules that are already installed
I made sure that baseUrl points to the directory node-modules is in so I'm sure the compiler can find node-modules . And just...
Read more >Announcing TypeScript 4.7 - Microsoft Developer Blogs
Today we're excited to announce the availability of TypeScript 4.7! If you're not yet familiar with TypeScript, it's a language that builds ...
Read more >Understanding TypeScript 4.7 and ECMAScript module support
The TypeScript 4.7 release comes a major upgrade to ECMAScript module support for Node.js, allowing developers to better support modules.
Read more >Cannot find module 'X' Error in TypeScript | bobbyhadz
The "Cannot find module or its corresponding type declarations" error occurs when TypeScript cannot locate a third-party or local module in our project....
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
hm, why don’t use https://webpack.js.org/configuration/resolve/#resolveextensionalias? I think it will work
https://github.com/justland/just-web/pull/58
One update. After I add the
cjs/package.json
workaround, at least the CommonJS side resolution is working fine. It’s not directly related to this issue, but it shows that having due-export (CJS + ESM/NodeNext) able to work at the end application.