Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(@angular-devkit/build-angular): remove
bundleDependencies
from…
… server builder This commit removes the usages of `bundleDependencies` which does not correctly work as webpack will use `require` to import ESM module since we configure the server bundle to be outputted in CJS. Migrating fully to ESM is also currently not viable due to the lack of support from Domino. Even if full ESM was possible, using this option would have resulted in a runtime overhead as Angular libraries would be linked during runtime instead of compile time. BREAKING CHANGE: The server builder `bundleDependencies` option has been removed. This option was used pre Ivy. Currently, using this option is unlikely to produce working server bundles. The `externalDependencies` option can be used instead to exclude specific node_module packages from the final bundle. Closes #23905
- Loading branch information
1 parent
4ead45c
commit 9c13fce
Showing
10 changed files
with
121 additions
and
111 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
27 changes: 27 additions & 0 deletions
27
packages/schematics/angular/migrations/update-15/update-workspace-config.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
/** | ||
* @license | ||
* Copyright Google LLC All Rights Reserved. | ||
* | ||
* Use of this source code is governed by an MIT-style license that can be | ||
* found in the LICENSE file at https://angular.io/license | ||
*/ | ||
|
||
import { Rule } from '@angular-devkit/schematics'; | ||
import { allTargetOptions, updateWorkspace } from '../../utility/workspace'; | ||
import { Builders } from '../../utility/workspace-models'; | ||
|
||
export default function (): Rule { | ||
return updateWorkspace((workspace) => { | ||
for (const project of workspace.projects.values()) { | ||
for (const target of project.targets.values()) { | ||
if (target.builder !== Builders.Server) { | ||
continue; | ||
} | ||
|
||
for (const [, options] of allTargetOptions(target)) { | ||
delete options.bundleDependencies; | ||
} | ||
} | ||
} | ||
}); | ||
} |
86 changes: 86 additions & 0 deletions
86
packages/schematics/angular/migrations/update-15/update-workspace-config_spec.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,86 @@ | ||
/** | ||
* @license | ||
* Copyright Google LLC All Rights Reserved. | ||
* | ||
* Use of this source code is governed by an MIT-style license that can be | ||
* found in the LICENSE file at https://angular.io/license | ||
*/ | ||
|
||
import { JsonObject } from '@angular-devkit/core'; | ||
import { EmptyTree } from '@angular-devkit/schematics'; | ||
import { SchematicTestRunner, UnitTestTree } from '@angular-devkit/schematics/testing'; | ||
import { | ||
BuilderTarget, | ||
Builders, | ||
ProjectType, | ||
WorkspaceSchema, | ||
} from '../../utility/workspace-models'; | ||
|
||
function getServerTarget(tree: UnitTestTree): BuilderTarget<Builders.Server, JsonObject> { | ||
const target = (tree.readJson('/angular.json') as unknown as WorkspaceSchema).projects.app | ||
.architect?.server; | ||
|
||
return target as unknown as BuilderTarget<Builders.Server, JsonObject>; | ||
} | ||
|
||
function createWorkSpaceConfig(tree: UnitTestTree) { | ||
const angularConfig: WorkspaceSchema = { | ||
version: 1, | ||
projects: { | ||
app: { | ||
root: '', | ||
sourceRoot: 'src', | ||
projectType: ProjectType.Application, | ||
prefix: 'app', | ||
architect: { | ||
server: { | ||
builder: Builders.Server, | ||
options: { | ||
main: './server.ts', | ||
bundleDependencies: false, | ||
sourceMaps: true, | ||
// eslint-disable-next-line @typescript-eslint/no-explicit-any | ||
} as any, | ||
configurations: { | ||
one: { | ||
aot: true, | ||
}, | ||
two: { | ||
bundleDependencies: true, | ||
aot: true, | ||
}, | ||
// eslint-disable-next-line @typescript-eslint/no-explicit-any | ||
} as any, | ||
}, | ||
}, | ||
}, | ||
}, | ||
}; | ||
|
||
tree.create('/angular.json', JSON.stringify(angularConfig, undefined, 2)); | ||
} | ||
|
||
const schematicName = 'update-workspace-config'; | ||
|
||
describe(`Migration to update 'angular.json'. ${schematicName}`, () => { | ||
const schematicRunner = new SchematicTestRunner( | ||
'migrations', | ||
require.resolve('../migration-collection.json'), | ||
); | ||
|
||
let tree: UnitTestTree; | ||
beforeEach(() => { | ||
tree = new UnitTestTree(new EmptyTree()); | ||
createWorkSpaceConfig(tree); | ||
}); | ||
|
||
it(`should remove 'bundleDependencies'`, async () => { | ||
const newTree = await schematicRunner.runSchematicAsync(schematicName, {}, tree).toPromise(); | ||
const { options, configurations } = getServerTarget(newTree); | ||
|
||
expect(options.bundleDependencies).toBeUndefined(); | ||
expect(configurations).toBeDefined(); | ||
expect(configurations?.one.bundleDependencies).toBeUndefined(); | ||
expect(configurations?.two.bundleDependencies).toBeUndefined(); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
66 changes: 0 additions & 66 deletions
66
tests/legacy-cli/e2e/tests/misc/universal-bundle-dependencies.ts
This file was deleted.
Oops, something went wrong.