Skip to content

fix(@schematics/angular): differential loading migration should run o… #14411

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
May 13, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -97,20 +97,26 @@ function updateProjects(): Rule {
}

// Older projects app and spec ts configs had script and module set in them.
const tsConfigs = [];
const architect = project.architect;
if (isJsonObject(architect)
if (!(isJsonObject(architect)
&& isJsonObject(architect.build)
&& isJsonObject(architect.build.options)
&& typeof architect.build.options.tsConfig === 'string') {
tsConfigs.push(architect.build.options.tsConfig);
&& architect.build.builder === '@angular-devkit/build-angular:browser')
) {
// Skip projects who's build builder is not build-angular:browser
continue;
}

const tsConfigs = [];
const buildOptionsConfig = architect.build.options;
if (isJsonObject(buildOptionsConfig) && typeof buildOptionsConfig.tsConfig === 'string') {
tsConfigs.push(buildOptionsConfig.tsConfig);
}

if (isJsonObject(architect)
&& isJsonObject(architect.test)
&& isJsonObject(architect.test.options)
&& typeof architect.test.options.tsConfig === 'string') {
tsConfigs.push(architect.test.options.tsConfig);
const testConfig = architect.test;
if (isJsonObject(testConfig)
&& isJsonObject(testConfig.options)
&& typeof testConfig.options.tsConfig === 'string') {
tsConfigs.push(testConfig.options.tsConfig);
}

for (const tsConfig of tsConfigs) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -113,5 +113,19 @@ describe('Migration to version 8', () => {
expect(specsCompilerOptions.target).toBeUndefined();
expect(specsCompilerOptions.module).toBeUndefined();
});

it(`should not update projects which browser builder is not 'build-angular:browser'`, () => {
tree.delete('/browserslist');
const config = JSON.parse(tree.readContent('angular.json'));
config
.projects['migration-test']
.architect
.build
.builder = '@dummy/builders:browser';

tree.overwrite('angular.json', JSON.stringify(config));
const tree2 = schematicRunner.runSchematic('migration-07', {}, tree.branch());
expect(tree2.exists('/browserslist')).toBe(false);
});
});
});