Skip to content

Commit 18de4f4

Browse files
committed
revert: "fix(@ngtools/webpack): improve fallbacking for path mapping"
This reverts commit 47f937e. This commit had a few issues detected by the NativeScript project. It is likely that they would have affected more users (and libraries) and so it is safer to revert now and investigate later. Will likely be fixed in 6.2 by refactoring this whole plugin properly.
1 parent 0a329d6 commit 18de4f4

File tree

1 file changed

+7
-14
lines changed

1 file changed

+7
-14
lines changed

packages/ngtools/webpack/src/paths-plugin.ts

Lines changed: 7 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -154,21 +154,14 @@ export function resolveWithPaths(
154154

155155
// If TypeScript gives us a `.d.ts`, it is probably a node module
156156
if (moduleFilePath.endsWith('.d.ts')) {
157-
const pathNoExtension = moduleFilePath.slice(0, -5);
158-
const pathDirName = path.dirname(moduleFilePath);
159-
const packageRootPath = path.join(pathDirName, 'package.json');
160-
const jsFilePath = `${pathNoExtension}.js`;
161-
162-
if (host.fileExists(pathNoExtension)) {
163-
// This is mainly for secondary entry points
164-
// ex: 'node_modules/@angular/core/testing.d.ts' -> 'node_modules/@angular/core/testing'
165-
request.request = pathNoExtension;
166-
} else if (host.fileExists(packageRootPath)) {
167-
// Let webpack resolve the correct module format
168-
request.request = pathDirName;
169-
} else if (host.fileExists(jsFilePath)) {
170-
// Otherwise, if there is a file with a .js extension use that
157+
// If in a package, let webpack resolve the package
158+
const packageRootPath = path.join(path.dirname(moduleFilePath), 'package.json');
159+
if (!host.fileExists(packageRootPath)) {
160+
// Otherwise, if there is a file with a .js extension use that
161+
const jsFilePath = moduleFilePath.slice(0, -5) + '.js';
162+
if (host.fileExists(jsFilePath)) {
171163
request.request = jsFilePath;
164+
}
172165
}
173166

174167
callback(null, request);

0 commit comments

Comments
 (0)