can not resolve to correct path when used with webpack5
See original GitHub issuehere is a minimum repo to show this bug: https://github.com/gespiton/tsconfigplugin-issue-with-webpack-5
The test file in packages/fullscreen couldn’t be correctly resolved. If we check the output bundle js file we will see
/***/ "../packages/fullscreen/src/entry.ts":
/*!*******************************************!*
!*** ../packages/fullscreen/src/entry.ts ***!
\*******************************************/
/***/ ((__unused_webpack_module, exports, __webpack_require__) => {
"use strict";
function __export(m) {
for (var p in m) if (!exports.hasOwnProperty(p)) exports[p] = m[p];
}
Object.defineProperty(exports, "__esModule", ({ value: true }));
console.log('packages/fullscreen/src/entry.ts loaded');
__export(__webpack_require__(/*! ./test */ "./src/test.ts"));
noted that on the last line, the file path is ./src/test.ts
, which resolves to the file application/src/test.ts
. While the correct resolve path should be like ../packages/fullscreen/src/test.ts
(in webpack 4).
I suppose this has something to do with how webpack5 distinguishes files. But I don’t have the knowledge to solve this bug. Wish someone could look into it. For now, I’m planning to use webpack resolve.alias instead of this plugin.
Issue Analytics
- State:
- Created 3 years ago
- Reactions:19
- Comments:5
Top Results From Across the Web
Module not found: Error: Can't resolve (with relative path) ...
Your file structure says that folder name is Container with a capital C. But you are trying to import it by container with...
Read more >Can't resolve 'path' · Issue #1509
I got an error with Angular 11 project Error: ./node_modules/sanitize-html/node_modules/postcss/lib/input.js Module not found: Error: Can't ...
Read more >Resolve
When enabled, symlinked resources are resolved to their real path, not their symlinked location. Note that this may cause module resolution to fail...
Read more >webpack can't resolve 'path'
But you are trying to import it by container with a lowercase c. You will need to change the import or the folder...
Read more >resolve-url-loader
If you can tick at least 1 item in all of these questions then use this loader. It will allow webpack to find...
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 FreeTop 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
Top GitHub Comments
I too have switched to resolve aliases to work around this; I had this this previously and assumed it was my fault, but there’s something going on in the plugin. It’s not too much code to read paths and produce aliases, and the output is the same (but it actually works in cases where the file names conflict between paths).
Any progress?