Skip to content

Commit 9de9e9e

Browse files
committed
revert: "fix(@ngtools/webpack): fix resolution fallback of paths-plugin"
This reverts commit 0bef5aa.
1 parent 11f3c75 commit 9de9e9e

File tree

14 files changed

+8
-227
lines changed

14 files changed

+8
-227
lines changed

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

Lines changed: 8 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -160,40 +160,15 @@ export function resolveWithPaths(
160160
const jsFilePath = `${pathNoExtension}.js`;
161161

162162
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 {
167-
const packageJsonContent = host.readFile(packageRootPath);
168-
let newRequest: string | undefined;
169-
170-
if (packageJsonContent) {
171-
try {
172-
const packageJson = JSON.parse(packageJsonContent);
173-
174-
// Let webpack resolve the correct module format IIF there is a module resolution field
175-
// in the package.json. These are all official fields that Angular uses.
176-
if (typeof packageJson.main == 'string'
177-
|| typeof packageJson.browser == 'string'
178-
|| typeof packageJson.module == 'string'
179-
|| typeof packageJson.es2015 == 'string'
180-
|| typeof packageJson.fesm5 == 'string'
181-
|| typeof packageJson.fesm2015 == 'string') {
182-
newRequest = pathDirName;
183-
}
184-
} catch {
185-
// Ignore exceptions and let it fall through (ie. if package.json file is invalid).
186-
}
187-
}
188-
189-
if (newRequest === undefined && host.fileExists(jsFilePath)) {
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)) {
190170
// Otherwise, if there is a file with a .js extension use that
191-
newRequest = jsFilePath;
192-
}
193-
194-
if (newRequest !== undefined) {
195-
request.request = newRequest;
196-
}
171+
request.request = jsFilePath;
197172
}
198173

199174
callback(null, request);

tests/legacy-cli/e2e/assets/webpack/test-app-path-mapping/aotplugin.config.json

Lines changed: 0 additions & 4 deletions
This file was deleted.

tests/legacy-cli/e2e/assets/webpack/test-app-path-mapping/package.json

Lines changed: 0 additions & 29 deletions
This file was deleted.

tests/legacy-cli/e2e/assets/webpack/test-app-path-mapping/src/app/app.module.ts

Lines changed: 0 additions & 29 deletions
This file was deleted.

tests/legacy-cli/e2e/assets/webpack/test-app-path-mapping/src/app/main.jit.ts

Lines changed: 0 additions & 5 deletions
This file was deleted.

tests/legacy-cli/e2e/assets/webpack/test-app-path-mapping/src/foo/foo.d.ts

Lines changed: 0 additions & 9 deletions
This file was deleted.

tests/legacy-cli/e2e/assets/webpack/test-app-path-mapping/src/foo/foo.js

Lines changed: 0 additions & 6 deletions
This file was deleted.

tests/legacy-cli/e2e/assets/webpack/test-app-path-mapping/src/foo/package.json

Lines changed: 0 additions & 3 deletions
This file was deleted.

tests/legacy-cli/e2e/assets/webpack/test-app-path-mapping/src/foo/right/foo.js

Lines changed: 0 additions & 6 deletions
This file was deleted.

tests/legacy-cli/e2e/assets/webpack/test-app-path-mapping/src/index.html

Lines changed: 0 additions & 12 deletions
This file was deleted.

0 commit comments

Comments
 (0)