tsconfig-paths-webpack-plugin icon indicating copy to clipboard operation
tsconfig-paths-webpack-plugin copied to clipboard

can not resolve to correct path when used with webpack5

Open wayne-liberty opened this issue 4 years ago • 6 comments

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.

wayne-liberty avatar Dec 13 '20 08:12 wayne-liberty

same problem, fallbacked to resolve.alias :(

elsasslegend avatar Jun 21 '21 14:06 elsasslegend

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

jakebailey avatar Jul 15 '21 00:07 jakebailey

Any progress please ?

jgchenu avatar Jul 21 '22 04:07 jgchenu

Any progress?

taylor-lindores-reeves avatar Jul 25 '22 16:07 taylor-lindores-reeves

Any progress?

mococa avatar Aug 20 '22 02:08 mococa

Any brogress?

nyngwang avatar Feb 25 '24 12:02 nyngwang