diff --git a/docs/generated/manifests/menus.json b/docs/generated/manifests/menus.json index 580c792e48..81e944090b 100644 --- a/docs/generated/manifests/menus.json +++ b/docs/generated/manifests/menus.json @@ -5219,14 +5219,6 @@ "path": "/packages/node/executors", "name": "executors", "children": [ - { - "id": "webpack", - "path": "/packages/node/executors/webpack", - "name": "webpack", - "children": [], - "isExternal": false, - "disableCollapsible": false - }, { "id": "node", "path": "/packages/node/executors/node", @@ -6425,30 +6417,6 @@ "path": "/packages/web/executors", "name": "executors", "children": [ - { - "id": "webpack", - "path": "/packages/web/executors/webpack", - "name": "webpack", - "children": [], - "isExternal": false, - "disableCollapsible": false - }, - { - "id": "rollup", - "path": "/packages/web/executors/rollup", - "name": "rollup", - "children": [], - "isExternal": false, - "disableCollapsible": false - }, - { - "id": "dev-server", - "path": "/packages/web/executors/dev-server", - "name": "dev-server", - "children": [], - "isExternal": false, - "disableCollapsible": false - }, { "id": "file-server", "path": "/packages/web/executors/file-server", diff --git a/docs/generated/manifests/packages.json b/docs/generated/manifests/packages.json index 70e0fe85b9..531b9847bc 100644 --- a/docs/generated/manifests/packages.json +++ b/docs/generated/manifests/packages.json @@ -1405,15 +1405,6 @@ "root": "/packages/node", "source": "/packages/node/src", "executors": { - "/packages/node/executors/webpack": { - "description": "Build a Node application using Webpack.", - "file": "generated/packages/node/executors/webpack.json", - "hidden": false, - "name": "webpack", - "originalFilePath": "/packages/node/src/executors/webpack/schema.json", - "path": "/packages/node/executors/webpack", - "type": "executor" - }, "/packages/node/executors/node": { "description": "Execute a Node application.", "file": "generated/packages/node/executors/node.json", @@ -2671,33 +2662,6 @@ "root": "/packages/web", "source": "/packages/web/src", "executors": { - "/packages/web/executors/webpack": { - "description": "Build an application using Webpack.", - "file": "generated/packages/web/executors/webpack.json", - "hidden": false, - "name": "webpack", - "originalFilePath": "/packages/web/src/executors/webpack/schema.json", - "path": "/packages/web/executors/webpack", - "type": "executor" - }, - "/packages/web/executors/rollup": { - "description": "Package a library using Rollup.", - "file": "generated/packages/web/executors/rollup.json", - "hidden": false, - "name": "rollup", - "originalFilePath": "/packages/web/src/executors/rollup/schema.json", - "path": "/packages/web/executors/rollup", - "type": "executor" - }, - "/packages/web/executors/dev-server": { - "description": "Serve a web application.", - "file": "generated/packages/web/executors/dev-server.json", - "hidden": false, - "name": "dev-server", - "originalFilePath": "/packages/web/src/executors/dev-server/schema.json", - "path": "/packages/web/executors/dev-server", - "type": "executor" - }, "/packages/web/executors/file-server": { "description": "Serve a web application from a folder.", "file": "generated/packages/web/executors/file-server.json", diff --git a/docs/generated/packages-metadata.json b/docs/generated/packages-metadata.json index c743dfc65d..7d134e5ccb 100644 --- a/docs/generated/packages-metadata.json +++ b/docs/generated/packages-metadata.json @@ -1385,15 +1385,6 @@ } ], "executors": [ - { - "description": "Build a Node application using Webpack.", - "file": "generated/packages/node/executors/webpack.json", - "hidden": false, - "name": "webpack", - "originalFilePath": "/packages/node/src/executors/webpack/schema.json", - "path": "node/executors/webpack", - "type": "executor" - }, { "description": "Execute a Node application.", "file": "generated/packages/node/executors/node.json", @@ -2642,33 +2633,6 @@ } ], "executors": [ - { - "description": "Build an application using Webpack.", - "file": "generated/packages/web/executors/webpack.json", - "hidden": false, - "name": "webpack", - "originalFilePath": "/packages/web/src/executors/webpack/schema.json", - "path": "web/executors/webpack", - "type": "executor" - }, - { - "description": "Package a library using Rollup.", - "file": "generated/packages/web/executors/rollup.json", - "hidden": false, - "name": "rollup", - "originalFilePath": "/packages/web/src/executors/rollup/schema.json", - "path": "web/executors/rollup", - "type": "executor" - }, - { - "description": "Serve a web application.", - "file": "generated/packages/web/executors/dev-server.json", - "hidden": false, - "name": "dev-server", - "originalFilePath": "/packages/web/src/executors/dev-server/schema.json", - "path": "web/executors/dev-server", - "type": "executor" - }, { "description": "Serve a web application from a folder.", "file": "generated/packages/web/executors/file-server.json", diff --git a/docs/shared/guides/module-federation/faster-builds.md b/docs/shared/guides/module-federation/faster-builds.md index bcb956f099..8a312512ab 100644 --- a/docs/shared/guides/module-federation/faster-builds.md +++ b/docs/shared/guides/module-federation/faster-builds.md @@ -115,7 +115,7 @@ To understand how Module Federation works with Nx, let's take a look at three fi ### `apps/host/project.json` -The `build` target uses `@nrwl/web:webpack` for React, and `@nrwl/angular:webpack-browser` for Angular. This is the same as a normal SPA that uses custom webpack configuration (`webpackConfig`), but difference is in the webpack configuration file. +The `build` target uses `@nrwl/webpack:webpack` for React, and `@nrwl/angular:webpack-browser` for Angular. This is the same as a normal SPA that uses custom webpack configuration (`webpackConfig`), but difference is in the webpack configuration file. If you use Module Federation to speed up your CI and improve your local development, and not to deploy different remotes independently, you need to create implicit dependencies from the host to all the remotes. Semantically, the host and the remotes comprise one application, so you cannot build the host without the remotes. Adding implicit dependencies also makes distributed builds possible ([see below](#production-build-and-deployment)). To create these dependencies, add the `implicitDependencies` configuration. diff --git a/docs/shared/guides/use-environment-variables-in-react.md b/docs/shared/guides/use-environment-variables-in-react.md index 85e53fa79a..60201a0663 100644 --- a/docs/shared/guides/use-environment-variables-in-react.md +++ b/docs/shared/guides/use-environment-variables-in-react.md @@ -17,7 +17,7 @@ You cannot interpolate environment variables into your `index.html` file for Rea ## For non-Vite React applications -In React applications (e.g. those using `@nrwl/web:webpack` or `@nrwl/next:build` executors for `build` target), Nx +In React applications (e.g. those using `@nrwl/webpack:webpack` or `@nrwl/next:build` executors for `build` target), Nx includes the following variables in the build process: - `NODE_ENV` diff --git a/docs/shared/guides/using-tailwind-css-in-react.md b/docs/shared/guides/using-tailwind-css-in-react.md index 9132f7acd1..1bca59ead1 100644 --- a/docs/shared/guides/using-tailwind-css-in-react.md +++ b/docs/shared/guides/using-tailwind-css-in-react.md @@ -126,7 +126,7 @@ Open up the `apps/{your app here}/project.json` file and add the following to th // ... "targets": { "build": { - "executor": "@nrwl/web:webpack", + "executor": "@nrwl/webpack:webpack", "options": { // ... "postcssConfig": "apps/{your app here}/postcss.config.js" diff --git a/docs/shared/migration/migration-angularjs.md b/docs/shared/migration/migration-angularjs.md index cc6399f1ab..6e9748a31f 100644 --- a/docs/shared/migration/migration-angularjs.md +++ b/docs/shared/migration/migration-angularjs.md @@ -407,7 +407,7 @@ To use webpack instead of gulp, go back to your `apps/realworld/project.json` fi ```jsonc {% fileName="apps/realworld/project.json" %} ... "build": { - "executor": "@nrwl/web:webpack", + "executor": "@nrwl/webpack:webpack", "options": { "outputPath": "dist/apps/realworld", "index": "apps/realworld/src/index.html", diff --git a/docs/shared/plugin-features/use-task-executors.md b/docs/shared/plugin-features/use-task-executors.md index 0cb1584e68..59cab1ef5d 100644 --- a/docs/shared/plugin-features/use-task-executors.md +++ b/docs/shared/plugin-features/use-task-executors.md @@ -20,7 +20,7 @@ Executors are associated with specific targets in a project's `project.json` fil "generators": {}, "targets": { "build": { - "executor": "@nrwl/web:webpack", + "executor": "@nrwl/webpack:webpack", "options": { "outputPath": "dist/apps/cart", ... diff --git a/nx-dev/nx-dev-e2e/src/e2e/packages.cy.ts b/nx-dev/nx-dev-e2e/src/e2e/packages.cy.ts index 413f44e88e..b9d1240803 100644 --- a/nx-dev/nx-dev-e2e/src/e2e/packages.cy.ts +++ b/nx-dev/nx-dev-e2e/src/e2e/packages.cy.ts @@ -259,7 +259,6 @@ describe('nx-dev: Packages Section', () => { path: '/packages/node/generators/application', }, { title: '@nrwl/node:library', path: '/packages/node/generators/library' }, - { title: '@nrwl/node:webpack', path: '/packages/node/executors/webpack' }, { title: '@nrwl/node:node', path: '/packages/node/executors/node' }, { title: 'nx', path: '/packages/nx' }, { title: 'nx:noop', path: '/packages/nx/executors/noop' }, @@ -421,12 +420,6 @@ describe('nx-dev: Packages Section', () => { title: '@nrwl/web:application', path: '/packages/web/generators/application', }, - { title: '@nrwl/web:webpack', path: '/packages/web/executors/webpack' }, - { title: '@nrwl/web:rollup', path: '/packages/web/executors/rollup' }, - { - title: '@nrwl/web:dev-server', - path: '/packages/web/executors/dev-server', - }, { title: '@nrwl/web:file-server', path: '/packages/web/executors/file-server', diff --git a/nx-dev/nx-dev/redirect-rules.config.js b/nx-dev/nx-dev/redirect-rules.config.js index cf836c6c09..d7c85742e2 100644 --- a/nx-dev/nx-dev/redirect-rules.config.js +++ b/nx-dev/nx-dev/redirect-rules.config.js @@ -531,6 +531,11 @@ const packagesDocuments = { '/packages/eslint-plugin/documents/enforce-module-boundaries', '/packages/eslint-plugin-nx/documents/overview': '/packages/eslint-plugin/documents/overview', + '/packages/node/executors/webpack': '/packages/webpack/executors/webpack', + '/packages/web/executors/webpack': '/packages/webpack/executors/webpack', + '/packages/web/executors/dev-server': + '/packages/webpack/executors/dev-server', + '/packages/web/executors/rollup': '/packages/rollup/executors/rollup', }; /** diff --git a/packages-legacy/web/executors.json b/packages-legacy/web/executors.json index d3f827055f..a21a306a18 100644 --- a/packages-legacy/web/executors.json +++ b/packages-legacy/web/executors.json @@ -1,20 +1,5 @@ { "builders": { - "webpack": { - "implementation": "@nx/web/src/executors/webpack/compat", - "schema": "@nx/web/src/executors/webpack/schema.json", - "description": "Build an application using Webpack." - }, - "rollup": { - "implementation": "@nx/web/src/executors/rollup/compat", - "schema": "@nx/web/src/executors/rollup/schema.json", - "description": "Package a library using Rollup." - }, - "dev-server": { - "implementation": "@nx/web/src/executors/dev-server/compat", - "schema": "@nx/web/src/executors/dev-server/schema.json", - "description": "Serve a web application." - }, "file-server": { "implementation": "@nx/web/src/executors/file-server/compat", "schema": "@nx/web/src/executors/file-server/schema.json", @@ -22,21 +7,6 @@ } }, "executors": { - "webpack": { - "implementation": "@nx/web/src/executors/webpack/webpack.impl", - "schema": "@nx/web/src/executors/webpack/schema.json", - "description": "Build an application using Webpack." - }, - "rollup": { - "implementation": "@nx/web/src/executors/rollup/rollup.impl", - "schema": "@nx/web/src/executors/rollup/schema.json", - "description": "Package a library using Rollup." - }, - "dev-server": { - "implementation": "@nx/web/src/executors/dev-server/dev-server.impl", - "schema": "@nx/web/src/executors/dev-server/schema.json", - "description": "Serve a web application." - }, "file-server": { "implementation": "@nx/web/src/executors/file-server/file-server.impl", "schema": "@nx/web/src/executors/file-server/schema.json", diff --git a/packages/cypress/src/generators/cypress-component-project/cypress-component-project.spec.ts b/packages/cypress/src/generators/cypress-component-project/cypress-component-project.spec.ts index 37542bf201..01dcdacd04 100644 --- a/packages/cypress/src/generators/cypress-component-project/cypress-component-project.spec.ts +++ b/packages/cypress/src/generators/cypress-component-project/cypress-component-project.spec.ts @@ -18,7 +18,7 @@ let projectConfig: ProjectConfiguration = { root: 'libs/cool-lib', targets: { build: { - executor: '@nx/web:rollup', + executor: '@nx/rollup:rollup', options: { tsConfig: 'libs/cool-lib/tsconfig.lib.json', }, diff --git a/packages/expo/src/generators/library/library.spec.ts b/packages/expo/src/generators/library/library.spec.ts index 93af2eca66..6a23737230 100644 --- a/packages/expo/src/generators/library/library.spec.ts +++ b/packages/expo/src/generators/library/library.spec.ts @@ -232,7 +232,7 @@ describe('lib', () => { const projects = getProjects(appTree); expect(projects.get('my-lib').targets.build).toMatchObject({ - executor: '@nx/web:rollup', + executor: '@nx/rollup:rollup', outputs: ['{options.outputPath}'], options: { external: ['react/jsx-runtime', 'react-native'], diff --git a/packages/expo/src/generators/library/library.ts b/packages/expo/src/generators/library/library.ts index ab2a50282f..2c0017f953 100644 --- a/packages/expo/src/generators/library/library.ts +++ b/packages/expo/src/generators/library/library.ts @@ -90,7 +90,7 @@ function addProject(host: Tree, options: NormalizedSchema) { const external = ['react/jsx-runtime', 'react-native']; targets.build = { - executor: '@nx/web:rollup', + executor: '@nx/rollup:rollup', outputs: ['{options.outputPath}'], options: { outputPath: `dist/${libsDir}/${options.projectDirectory}`, diff --git a/packages/js/babel.ts b/packages/js/babel.ts index 8f1e0935c7..2790f077e3 100644 --- a/packages/js/babel.ts +++ b/packages/js/babel.ts @@ -20,7 +20,7 @@ module.exports = function (api: any, options: NxWebBabelPresetOptions = {}) { const isModern = api.caller((caller) => caller?.isModern); - // This is set by `@nx/web:rollup` executor + // This is set by `@nx/rollup:rollup` executor const isNxPackage = api.caller((caller) => caller?.isNxPackage); const emitDecoratorMetadata = api.caller( diff --git a/packages/node/executors.json b/packages/node/executors.json index c6fc8f875e..92934806b1 100644 --- a/packages/node/executors.json +++ b/packages/node/executors.json @@ -1,10 +1,5 @@ { "executors": { - "webpack": { - "implementation": "./src/executors/webpack/webpack.impl", - "schema": "./src/executors/webpack/schema.json", - "description": "Build a Node application using Webpack." - }, "node": { "implementation": "./src/executors/node/node.impl", "schema": "./src/executors/node/schema.json", @@ -12,11 +7,6 @@ } }, "builders": { - "webpack": { - "implementation": "./src/executors/webpack/compat", - "schema": "./src/executors/webpack/schema.json", - "description": "Build a Node application using Webpack." - }, "node": { "implementation": "./src/executors/node/compat", "schema": "./src/executors/node/schema.json", diff --git a/packages/node/migrations.json b/packages/node/migrations.json index bc27d650a1..5782ea51dd 100644 --- a/packages/node/migrations.json +++ b/packages/node/migrations.json @@ -35,6 +35,12 @@ "version": "16.0.0-beta.1", "description": "Replace @nrwl/node with @nx/node", "implementation": "./src/migrations/update-16-0-0-add-nx-packages/update-16-0-0-add-nx-packages" + }, + "update-16-0-0-update-executor": { + "cli": "nx", + "version": "16.0.0-beta.5", + "description": "Replace @nrwl/node:webpack with @nx/node:webpack", + "implementation": "./src/migrations/update-16-0-0/update-webpack-executor" } }, "packageJsonUpdates": { diff --git a/packages/node/package.json b/packages/node/package.json index b59f27c868..d17ade5156 100644 --- a/packages/node/package.json +++ b/packages/node/package.json @@ -36,7 +36,6 @@ "@nx/jest": "file:../jest", "@nx/js": "file:../js", "@nx/linter": "file:../linter", - "@nx/webpack": "file:../webpack", "@nx/workspace": "file:../workspace" }, "publishConfig": { diff --git a/packages/node/src/executors/webpack/compat.ts b/packages/node/src/executors/webpack/compat.ts deleted file mode 100644 index e04afb8239..0000000000 --- a/packages/node/src/executors/webpack/compat.ts +++ /dev/null @@ -1,5 +0,0 @@ -import { convertNxExecutor } from '@nx/devkit'; - -import { webpackExecutor } from './webpack.impl'; - -export default convertNxExecutor(webpackExecutor); diff --git a/packages/node/src/executors/webpack/schema.json b/packages/node/src/executors/webpack/schema.json deleted file mode 100644 index 9008bb4f3f..0000000000 --- a/packages/node/src/executors/webpack/schema.json +++ /dev/null @@ -1,275 +0,0 @@ -{ - "version": 2, - "outputCapture": "direct-nodejs", - "title": "Node Application Build Target", - "description": "Node application build target options for Build Facade.", - "cli": "nx", - "type": "object", - "properties": { - "main": { - "type": "string", - "description": "The name of the main entry-point file.", - "x-completion-type": "file", - "x-completion-glob": "main@(.js|.ts)" - }, - "tsConfig": { - "type": "string", - "description": "The name of the Typescript configuration file.", - "x-completion-type": "file", - "x-completion-glob": "tsconfig.*.json" - }, - "outputPath": { - "type": "string", - "description": "The output path of the generated files.", - "x-completion-type": "directory", - "x-priority": "important" - }, - "deleteOutputPath": { - "type": "boolean", - "description": "Delete the output path before building.", - "default": true - }, - "watch": { - "type": "boolean", - "description": "Run build when files change.", - "default": false - }, - "watchOptions": { - "type": "object", - "description": "A set of options used to customize watch mode.", - "properties": { - "aggregateTimeout": { - "type": "integer" - }, - "ignored": { - "oneOf": [ - { - "type": "array", - "items": { - "type": "string" - } - }, - { - "type": "string" - } - ] - }, - "poll": { - "type": "integer" - }, - "followSymlinks": { - "type": "boolean" - }, - "stdin": { - "type": "boolean" - } - } - }, - "poll": { - "type": "number", - "description": "Frequency of file watcher in ms." - }, - "sourceMap": { - "type": "boolean", - "description": "Produce source maps.", - "default": true - }, - "progress": { - "type": "boolean", - "description": "Log progress to the console while building.", - "default": false - }, - "assets": { - "type": "array", - "description": "List of static application assets.", - "default": [], - "items": { - "$ref": "#/definitions/assetPattern" - } - }, - "externalDependencies": { - "oneOf": [ - { - "type": "string", - "enum": ["none", "all"] - }, - { - "type": "array", - "items": { - "type": "string" - } - } - ], - "description": "Dependencies to keep external to the bundle. (`all` (default), `none`, or an array of module names)", - "default": "all" - }, - "statsJson": { - "type": "boolean", - "description": "Generates a `stats.json` file which can be analyzed using tools such as: `webpack-bundle-analyzer` or ``.", - "default": false - }, - "verbose": { - "type": "boolean", - "description": "Emits verbose output", - "default": false - }, - "extractLicenses": { - "type": "boolean", - "description": "Extract all licenses in a separate file, in the case of production builds only.", - "default": false - }, - "optimization": { - "type": "boolean", - "description": "Defines the optimization level of the build.", - "default": false - }, - "maxWorkers": { - "type": "number", - "description": "Number of workers to use for type checking. (defaults to # of CPUS)" - }, - "memoryLimit": { - "type": "number", - "description": "Memory limit for type checking service process in MB. (defaults to `2048`)", - "default": 2048 - }, - "fileReplacements": { - "description": "Replace files with other files in the build.", - "type": "array", - "items": { - "type": "object", - "properties": { - "replace": { - "type": "string", - "description": "The file to be replaced.", - "x-completion-type": "file" - }, - "with": { - "type": "string", - "description": "The file to replace with.", - "x-completion-type": "file" - } - }, - "additionalProperties": false, - "required": ["replace", "with"] - }, - "default": [] - }, - "webpackConfig": { - "oneOf": [ - { - "type": "array", - "items": { - "type": "string", - "x-completion-type": "file", - "x-completion-glob": "webpack?(*)@(.js|.ts)" - } - }, - { - "type": "string", - "x-completion-type": "file", - "x-completion-glob": "webpack?(*)@(.js|.ts)" - } - ], - "description": "Path to a function which takes a webpack config, context and returns the resulting webpack config. See https://nx.dev/guides/customize-webpack" - }, - "buildLibsFromSource": { - "type": "boolean", - "description": "Read buildable libraries from source instead of building them separately.", - "default": true - }, - "generatePackageJson": { - "type": "boolean", - "description": "Generates a `package.json` and pruned lock file with the project's `node_module` dependencies populated for installing in a container. If a `package.json` exists in the project's directory, it will be reused with dependencies populated.", - "default": false - }, - "transformers": { - "type": "array", - "description": "List of TypeScript Compiler Transfomers Plugins.", - "default": [], - "aliases": ["tsPlugins"], - "items": { - "$ref": "#/definitions/transformerPattern" - } - }, - "additionalEntryPoints": { - "type": "array", - "items": { - "type": "object", - "properties": { - "entryName": { - "type": "string", - "description": "Name of the additional entry file." - }, - "entryPath": { - "type": "string", - "description": "Path to the additional entry file.", - "x-completion-type": "file", - "x-completion-glob": "**/*@(.js|.ts)" - } - } - } - }, - "outputFileName": { - "type": "string", - "description": "Name of the main output file. (defaults to `main.js`)", - "default": "main.js" - } - }, - "required": ["tsConfig", "main"], - "definitions": { - "assetPattern": { - "oneOf": [ - { - "type": "object", - "properties": { - "glob": { - "type": "string", - "description": "The pattern to match." - }, - "input": { - "type": "string", - "description": "The input directory path in which to apply `glob`. Defaults to the project root." - }, - "ignore": { - "description": "An array of globs to ignore.", - "type": "array", - "items": { - "type": "string" - } - }, - "output": { - "type": "string", - "description": "Absolute path within the output." - } - }, - "additionalProperties": false, - "required": ["glob", "input", "output"] - }, - { - "type": "string" - } - ] - }, - "transformerPattern": { - "oneOf": [ - { - "type": "string" - }, - { - "type": "object", - "properties": { - "name": { - "type": "string" - }, - "options": { - "type": "object", - "additionalProperties": true - } - }, - "additionalProperties": false, - "required": ["name"] - } - ] - } - } -} diff --git a/packages/node/src/executors/webpack/webpack.impl.ts b/packages/node/src/executors/webpack/webpack.impl.ts deleted file mode 100644 index ca45b28649..0000000000 --- a/packages/node/src/executors/webpack/webpack.impl.ts +++ /dev/null @@ -1,28 +0,0 @@ -/** - * For backwards compat. - * TODO(v16): Remove in Nx 16. - */ -import { ExecutorContext, logger } from '@nx/devkit'; -import type { WebpackExecutorOptions } from '@nx/webpack'; -import { webpackExecutor as baseWebpackExecutor } from '@nx/webpack'; - -export async function* webpackExecutor( - options: WebpackExecutorOptions, - context: ExecutorContext -) { - logger.warn( - '"@nx/node:webpack" executor is deprecated. Use "@nx/webpack:webpack" instead in your project.json.' - ); - yield* baseWebpackExecutor( - { - ...options, - target: 'node', - compiler: 'tsc', - scripts: [], - styles: [], - }, - context - ); -} - -export default webpackExecutor; diff --git a/packages/node/src/migrations/update-16-0-0/update-webpack-executor.ts b/packages/node/src/migrations/update-16-0-0/update-webpack-executor.ts new file mode 100644 index 0000000000..330ac3de7b --- /dev/null +++ b/packages/node/src/migrations/update-16-0-0/update-webpack-executor.ts @@ -0,0 +1,21 @@ +import { + formatFiles, + getProjects, + Tree, + updateProjectConfiguration, +} from '@nx/devkit'; + +export default async function update(host: Tree) { + const projects = getProjects(host); + + for (const [name, config] of projects.entries()) { + if (config?.targets?.build?.executor === '@nrwl/node:webpack') { + config.targets.build.executor = '@nx/webpack:webpack'; + config.targets.build.options.target = 'node'; + config.targets.build.options.compiler = 'tsc'; + updateProjectConfiguration(host, name, config); + } + } + + await formatFiles(host); +} diff --git a/packages/nx/src/config/workspace-json-project-json.ts b/packages/nx/src/config/workspace-json-project-json.ts index a1847f6c69..901bb779b5 100644 --- a/packages/nx/src/config/workspace-json-project-json.ts +++ b/packages/nx/src/config/workspace-json-project-json.ts @@ -136,7 +136,7 @@ export interface TargetConfiguration { /** * The executor/builder used to implement the target. * - * Example: '@nx/web:rollup' + * Example: '@nx/rollup:rollup' */ executor?: string; diff --git a/packages/react-native/src/generators/library/library.spec.ts b/packages/react-native/src/generators/library/library.spec.ts index cf0e871e57..165bd00bc0 100644 --- a/packages/react-native/src/generators/library/library.spec.ts +++ b/packages/react-native/src/generators/library/library.spec.ts @@ -268,7 +268,7 @@ describe('lib', () => { const projectConfiguration = readProjectConfiguration(appTree, 'my-lib'); expect(projectConfiguration.targets.build).toMatchObject({ - executor: '@nx/web:rollup', + executor: '@nx/rollup:rollup', outputs: ['{options.outputPath}'], options: { external: ['react/jsx-runtime', 'react-native'], diff --git a/packages/react-native/src/generators/library/library.ts b/packages/react-native/src/generators/library/library.ts index d1cc5962e5..9feea8af76 100644 --- a/packages/react-native/src/generators/library/library.ts +++ b/packages/react-native/src/generators/library/library.ts @@ -84,7 +84,7 @@ function addProject(host: Tree, options: NormalizedSchema) { const external = ['react/jsx-runtime', 'react-native']; targets.build = { - executor: '@nx/web:rollup', + executor: '@nx/rollup:rollup', outputs: ['{options.outputPath}'], options: { outputPath: `dist/${libsDir}/${options.projectDirectory}`, diff --git a/packages/storybook/src/generators/configuration/test-configs/root-workspace-configuration.json b/packages/storybook/src/generators/configuration/test-configs/root-workspace-configuration.json index 9f45cee862..1d1bd1a55d 100644 --- a/packages/storybook/src/generators/configuration/test-configs/root-workspace-configuration.json +++ b/packages/storybook/src/generators/configuration/test-configs/root-workspace-configuration.json @@ -10,7 +10,9 @@ "executor": "@nx/vite:build", "outputs": ["{options.outputPath}"], "defaultConfiguration": "production", - "options": { "outputPath": "dist/web" }, + "options": { + "outputPath": "dist/web" + }, "configurations": { "development": {}, "production": { @@ -27,9 +29,13 @@ "serve": { "executor": "@nx/vite:dev-server", "defaultConfiguration": "development", - "options": { "buildTarget": "web:build" }, + "options": { + "buildTarget": "web:build" + }, "configurations": { - "development": { "buildTarget": "web:build:development" }, + "development": { + "buildTarget": "web:build:development" + }, "production": { "buildTarget": "web:build:production", "hmr": false @@ -39,7 +45,9 @@ "test": { "executor": "@nx/vite:test", "outputs": ["{projectRoot}/coverage"], - "options": { "passWithNoTests": true } + "options": { + "passWithNoTests": true + } }, "storybook": { "executor": "@storybook/angular:start-storybook", @@ -49,7 +57,11 @@ "browserTarget": "web:build-storybook", "compodoc": false }, - "configurations": { "ci": { "quiet": true } } + "configurations": { + "ci": { + "quiet": true + } + } }, "build-storybook": { "executor": "@storybook/angular:build-storybook", @@ -60,7 +72,11 @@ "browserTarget": "web:build-storybook", "compodoc": false }, - "configurations": { "ci": { "quiet": true } } + "configurations": { + "ci": { + "quiet": true + } + } } }, "tags": [], @@ -179,7 +195,7 @@ "tags": [], "targets": { "build": { - "executor": "@nx/web:rollup", + "executor": "@nx/rollup:rollup", "outputs": ["{options.outputPath}"], "options": { "outputPath": "dist/libs/nxlib-buildable", @@ -223,7 +239,7 @@ "tags": [], "targets": { "build": { - "executor": "@nx/web:rollup", + "executor": "@nx/rollup:rollup", "outputs": ["{options.outputPath}"], "options": { "outputPath": "dist/libs/relib-buildable", diff --git a/packages/storybook/src/generators/configuration/test-configs/workspace-conifiguration.json b/packages/storybook/src/generators/configuration/test-configs/workspace-conifiguration.json index 6ef12ac6dd..270f8c774e 100644 --- a/packages/storybook/src/generators/configuration/test-configs/workspace-conifiguration.json +++ b/packages/storybook/src/generators/configuration/test-configs/workspace-conifiguration.json @@ -174,7 +174,7 @@ "tags": [], "targets": { "build": { - "executor": "@nx/web:rollup", + "executor": "@nx/rollup:rollup", "outputs": ["{options.outputPath}"], "options": { "outputPath": "dist/libs/nxlib-buildable", @@ -218,7 +218,7 @@ "tags": [], "targets": { "build": { - "executor": "@nx/web:rollup", + "executor": "@nx/rollup:rollup", "outputs": ["{options.outputPath}"], "options": { "outputPath": "dist/libs/relib-buildable", diff --git a/packages/storybook/src/utils/test-configs/different-target-variations.json b/packages/storybook/src/utils/test-configs/different-target-variations.json index 935639f67e..534e3a314e 100644 --- a/packages/storybook/src/utils/test-configs/different-target-variations.json +++ b/packages/storybook/src/utils/test-configs/different-target-variations.json @@ -70,7 +70,7 @@ }, "nextlib": { "build": { - "executor": "@nx/web:rollup", + "executor": "@nx/rollup:rollup", "outputs": ["{options.outputPath}"], "options": { "outputPath": "dist/libs/next-lib-buildable", @@ -116,7 +116,6 @@ "styles": ["apps/ngapp/src/styles.css"], "scripts": [] }, - "defaultConfiguration": "production" }, "serve": { @@ -131,7 +130,6 @@ }, "defaultConfiguration": "development" }, - "storybook": { "executor": "@storybook/angular:start-storybook", "options": { diff --git a/packages/storybook/src/utils/utilities.ts b/packages/storybook/src/utils/utilities.ts index 74c0537d44..beb0fb8e29 100644 --- a/packages/storybook/src/utils/utilities.ts +++ b/packages/storybook/src/utils/utilities.ts @@ -197,7 +197,6 @@ export function findStorybookAndBuildTargetsAndCompiler(targets: { '@nx/js:tsc', '@nx/webpack:webpack', '@nx/rollup:rollup', - '@nx/web:rollup', '@nx/vite:build', '@nx/angular:ng-packagr-lite', '@nx/angular:package', diff --git a/packages/vite/src/utils/generator-utils.ts b/packages/vite/src/utils/generator-utils.ts index 98f3f06455..7a8c0474b6 100644 --- a/packages/vite/src/utils/generator-utils.ts +++ b/packages/vite/src/utils/generator-utils.ts @@ -46,7 +46,6 @@ export function findExistingTargetsInProject( '@nx/js:swc', '@nx/webpack:webpack', '@nx/rollup:rollup', - '@nx/web:rollup', '@nrwl/js:babel', '@nrwl/js:swc', '@nrwl/webpack:webpack', diff --git a/packages/web/executors.json b/packages/web/executors.json index e9a918e9a9..181d172806 100644 --- a/packages/web/executors.json +++ b/packages/web/executors.json @@ -1,20 +1,5 @@ { "builders": { - "webpack": { - "implementation": "./src/executors/webpack/compat", - "schema": "./src/executors/webpack/schema.json", - "description": "Build an application using Webpack." - }, - "rollup": { - "implementation": "./src/executors/rollup/compat", - "schema": "./src/executors/rollup/schema.json", - "description": "Package a library using Rollup." - }, - "dev-server": { - "implementation": "./src/executors/dev-server/compat", - "schema": "./src/executors/dev-server/schema.json", - "description": "Serve a web application." - }, "file-server": { "implementation": "./src/executors/file-server/compat", "schema": "./src/executors/file-server/schema.json", @@ -22,21 +7,6 @@ } }, "executors": { - "webpack": { - "implementation": "./src/executors/webpack/webpack.impl", - "schema": "./src/executors/webpack/schema.json", - "description": "Build an application using Webpack." - }, - "rollup": { - "implementation": "./src/executors/rollup/rollup.impl", - "schema": "./src/executors/rollup/schema.json", - "description": "Package a library using Rollup." - }, - "dev-server": { - "implementation": "./src/executors/dev-server/dev-server.impl", - "schema": "./src/executors/dev-server/schema.json", - "description": "Serve a web application." - }, "file-server": { "implementation": "./src/executors/file-server/file-server.impl", "schema": "./src/executors/file-server/schema.json", diff --git a/packages/web/migrations.json b/packages/web/migrations.json index 4106e1b67b..84c2150e77 100644 --- a/packages/web/migrations.json +++ b/packages/web/migrations.json @@ -65,6 +65,12 @@ "version": "16.0.0-beta.1", "description": "Replace @nrwl/web with @nx/web", "implementation": "./src/migrations/update-16-0-0-add-nx-packages/update-16-0-0-add-nx-packages" + }, + "update-16-0-0-update-executors": { + "cli": "nx", + "version": "16.0.0-beta.4", + "description": "Replace @nrwl/web executors with @nx/webpack and @nx/rollup", + "implementation": "./src/migrations/update-16-0-0-update-executors/update-16-0-0-update-executors" } }, "packageJsonUpdates": { diff --git a/packages/web/src/executors/dev-server/compat.ts b/packages/web/src/executors/dev-server/compat.ts deleted file mode 100644 index 34b277b04e..0000000000 --- a/packages/web/src/executors/dev-server/compat.ts +++ /dev/null @@ -1,5 +0,0 @@ -import { convertNxExecutor } from '@nx/devkit'; - -import devServerExecutor from './dev-server.impl'; - -export default convertNxExecutor(devServerExecutor); diff --git a/packages/web/src/executors/dev-server/dev-server.impl.ts b/packages/web/src/executors/dev-server/dev-server.impl.ts deleted file mode 100644 index 300c9255e3..0000000000 --- a/packages/web/src/executors/dev-server/dev-server.impl.ts +++ /dev/null @@ -1,23 +0,0 @@ -/** - * This is here for backwards-compat. - * TODO(v16): remove in Nx 16. - */ -import { ExecutorContext, logger } from '@nx/devkit'; - -export async function* devServerExecutor( - options: any, - context: ExecutorContext -) { - const { devServerExecutor: baseDevServerExecutor } = require('@nx/webpack'); - logger.warn( - '"@nx/web:dev-server" executor is deprecated. Use "@nx/webpack:dev-server" instead in your project.json.' - ); - yield* baseDevServerExecutor( - { - ...options, - target: 'web', - }, - context - ); -} -export default devServerExecutor; diff --git a/packages/web/src/executors/dev-server/schema.json b/packages/web/src/executors/dev-server/schema.json deleted file mode 100644 index 9f644f5812..0000000000 --- a/packages/web/src/executors/dev-server/schema.json +++ /dev/null @@ -1,81 +0,0 @@ -{ - "version": 2, - "outputCapture": "direct-nodejs", - "title": "Web Dev Server", - "description": "Serve a web application.", - "cli": "nx", - "type": "object", - "properties": { - "buildTarget": { - "type": "string", - "description": "Target which builds the application." - }, - "port": { - "type": "number", - "description": "Port to listen on.", - "default": 4200 - }, - "host": { - "type": "string", - "description": "Host to listen on.", - "default": "localhost" - }, - "ssl": { - "type": "boolean", - "description": "Serve using `HTTPS`.", - "default": false - }, - "sslKey": { - "type": "string", - "description": "SSL key to use for serving `HTTPS`." - }, - "sslCert": { - "type": "string", - "description": "SSL certificate to use for serving `HTTPS`." - }, - "watch": { - "type": "boolean", - "description": "Watches for changes and rebuilds application.", - "default": true - }, - "liveReload": { - "type": "boolean", - "description": "Whether to reload the page on change, using live-reload.", - "default": true - }, - "hmr": { - "type": "boolean", - "description": "Enable hot module replacement.", - "default": false - }, - "publicHost": { - "type": "string", - "description": "Public URL where the application will be served.", - "x-priority": "important" - }, - "open": { - "type": "boolean", - "description": "Open the application in the browser.", - "default": false - }, - "allowedHosts": { - "type": "string", - "description": "This option allows you to whitelist services that are allowed to access the dev server." - }, - "memoryLimit": { - "type": "number", - "description": "Memory limit for type checking service process in `MB`." - }, - "maxWorkers": { - "type": "number", - "description": "Number of workers to use for type checking." - }, - "baseHref": { - "type": "string", - "description": "Base url for the application being built.", - "x-priority": "important" - } - }, - "additionalProperties": false, - "required": ["buildTarget"] -} diff --git a/packages/web/src/executors/rollup/compat.ts b/packages/web/src/executors/rollup/compat.ts deleted file mode 100644 index 4681ebee42..0000000000 --- a/packages/web/src/executors/rollup/compat.ts +++ /dev/null @@ -1,5 +0,0 @@ -import { convertNxExecutor } from '@nx/devkit'; - -import rollupExecutor from './rollup.impl'; - -export default convertNxExecutor(rollupExecutor); diff --git a/packages/web/src/executors/rollup/rollup.impl.ts b/packages/web/src/executors/rollup/rollup.impl.ts deleted file mode 100644 index 40d55ca8b8..0000000000 --- a/packages/web/src/executors/rollup/rollup.impl.ts +++ /dev/null @@ -1,25 +0,0 @@ -/** - * This is here for backwards-compat. - * TODO(v16): remove in Nx 16. - */ -import { - rollupExecutor as _rollupExecutor, - RollupExecutorOptions as WebRollupOptions, -} from '@nx/rollup'; -import { logger } from 'nx/src/utils/logger'; - -export { WebRollupOptions }; - -export async function* rollupExecutor(options: any, context: any) { - logger.warn( - '"@nx/web:rollup" executor is deprecated. Use "@nx/rollup:rollup" instead in your project.json.' - ); - return yield* _rollupExecutor( - { - ...options, - main: options.main || options.entryFile, - }, - context - ); -} -export default rollupExecutor; diff --git a/packages/web/src/executors/rollup/schema.d.ts b/packages/web/src/executors/rollup/schema.d.ts deleted file mode 100644 index ce0906a8a6..0000000000 --- a/packages/web/src/executors/rollup/schema.d.ts +++ /dev/null @@ -1,29 +0,0 @@ -type Compiler = 'babel' | 'swc'; - -export interface Globals { - moduleId: string; - global: string; -} - -export interface WebRollupOptions { - outputPath: string; - tsConfig: string; - project: string; - entryFile: string; - extractCss?: boolean | string; - globals?: Globals[]; - external?: string[]; - rollupConfig?: string | string[]; - watch?: boolean; - assets?: any[]; - updateBuildableProjectDepsInPackageJson?: boolean; - buildableProjectDepsInPackageJsonType?: 'dependencies' | 'peerDependencies'; - umdName?: string; - deleteOutputPath?: boolean; - format: string[]; - compiler?: Compiler; - javascriptEnabled?: boolean; - // TODO(jack): remove this for Nx 16 - skipTypeField?: boolean; - generateExportsField?: boolean; -} diff --git a/packages/web/src/executors/rollup/schema.json b/packages/web/src/executors/rollup/schema.json deleted file mode 100644 index 380a068397..0000000000 --- a/packages/web/src/executors/rollup/schema.json +++ /dev/null @@ -1,153 +0,0 @@ -{ - "version": 2, - "outputCapture": "direct-nodejs", - "title": "Web Library Rollup Target (Experimental)", - "description": "Packages a library for different web usages (`UMD`, `ESM`, `CJS`).", - "cli": "nx", - "type": "object", - "properties": { - "project": { - "type": "string", - "description": "The path to package.json file." - }, - "entryFile": { - "type": "string", - "description": "The path to the entry file, relative to project.", - "x-completion-type": "file", - "x-completion-glob": "**/*@(.js|.ts)" - }, - "outputPath": { - "type": "string", - "description": "The output path of the generated files.", - "x-completion-type": "directory" - }, - "deleteOutputPath": { - "type": "boolean", - "description": "Delete the output path before building.", - "default": true - }, - "tsConfig": { - "type": "string", - "description": "The path to tsconfig file.", - "x-completion-type": "file", - "x-completion-glob": "tsconfig.*.json" - }, - "format": { - "type": "array", - "description": "Only build the specified comma-separated formats (`esm,umd,cjs`)", - "alias": "f", - "items": { - "type": "string", - "enum": ["esm", "umd", "cjs"] - }, - "default": ["esm"], - "x-priority": "important" - }, - "external": { - "type": "array", - "description": "A list of external modules that will not be bundled (`react`, `react-dom`, etc.).", - "items": { - "type": "string" - } - }, - "watch": { - "type": "boolean", - "description": "Enable re-building when files change.", - "default": false - }, - "updateBuildableProjectDepsInPackageJson": { - "type": "boolean", - "description": "Update buildable project dependencies in `package.json`.", - "default": true - }, - "buildableProjectDepsInPackageJsonType": { - "type": "string", - "description": "When `updateBuildableProjectDepsInPackageJson` is `true`, this adds dependencies to either `peerDependencies` or `dependencies`.", - "enum": ["dependencies", "peerDependencies"], - "default": "peerDependencies" - }, - "rollupConfig": { - "oneOf": [ - { - "type": "array", - "items": { - "type": "string", - "x-completion-type": "file", - "x-completion-glob": "rollup?(*)@(.js|.ts)" - } - }, - { - "type": "string", - "x-completion-type": "file", - "x-completion-glob": "rollup?(*)@(.js|.ts)" - } - ], - "description": "Path to a function which takes a rollup config and returns an updated rollup config.", - "x-priority": "important" - }, - "extractCss": { - "type": ["boolean", "string"], - "description": "CSS files will be extracted to the output folder. Alternatively custom filename can be provided (e.g. styles.css)", - "default": true - }, - "assets": { - "type": "array", - "description": "List of static assets.", - "default": [], - "items": { - "$ref": "#/definitions/assetPattern" - } - }, - "compiler": { - "type": "string", - "enum": ["babel", "swc"], - "default": "babel", - "description": "Which compiler to use.", - "x-priority": "important" - }, - "javascriptEnabled": { - "type": "boolean", - "description": "Sets `javascriptEnabled` option for less loader", - "default": false - }, - "generateExportsField": { - "type": "boolean", - "description": "Generate package.json with 'exports' field. This field defines entry points in the package and is used by Node and the TypeScript compiler.", - "default": false - }, - "skipTypeField": { - "type": "boolean", - "description": "Prevents 'type' field from being added to compiled package.json file. Only use this if you are having an issue with this field.", - "default": false - } - }, - "required": ["tsConfig", "entryFile", "outputPath"], - "definitions": { - "assetPattern": { - "oneOf": [ - { - "type": "object", - "properties": { - "glob": { - "type": "string", - "description": "The pattern to match." - }, - "input": { - "type": "string", - "description": "The input directory path in which to apply `glob`. Defaults to the project root." - }, - "output": { - "type": "string", - "description": "Relative path within the output folder." - } - }, - "additionalProperties": false, - "required": ["glob", "input", "output"] - }, - { - "type": "string" - } - ] - } - } -} diff --git a/packages/web/src/executors/webpack/compat.ts b/packages/web/src/executors/webpack/compat.ts deleted file mode 100644 index e04afb8239..0000000000 --- a/packages/web/src/executors/webpack/compat.ts +++ /dev/null @@ -1,5 +0,0 @@ -import { convertNxExecutor } from '@nx/devkit'; - -import { webpackExecutor } from './webpack.impl'; - -export default convertNxExecutor(webpackExecutor); diff --git a/packages/web/src/executors/webpack/schema.json b/packages/web/src/executors/webpack/schema.json deleted file mode 100644 index 8e01be78f5..0000000000 --- a/packages/web/src/executors/webpack/schema.json +++ /dev/null @@ -1,374 +0,0 @@ -{ - "version": 2, - "outputCapture": "direct-nodejs", - "title": "Webpack Executor", - "description": "Builds web applications using webpack.", - "cli": "nx", - "type": "object", - "properties": { - "crossOrigin": { - "type": "string", - "description": "The `crossorigin` attribute to use for generated javascript script tags. One of 'none' | 'anonymous' | 'use-credentials'." - }, - "main": { - "type": "string", - "description": "The name of the main entry-point file.", - "x-completion-type": "file", - "x-completion-glob": "**/*@(.js|.ts|.tsx)" - }, - "tsConfig": { - "type": "string", - "description": "The name of the Typescript configuration file.", - "x-completion-type": "file", - "x-completion-glob": "tsconfig.*.json" - }, - "compiler": { - "type": "string", - "description": "The compiler to use.", - "enum": ["babel", "swc"], - "default": "babel", - "x-priority": "important" - }, - "outputPath": { - "type": "string", - "description": "The output path of the generated files.", - "x-completion-type": "directory" - }, - "deleteOutputPath": { - "type": "boolean", - "description": "Delete the output path before building.", - "default": true - }, - "watch": { - "type": "boolean", - "description": "Enable re-building when files change.", - "default": false - }, - "baseHref": { - "type": "string", - "description": "Base url for the application being built.", - "x-priority": "important" - }, - "deployUrl": { - "type": "string", - "description": "URL where the application will be deployed.", - "x-priority": "important" - }, - "vendorChunk": { - "type": "boolean", - "description": "Use a separate bundle containing only vendor libraries.", - "default": true - }, - "commonChunk": { - "type": "boolean", - "description": "Use a separate bundle containing code used across multiple bundles.", - "default": true - }, - "runtimeChunk": { - "type": "boolean", - "description": "Use a separate bundle containing the runtime.", - "default": true - }, - "sourceMap": { - "description": "Output sourcemaps. Use 'hidden' for use with error reporting tools without generating sourcemap comment.", - "default": true, - "oneOf": [ - { - "type": "boolean" - }, - { - "type": "string" - } - ] - }, - "progress": { - "type": "boolean", - "description": "Log progress to the console while building.", - "default": false - }, - "assets": { - "type": "array", - "description": "List of static application assets.", - "default": [], - "items": { - "$ref": "#/definitions/assetPattern" - } - }, - "index": { - "type": "string", - "description": "HTML File which will be contain the application.", - "x-completion-type": "file", - "x-completion-glob": "**/*@(.html|.htm)" - }, - "scripts": { - "type": "array", - "description": "External Scripts which will be included before the main application entry.", - "items": { - "$ref": "#/definitions/extraEntryPoint" - }, - "default": [] - }, - "styles": { - "type": "array", - "description": "External Styles which will be included with the application", - "items": { - "$ref": "#/definitions/extraEntryPoint" - }, - "default": [] - }, - "budgets": { - "description": "Budget thresholds to ensure parts of your application stay within boundaries which you set.", - "type": "array", - "items": { - "$ref": "#/definitions/budget" - }, - "default": [] - }, - "namedChunks": { - "type": "boolean", - "description": "Names the produced bundles according to their entry file.", - "default": true - }, - "outputHashing": { - "type": "string", - "description": "Define the output filename cache-busting hashing mode.", - "default": "none", - "enum": ["none", "all", "media", "bundles"] - }, - "stylePreprocessorOptions": { - "description": "Options to pass to style preprocessors.", - "type": "object", - "properties": { - "includePaths": { - "description": "Paths to include. Paths will be resolved to project root.", - "type": "array", - "items": { - "type": "string" - }, - "default": [] - } - }, - "additionalProperties": false - }, - "optimization": { - "description": "Enables optimization of the build output.", - "oneOf": [ - { - "type": "object", - "properties": { - "scripts": { - "type": "boolean", - "description": "Enables optimization of the scripts output.", - "default": true - }, - "styles": { - "type": "boolean", - "description": "Enables optimization of the styles output.", - "default": true - } - }, - "additionalProperties": false - }, - { - "type": "boolean" - } - ] - }, - "extractCss": { - "type": "boolean", - "description": "Extract CSS into a `.css` file.", - "default": true - }, - "subresourceIntegrity": { - "type": "boolean", - "description": "Enables the use of subresource integrity validation.", - "default": false - }, - "polyfills": { - "type": "string", - "description": "Polyfills to load before application", - "x-completion-type": "file", - "x-completion-glob": "**/*@(.js|.ts|.tsx)" - }, - "verbose": { - "type": "boolean", - "description": "Emits verbose output", - "default": false - }, - "statsJson": { - "type": "boolean", - "description": "Generates a 'stats.json' file which can be analyzed using tools such as: 'webpack-bundle-analyzer' or ``.", - "default": false - }, - "extractLicenses": { - "type": "boolean", - "description": "Extract all licenses in a separate file, in the case of production builds only.", - "default": false - }, - "memoryLimit": { - "type": "number", - "description": "Memory limit for type checking service process in `MB`.", - "default": 2048 - }, - "maxWorkers": { - "type": "number", - "description": "Number of workers to use for type checking.", - "default": 2 - }, - "fileReplacements": { - "description": "Replace files with other files in the build.", - "type": "array", - "items": { - "type": "object", - "properties": { - "replace": { - "type": "string", - "description": "The file to be replaced.", - "x-completion-type": "file" - }, - "with": { - "type": "string", - "description": "The file to replace with.", - "x-completion-type": "file" - } - }, - "additionalProperties": false, - "required": ["replace", "with"] - }, - "default": [] - }, - "buildLibsFromSource": { - "type": "boolean", - "description": "Read buildable libraries from source instead of building them separately.", - "default": true - }, - "generateIndexHtml": { - "type": "boolean", - "description": "Generates `index.html` file to the output path. This can be turned off if using a webpack plugin to generate HTML such as `html-webpack-plugin`.", - "default": true - }, - "postcssConfig": { - "type": "string", - "description": "Set a path to PostCSS config that applies to the app and all libs. Defaults to `undefined`, which auto-detects postcss.config.js files in each `app`/`lib` directory." - }, - "webpackConfig": { - "type": "string", - "description": "Path to a function which takes a webpack config, some context and returns the resulting webpack config. See https://nx.dev/guides/customize-webpack", - "x-completion-type": "file", - "x-completion-glob": "webpack?(*)@(.js|.ts)", - "x-priority": "important" - } - }, - "required": ["tsConfig", "main", "index"], - "definitions": { - "assetPattern": { - "oneOf": [ - { - "type": "object", - "properties": { - "glob": { - "type": "string", - "description": "The pattern to match." - }, - "input": { - "type": "string", - "description": "The input directory path in which to apply 'glob'. Defaults to the project root." - }, - "ignore": { - "description": "An array of globs to ignore.", - "type": "array", - "items": { - "type": "string" - } - }, - "output": { - "type": "string", - "description": "Absolute path within the output." - } - }, - "additionalProperties": false, - "required": ["glob", "input", "output"] - }, - { - "type": "string" - } - ] - }, - "budget": { - "type": "object", - "properties": { - "type": { - "type": "string", - "description": "The type of budget.", - "enum": ["all", "allScript", "any", "anyScript", "bundle", "initial"] - }, - "name": { - "type": "string", - "description": "The name of the bundle." - }, - "baseline": { - "type": "string", - "description": "The baseline size for comparison." - }, - "maximumWarning": { - "type": "string", - "description": "The maximum threshold for warning relative to the baseline." - }, - "maximumError": { - "type": "string", - "description": "The maximum threshold for error relative to the baseline." - }, - "minimumWarning": { - "type": "string", - "description": "The minimum threshold for warning relative to the baseline." - }, - "minimumError": { - "type": "string", - "description": "The minimum threshold for error relative to the baseline." - }, - "warning": { - "type": "string", - "description": "The threshold for warning relative to the baseline (min & max)." - }, - "error": { - "type": "string", - "description": "The threshold for error relative to the baseline (min & max)." - } - }, - "additionalProperties": false, - "required": ["type"] - }, - "extraEntryPoint": { - "oneOf": [ - { - "type": "object", - "properties": { - "input": { - "type": "string", - "description": "The file to include.", - "x-completion-type": "file", - "x-completion-glob": "**/*@(.css|.scss|.less|.sass|.styl|.stylus)" - }, - "bundleName": { - "type": "string", - "description": "The bundle name for this extra entry point." - }, - "inject": { - "type": "boolean", - "description": "If the bundle will be referenced in the HTML file.", - "default": true - } - }, - "additionalProperties": false, - "required": ["input"] - }, - { - "type": "string", - "description": "The file to include.", - "x-completion-type": "file", - "x-completion-glob": "**/*@(.css|.scss|.less|.sass|.styl|.stylus)" - } - ] - } - } -} diff --git a/packages/web/src/executors/webpack/webpack.impl.ts b/packages/web/src/executors/webpack/webpack.impl.ts deleted file mode 100644 index 6962a67398..0000000000 --- a/packages/web/src/executors/webpack/webpack.impl.ts +++ /dev/null @@ -1,21 +0,0 @@ -/** - * For backwards compat. - * TODO(v16): Remove in Nx 16. - */ -import { ExecutorContext, logger } from '@nx/devkit'; - -export async function* webpackExecutor(options: any, context: ExecutorContext) { - const { webpackExecutor: baseWebpackExecutor } = require('@nx/webpack'); - logger.warn( - '"@nx/web:webpack" executor is deprecated. Use "@nx/webpack:webpack" instead in your project.json.' - ); - yield* baseWebpackExecutor( - { - ...options, - target: 'web', - }, - context - ); -} - -export default webpackExecutor; diff --git a/packages/web/src/migrations/update-16-0-0-update-executors/update-16-0-0-update-executors.ts b/packages/web/src/migrations/update-16-0-0-update-executors/update-16-0-0-update-executors.ts new file mode 100644 index 0000000000..5e17cdd90b --- /dev/null +++ b/packages/web/src/migrations/update-16-0-0-update-executors/update-16-0-0-update-executors.ts @@ -0,0 +1,44 @@ +import { + formatFiles, + getProjects, + Tree, + updateProjectConfiguration, + addDependenciesToPackageJson, +} from '@nx/devkit'; +import { nxVersion } from '../../utils/versions'; + +export default async function update(host: Tree) { + const projects = getProjects(host); + const deps = {}; + + for (const [name, config] of projects.entries()) { + let updated = false; + + // webpack + if (config?.targets?.build?.executor === '@nrwl/web:webpack') { + config.targets.build.executor = '@nx/webpack:webpack'; + deps['@nx/webpack'] = nxVersion; + updated = true; + } + if (config?.targets?.serve?.executor === '@nrwl/web:dev-server') { + config.targets.serve.executor = '@nx/webpack:dev-server'; + deps['@nx/webpack'] = nxVersion; + updated = true; + } + + // rollup + if (config?.targets?.build?.executor === '@nrwl/web:rollup') { + config.targets.build.executor = '@nx/rollup:rollup'; + deps['@nx/rollup'] = nxVersion; + updated = true; + } + + if (updated) { + updateProjectConfiguration(host, name, config); + } + } + + await formatFiles(host); + + return addDependenciesToPackageJson(host, {}, deps); +}