feat(web): remove deprecated executors (#16416)

This commit is contained in:
Jack Hsu 2023-04-20 17:50:31 -04:00 committed by GitHub
parent a7c14fca1e
commit 8de17ab1e0
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
43 changed files with 121 additions and 1238 deletions

View File

@ -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",

View File

@ -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",

View File

@ -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",

View File

@ -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.

View File

@ -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`

View File

@ -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"

View File

@ -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",

View File

@ -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",
...

View File

@ -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',

View File

@ -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',
};
/**

View File

@ -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",

View File

@ -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',
},

View File

@ -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'],

View File

@ -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}`,

View File

@ -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(

View File

@ -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",

View File

@ -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": {

View File

@ -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": {

View File

@ -1,5 +0,0 @@
import { convertNxExecutor } from '@nx/devkit';
import { webpackExecutor } from './webpack.impl';
export default convertNxExecutor(webpackExecutor);

View File

@ -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 `<https://webpack.github.io/analyse>`.",
"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"]
}
]
}
}
}

View File

@ -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;

View File

@ -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);
}

View File

@ -136,7 +136,7 @@ export interface TargetConfiguration<T = any> {
/**
* The executor/builder used to implement the target.
*
* Example: '@nx/web:rollup'
* Example: '@nx/rollup:rollup'
*/
executor?: string;

View File

@ -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'],

View File

@ -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}`,

View File

@ -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",

View File

@ -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",

View File

@ -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": {

View File

@ -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',

View File

@ -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',

View File

@ -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",

View File

@ -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": {

View File

@ -1,5 +0,0 @@
import { convertNxExecutor } from '@nx/devkit';
import devServerExecutor from './dev-server.impl';
export default convertNxExecutor(devServerExecutor);

View File

@ -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;

View File

@ -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"]
}

View File

@ -1,5 +0,0 @@
import { convertNxExecutor } from '@nx/devkit';
import rollupExecutor from './rollup.impl';
export default convertNxExecutor(rollupExecutor);

View File

@ -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;

View File

@ -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;
}

View File

@ -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"
}
]
}
}
}

View File

@ -1,5 +0,0 @@
import { convertNxExecutor } from '@nx/devkit';
import { webpackExecutor } from './webpack.impl';
export default convertNxExecutor(webpackExecutor);

View File

@ -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 `<https://webpack.github.io/analyse>`.",
"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)"
}
]
}
}
}

View File

@ -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;

View File

@ -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);
}