diff --git a/packages/esbuild/src/migrations/update-16-0-1-set-thirdparty-true/update-16-0-1-set-thirdparty-true.spec.ts b/packages/esbuild/src/migrations/update-16-0-1-set-thirdparty-true/update-16-0-1-set-thirdparty-true.spec.ts index 8c8f5e447a..7da77d511f 100644 --- a/packages/esbuild/src/migrations/update-16-0-1-set-thirdparty-true/update-16-0-1-set-thirdparty-true.spec.ts +++ b/packages/esbuild/src/migrations/update-16-0-1-set-thirdparty-true/update-16-0-1-set-thirdparty-true.spec.ts @@ -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', diff --git a/packages/esbuild/src/migrations/update-16-0-1-set-thirdparty-true/update-16-0-1-set-thirdparty-true.ts b/packages/esbuild/src/migrations/update-16-0-1-set-thirdparty-true/update-16-0-1-set-thirdparty-true.ts index 875b222828..e1e3973dd1 100644 --- a/packages/esbuild/src/migrations/update-16-0-1-set-thirdparty-true/update-16-0-1-set-thirdparty-true.ts +++ b/packages/esbuild/src/migrations/update-16-0-1-set-thirdparty-true/update-16-0-1-set-thirdparty-true.ts @@ -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(