question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

can not resolve to correct path when used with webpack5

See original GitHub issue

here 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:open
  • Created 3 years ago
  • Reactions:19
  • Comments:5

github_iconTop GitHub Comments

3reactions
jakebaileycommented, Jul 15, 2021

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).

0reactions
mococacommented, Aug 20, 2022

Any progress?

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found