fix(bundling): handle projects without targets in esbuild thirdParty migration (#16712)

This commit is contained in:
Jack Hsu 2023-05-03 10:35:20 -04:00 committed by GitHub
parent e291c9c79b
commit 1e7aa39a9f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 16 additions and 0 deletions

View File

@ -14,6 +14,17 @@ describe('update-16-0-1-set-thirdparty-true', () => {
tree = createTreeWithEmptyWorkspace();
});
it('should skip migration targets are not set on the project', async () => {
addProjectConfiguration(tree, 'myapp', {
root: 'myapp',
});
await update(tree);
const config = readProjectConfiguration(tree, 'myapp');
expect(config.targets).toBeUndefined();
});
it('should add thirdParty property if bundling is enabled implicitly', async () => {
addProjectConfiguration(tree, 'myapp', {
root: 'myapp',
@ -31,6 +42,7 @@ describe('update-16-0-1-set-thirdparty-true', () => {
thirdParty: true,
});
});
it('should add thirdParty property if bundling is enabled explicitly', async () => {
addProjectConfiguration(tree, 'myapp', {
root: 'myapp',
@ -52,6 +64,7 @@ describe('update-16-0-1-set-thirdparty-true', () => {
thirdParty: true,
});
});
it('should not add thirdParty property if bundling is disabled', async () => {
addProjectConfiguration(tree, 'myapp', {
root: 'myapp',
@ -72,6 +85,7 @@ describe('update-16-0-1-set-thirdparty-true', () => {
bundle: false,
});
});
it('should not set thirdParty property if it was already set', async () => {
addProjectConfiguration(tree, 'myapp', {
root: 'myapp',

View File

@ -10,6 +10,8 @@ export default async function update(host: Tree) {
const projects = getProjects(host);
projects.forEach((projectConfig, projectName) => {
if (!projectConfig.targets) return;
let shouldUpdate = false;
Object.entries(projectConfig.targets).forEach(