Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(angular): add buildLibsFromSource option to @nrwl/angular:webpac…
…k-browser executor (#9334)
- Loading branch information
1 parent
ac464b9
commit a82edb1
Showing
9 changed files
with
164 additions
and
22 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
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
63 changes: 63 additions & 0 deletions
63
packages/angular/src/migrations/update-13-9-0/set-build-libs-from-source.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,63 @@ | ||
import { | ||
addProjectConfiguration, | ||
ProjectConfiguration, | ||
readProjectConfiguration, | ||
Tree, | ||
} from '@nrwl/devkit'; | ||
import { createTreeWithEmptyWorkspace } from '@nrwl/devkit/testing'; | ||
import migration from './set-build-libs-from-source'; | ||
|
||
describe('set-build-libs-from-source migration', () => { | ||
let tree: Tree; | ||
|
||
beforeEach(() => { | ||
tree = createTreeWithEmptyWorkspace(2); | ||
}); | ||
|
||
it('should not error when project does not have targets', async () => { | ||
addProjectConfiguration(tree, 'app1', { root: 'apps/app1' }); | ||
|
||
await expect(migration(tree)).resolves.not.toThrow(); | ||
}); | ||
|
||
it('should not update when not using the @nrwl/angular:webpack-browser executor', async () => { | ||
const project: ProjectConfiguration = { | ||
root: 'apps/app1', | ||
targets: { build: { executor: '@nrwl/angular:package' } }, | ||
}; | ||
addProjectConfiguration(tree, 'app1', project); | ||
|
||
await migration(tree); | ||
|
||
const resultingProject = readProjectConfiguration(tree, 'app1'); | ||
expect(project).toStrictEqual(resultingProject); | ||
}); | ||
|
||
it('should set buildLibsFromSource to false', async () => { | ||
addProjectConfiguration(tree, 'app1', { | ||
root: 'apps/app1', | ||
targets: { build: { executor: '@nrwl/angular:webpack-browser' } }, | ||
}); | ||
|
||
await migration(tree); | ||
|
||
const project = readProjectConfiguration(tree, 'app1'); | ||
expect(project.targets.build.options).toStrictEqual({ | ||
buildLibsFromSource: false, | ||
}); | ||
}); | ||
|
||
it('should support any target name using @nrwl/angular:webpack-browser', async () => { | ||
addProjectConfiguration(tree, 'app1', { | ||
root: 'apps/app1', | ||
targets: { 'build-base': { executor: '@nrwl/angular:webpack-browser' } }, | ||
}); | ||
|
||
await migration(tree); | ||
|
||
const project = readProjectConfiguration(tree, 'app1'); | ||
expect(project.targets['build-base'].options).toStrictEqual({ | ||
buildLibsFromSource: false, | ||
}); | ||
}); | ||
}); |
30 changes: 30 additions & 0 deletions
30
packages/angular/src/migrations/update-13-9-0/set-build-libs-from-source.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,30 @@ | ||
import { | ||
formatFiles, | ||
getProjects, | ||
Tree, | ||
updateProjectConfiguration, | ||
} from '@nrwl/devkit'; | ||
|
||
export default async function (tree: Tree) { | ||
const projects = getProjects(tree); | ||
|
||
for (const [projectName, project] of projects) { | ||
if (!project.targets) { | ||
continue; | ||
} | ||
|
||
let shouldUpdate = false; | ||
Object.values(project.targets).forEach((target) => { | ||
if (target.executor === '@nrwl/angular:webpack-browser') { | ||
shouldUpdate = true; | ||
target.options = { ...target.options, buildLibsFromSource: false }; | ||
} | ||
}); | ||
|
||
if (shouldUpdate) { | ||
updateProjectConfiguration(tree, projectName, project); | ||
} | ||
} | ||
|
||
await formatFiles(tree); | ||
} |
a82edb1
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Successfully deployed to the following URLs: