-
Notifications
You must be signed in to change notification settings - Fork 2.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(node): extend @nx/node:webpack migration to all targets (#17337)
- Loading branch information
Showing
3 changed files
with
80 additions
and
0 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
52 changes: 52 additions & 0 deletions
52
packages/node/src/migrations/update-16-3-1/update-webpack-executor.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,52 @@ | ||
import { addProjectConfiguration, readProjectConfiguration } from '@nx/devkit'; | ||
import { createTreeWithEmptyWorkspace } from '@nx/devkit/testing'; | ||
|
||
import update from './update-webpack-executor'; | ||
|
||
describe('Migration: @nrwl/webpack', () => { | ||
it(`should update usage of webpack executor`, async () => { | ||
let tree = createTreeWithEmptyWorkspace({ layout: 'apps-libs' }); | ||
|
||
addProjectConfiguration(tree, 'myapp', { | ||
root: 'apps/myapp', | ||
sourceRoot: 'apps/myapp/src', | ||
projectType: 'application', | ||
targets: { | ||
foo: { | ||
executor: '@nrwl/node:webpack', | ||
options: {}, | ||
}, | ||
bar: { | ||
executor: '@nx/node:webpack', | ||
options: {}, | ||
}, | ||
}, | ||
}); | ||
|
||
await update(tree); | ||
|
||
expect(readProjectConfiguration(tree, 'myapp')).toEqual({ | ||
$schema: '../../node_modules/nx/schemas/project-schema.json', | ||
name: 'myapp', | ||
root: 'apps/myapp', | ||
sourceRoot: 'apps/myapp/src', | ||
projectType: 'application', | ||
targets: { | ||
foo: { | ||
executor: '@nx/webpack:webpack', | ||
options: { | ||
compiler: 'tsc', | ||
target: 'node', | ||
}, | ||
}, | ||
bar: { | ||
executor: '@nx/webpack:webpack', | ||
options: { | ||
compiler: 'tsc', | ||
target: 'node', | ||
}, | ||
}, | ||
}, | ||
}); | ||
}); | ||
}); |
22 changes: 22 additions & 0 deletions
22
packages/node/src/migrations/update-16-3-1/update-webpack-executor.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,22 @@ | ||
import { | ||
formatFiles, | ||
readProjectConfiguration, | ||
Tree, | ||
updateProjectConfiguration, | ||
} from '@nx/devkit'; | ||
import { forEachExecutorOptions } from '@nx/devkit/src/generators/executor-options-utils'; | ||
|
||
export default async function update(tree: Tree) { | ||
const migrateProject = (options, projectName, targetName) => { | ||
const projectConfig = readProjectConfiguration(tree, projectName); | ||
projectConfig.targets[targetName].executor = '@nx/webpack:webpack'; | ||
projectConfig.targets[targetName].options.compiler = 'tsc'; | ||
projectConfig.targets[targetName].options.target = 'node'; | ||
updateProjectConfiguration(tree, projectName, projectConfig); | ||
}; | ||
|
||
forEachExecutorOptions(tree, '@nx/node:webpack', migrateProject); | ||
forEachExecutorOptions(tree, '@nrwl/node:webpack', migrateProject); | ||
|
||
await formatFiles(tree); | ||
} |
51ff862
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:
nx-dev – ./
nx-dev-git-master-nrwl.vercel.app
nx-five.vercel.app
nx-dev-nrwl.vercel.app
nx.dev