Skip to content

Commit

Permalink
fix(react): update migration to work without targets (#9901)
Browse files Browse the repository at this point in the history
  • Loading branch information
jaysoo authored Apr 20, 2022
1 parent a1326ae commit e744768
Show file tree
Hide file tree
Showing 4 changed files with 46 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -41,4 +41,25 @@ describe('React default development configuration', () => {
dev: true,
});
});

it('should work without targets', async () => {
const tree = createTreeWithEmptyWorkspace(2);
addProjectConfiguration(
tree,
'example',
{
root: 'apps/example',
projectType: 'application',
},
true
);

await update(tree);

const config = readProjectConfiguration(tree, 'example');
expect(config).toEqual({
root: 'apps/example',
projectType: 'application',
});
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,13 @@ export async function update(tree: Tree) {

projects.forEach((config, name) => {
let shouldUpdate = false;
if (config.targets.build?.executor === '@nrwl/next:build') {
if (config.targets?.build?.executor === '@nrwl/next:build') {
shouldUpdate = true;
config.targets.build.defaultConfiguration ??= 'production';
config.targets.build.configurations.development ??= {};
}

if (config.targets.serve?.executor === '@nrwl/next:server') {
if (config.targets?.serve?.executor === '@nrwl/next:server') {
shouldUpdate = true;
config.targets.serve.defaultConfiguration ??= 'development';
config.targets.serve.configurations.development ??= {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,4 +45,25 @@ describe('React default development configuration', () => {
buildTarget: `example:build:development`,
});
});

it('should work without targets', async () => {
const tree = createTreeWithEmptyWorkspace(2);
addProjectConfiguration(
tree,
'example',
{
root: 'apps/example',
projectType: 'application',
},
true
);

await update(tree);

const config = readProjectConfiguration(tree, 'example');
expect(config).toEqual({
root: 'apps/example',
projectType: 'application',
});
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ export async function update(tree: Tree) {

projects.forEach((config, name) => {
let shouldUpdate = false;
if (config.targets.build?.executor === '@nrwl/web:webpack') {
if (config.targets?.build?.executor === '@nrwl/web:webpack') {
shouldUpdate = true;
config.targets.build.defaultConfiguration ??= 'production';
config.targets.build.configurations.development ??= {
Expand All @@ -21,7 +21,7 @@ export async function update(tree: Tree) {
};
}

if (config.targets.serve?.executor === '@nrwl/web:dev-server') {
if (config.targets?.serve?.executor === '@nrwl/web:dev-server') {
shouldUpdate = true;
config.targets.serve.defaultConfiguration ??= 'development';
config.targets.serve.configurations.development ??= {
Expand Down

0 comments on commit e744768

Please sign in to comment.