Skip to content

Commit 874e576

Browse files
clydinalan-agius4
authored andcommitted
fix(@angular-devkit/build-angular): filter explicit external dependencies for Vite prebundling
To ensure that Vite does not unintentionally attempt to prebundle a module that was explicitly marked as external (typically via the `externalDependencies` build option), the full list of externalized imports is now filtered by the dependencies specified within the external configuration. Vite currently will include a module for prebundling if it is present in the include list even though it may also be present in the exclude list.
1 parent 0d64ffc commit 874e576

File tree

1 file changed

+14
-5
lines changed

1 file changed

+14
-5
lines changed

packages/angular_devkit/build_angular/src/builders/application/execute-build.ts

+14-5
Original file line numberDiff line numberDiff line change
@@ -178,12 +178,21 @@ export async function executeBuild(
178178

179179
// Analyze external imports if external options are enabled
180180
if (options.externalPackages || bundlingResult.externalConfiguration) {
181-
const { browser = new Set(), server = new Set() } = bundlingResult.externalImports;
182-
// TODO: Filter externalImports to generate third argument to support wildcard externalConfiguration values
181+
const {
182+
externalConfiguration,
183+
externalImports: { browser, server },
184+
} = bundlingResult;
185+
const implicitBrowser = browser ? [...browser] : [];
186+
const implicitServer = server ? [...server] : [];
187+
// TODO: Implement wildcard externalConfiguration filtering
183188
executionResult.setExternalMetadata(
184-
[...browser],
185-
[...server],
186-
bundlingResult.externalConfiguration,
189+
externalConfiguration
190+
? implicitBrowser.filter((value) => !externalConfiguration.includes(value))
191+
: implicitBrowser,
192+
externalConfiguration
193+
? implicitServer.filter((value) => !externalConfiguration.includes(value))
194+
: implicitServer,
195+
externalConfiguration,
187196
);
188197
}
189198

0 commit comments

Comments
 (0)