@nx/webpack 0.0.0-pr-22179-271588f

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (146) hide show
  1. package/LICENSE +22 -0
  2. package/README.md +68 -0
  3. package/executors.json +19 -0
  4. package/generators.json +20 -0
  5. package/index.d.ts +18 -0
  6. package/index.js +24 -0
  7. package/migrations.json +60 -0
  8. package/package.json +74 -0
  9. package/plugin.d.ts +1 -0
  10. package/plugin.js +5 -0
  11. package/src/executors/dev-server/dev-server.impl.d.ts +7 -0
  12. package/src/executors/dev-server/dev-server.impl.js +79 -0
  13. package/src/executors/dev-server/lib/get-dev-server-config.d.ts +4 -0
  14. package/src/executors/dev-server/lib/get-dev-server-config.js +79 -0
  15. package/src/executors/dev-server/lib/serve-path.d.ts +3 -0
  16. package/src/executors/dev-server/lib/serve-path.js +45 -0
  17. package/src/executors/dev-server/schema.d.ts +17 -0
  18. package/src/executors/dev-server/schema.json +76 -0
  19. package/src/executors/ssr-dev-server/lib/wait-until-server-is-listening.d.ts +1 -0
  20. package/src/executors/ssr-dev-server/lib/wait-until-server-is-listening.js +39 -0
  21. package/src/executors/ssr-dev-server/schema.d.ts +11 -0
  22. package/src/executors/ssr-dev-server/schema.json +37 -0
  23. package/src/executors/ssr-dev-server/ssr-dev-server.impl.d.ts +8 -0
  24. package/src/executors/ssr-dev-server/ssr-dev-server.impl.js +39 -0
  25. package/src/executors/webpack/lib/normalize-options.d.ts +3 -0
  26. package/src/executors/webpack/lib/normalize-options.js +40 -0
  27. package/src/executors/webpack/lib/run-webpack.d.ts +3 -0
  28. package/src/executors/webpack/lib/run-webpack.js +36 -0
  29. package/src/executors/webpack/schema.d.ts +96 -0
  30. package/src/executors/webpack/schema.json +394 -0
  31. package/src/executors/webpack/webpack.impl.d.ts +13 -0
  32. package/src/executors/webpack/webpack.impl.js +125 -0
  33. package/src/generators/configuration/configuration.d.ts +5 -0
  34. package/src/generators/configuration/configuration.js +194 -0
  35. package/src/generators/configuration/schema.d.ts +14 -0
  36. package/src/generators/configuration/schema.json +77 -0
  37. package/src/generators/init/init.d.ts +5 -0
  38. package/src/generators/init/init.js +60 -0
  39. package/src/generators/init/schema.d.ts +7 -0
  40. package/src/generators/init/schema.json +33 -0
  41. package/src/migrations/update-15-0-0/add-babel-inputs.d.ts +2 -0
  42. package/src/migrations/update-15-0-0/add-babel-inputs.js +9 -0
  43. package/src/migrations/update-15-4-5/remove-es2015-polyfills-option.d.ts +2 -0
  44. package/src/migrations/update-15-4-5/remove-es2015-polyfills-option.js +20 -0
  45. package/src/migrations/update-15-6-3/webpack-config-setup.d.ts +2 -0
  46. package/src/migrations/update-15-6-3/webpack-config-setup.js +100 -0
  47. package/src/migrations/update-15-7-2/add-babelUpwardRootMode-flag.d.ts +2 -0
  48. package/src/migrations/update-15-7-2/add-babelUpwardRootMode-flag.js +17 -0
  49. package/src/migrations/update-16-0-0-add-nx-packages/update-16-0-0-add-nx-packages.d.ts +2 -0
  50. package/src/migrations/update-16-0-0-add-nx-packages/update-16-0-0-add-nx-packages.js +9 -0
  51. package/src/migrations/update-17-2-1/webpack-config-setup.d.ts +2 -0
  52. package/src/migrations/update-17-2-1/webpack-config-setup.js +31 -0
  53. package/src/plugins/generate-package-json-plugin.d.ts +14 -0
  54. package/src/plugins/generate-package-json-plugin.js +44 -0
  55. package/src/plugins/nx-typescript-webpack-plugin/nx-tsconfig-paths-webpack-plugin.d.ts +8 -0
  56. package/src/plugins/nx-typescript-webpack-plugin/nx-tsconfig-paths-webpack-plugin.js +31 -0
  57. package/src/plugins/nx-webpack-plugin/lib/apply-base-config.d.ts +5 -0
  58. package/src/plugins/nx-webpack-plugin/lib/apply-base-config.js +318 -0
  59. package/src/plugins/nx-webpack-plugin/lib/apply-web-config.d.ts +5 -0
  60. package/src/plugins/nx-webpack-plugin/lib/apply-web-config.js +372 -0
  61. package/src/plugins/nx-webpack-plugin/lib/compiler-loaders.d.ts +53 -0
  62. package/src/plugins/nx-webpack-plugin/lib/compiler-loaders.js +78 -0
  63. package/src/plugins/nx-webpack-plugin/lib/get-terser-ecma-version.d.ts +1 -0
  64. package/src/plugins/nx-webpack-plugin/lib/get-terser-ecma-version.js +35 -0
  65. package/src/plugins/nx-webpack-plugin/lib/instantiate-script-plugins.d.ts +3 -0
  66. package/src/plugins/nx-webpack-plugin/lib/instantiate-script-plugins.js +42 -0
  67. package/src/plugins/nx-webpack-plugin/lib/normalize-options.d.ts +4 -0
  68. package/src/plugins/nx-webpack-plugin/lib/normalize-options.js +143 -0
  69. package/src/plugins/nx-webpack-plugin/lib/stylesheet-loaders.d.ts +73 -0
  70. package/src/plugins/nx-webpack-plugin/lib/stylesheet-loaders.js +117 -0
  71. package/src/plugins/nx-webpack-plugin/nx-webpack-plugin-options.d.ts +216 -0
  72. package/src/plugins/nx-webpack-plugin/nx-webpack-plugin-options.js +2 -0
  73. package/src/plugins/nx-webpack-plugin/nx-webpack-plugin.d.ts +17 -0
  74. package/src/plugins/nx-webpack-plugin/nx-webpack-plugin.js +48 -0
  75. package/src/plugins/plugin.d.ts +9 -0
  76. package/src/plugins/plugin.js +131 -0
  77. package/src/plugins/stats-json-plugin.d.ts +4 -0
  78. package/src/plugins/stats-json-plugin.js +13 -0
  79. package/src/plugins/webpack-nx-build-coordination-plugin.d.ts +11 -0
  80. package/src/plugins/webpack-nx-build-coordination-plugin.js +85 -0
  81. package/src/plugins/write-index-html-plugin.d.ts +22 -0
  82. package/src/plugins/write-index-html-plugin.js +249 -0
  83. package/src/utils/config.d.ts +22 -0
  84. package/src/utils/config.js +66 -0
  85. package/src/utils/create-copy-plugin.d.ts +3 -0
  86. package/src/utils/create-copy-plugin.js +26 -0
  87. package/src/utils/ensure-dependencies.d.ts +6 -0
  88. package/src/utils/ensure-dependencies.js +28 -0
  89. package/src/utils/fs.d.ts +6 -0
  90. package/src/utils/fs.js +58 -0
  91. package/src/utils/get-client-environment.d.ts +5 -0
  92. package/src/utils/get-client-environment.js +29 -0
  93. package/src/utils/get-css-module-local-ident.d.ts +1 -0
  94. package/src/utils/get-css-module-local-ident.js +18 -0
  95. package/src/utils/has-plugin.d.ts +2 -0
  96. package/src/utils/has-plugin.js +11 -0
  97. package/src/utils/hash-format.d.ts +7 -0
  98. package/src/utils/hash-format.js +23 -0
  99. package/src/utils/models.d.ts +23 -0
  100. package/src/utils/models.js +2 -0
  101. package/src/utils/module-federation/dependencies.d.ts +6 -0
  102. package/src/utils/module-federation/dependencies.js +57 -0
  103. package/src/utils/module-federation/get-remotes-for-host.d.ts +14 -0
  104. package/src/utils/module-federation/get-remotes-for-host.js +88 -0
  105. package/src/utils/module-federation/index.d.ts +6 -0
  106. package/src/utils/module-federation/index.js +9 -0
  107. package/src/utils/module-federation/models/index.d.ts +39 -0
  108. package/src/utils/module-federation/models/index.js +2 -0
  109. package/src/utils/module-federation/package-json.d.ts +8 -0
  110. package/src/utils/module-federation/package-json.js +13 -0
  111. package/src/utils/module-federation/public-api.d.ts +6 -0
  112. package/src/utils/module-federation/public-api.js +16 -0
  113. package/src/utils/module-federation/remotes.d.ts +19 -0
  114. package/src/utils/module-federation/remotes.js +80 -0
  115. package/src/utils/module-federation/secondary-entry-points.d.ts +12 -0
  116. package/src/utils/module-federation/secondary-entry-points.js +108 -0
  117. package/src/utils/module-federation/share.d.ts +48 -0
  118. package/src/utils/module-federation/share.js +215 -0
  119. package/src/utils/module-federation/typescript.d.ts +4 -0
  120. package/src/utils/module-federation/typescript.js +54 -0
  121. package/src/utils/run-webpack.d.ts +5 -0
  122. package/src/utils/run-webpack.js +31 -0
  123. package/src/utils/versions.d.ts +8 -0
  124. package/src/utils/versions.js +12 -0
  125. package/src/utils/web-babel-loader.d.ts +0 -0
  126. package/src/utils/web-babel-loader.js +17 -0
  127. package/src/utils/webpack/deprecated-stylus-loader.d.ts +1 -0
  128. package/src/utils/webpack/deprecated-stylus-loader.js +11 -0
  129. package/src/utils/webpack/interpolate-env-variables-to-index.d.ts +1 -0
  130. package/src/utils/webpack/interpolate-env-variables-to-index.js +30 -0
  131. package/src/utils/webpack/normalize-entry.d.ts +2 -0
  132. package/src/utils/webpack/normalize-entry.js +28 -0
  133. package/src/utils/webpack/package-chunk-sort.d.ts +5 -0
  134. package/src/utils/webpack/package-chunk-sort.js +29 -0
  135. package/src/utils/webpack/plugins/postcss-cli-resources.d.ts +13 -0
  136. package/src/utils/webpack/plugins/postcss-cli-resources.js +165 -0
  137. package/src/utils/webpack/plugins/scripts-webpack-plugin.d.ts +17 -0
  138. package/src/utils/webpack/plugins/scripts-webpack-plugin.js +119 -0
  139. package/src/utils/webpack/read-webpack-options.d.ts +10 -0
  140. package/src/utils/webpack/read-webpack-options.js +41 -0
  141. package/src/utils/webpack/resolve-user-defined-webpack-config.d.ts +3 -0
  142. package/src/utils/webpack/resolve-user-defined-webpack-config.js +39 -0
  143. package/src/utils/with-nx.d.ts +8 -0
  144. package/src/utils/with-nx.js +34 -0
  145. package/src/utils/with-web.d.ts +22 -0
  146. package/src/utils/with-web.js +26 -0
package/LICENSE ADDED
@@ -0,0 +1,22 @@
1
+ (The MIT License)
2
+
3
+ Copyright (c) 2017-2023 Narwhal Technologies Inc.
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining
6
+ a copy of this software and associated documentation files (the
7
+ 'Software'), to deal in the Software without restriction, including
8
+ without limitation the rights to use, copy, modify, merge, publish,
9
+ distribute, sublicense, and/or sell copies of the Software, and to
10
+ permit persons to whom the Software is furnished to do so, subject to
11
+ the following conditions:
12
+
13
+ The above copyright notice and this permission notice shall be
14
+ included in all copies or substantial portions of the Software.
15
+
16
+ THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,
17
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
19
+ IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
20
+ CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
21
+ TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
22
+ SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,68 @@
1
+ <p style="text-align: center;">
2
+ <picture>
3
+ <source media="(prefers-color-scheme: dark)" srcset="https://raw.githubusercontent.com/nrwl/nx/master/images/nx-dark.svg">
4
+ <img alt="Nx - Smart Monorepos · Fast CI" src="https://raw.githubusercontent.com/nrwl/nx/master/images/nx-light.svg" width="100%">
5
+ </picture>
6
+ </p>
7
+
8
+ <div style="text-align: center;">
9
+
10
+ [![CircleCI](https://circleci.com/gh/nrwl/nx.svg?style=svg)](https://circleci.com/gh/nrwl/nx)
11
+ [![License](https://img.shields.io/npm/l/@nx/workspace.svg?style=flat-square)]()
12
+ [![NPM Version](https://badge.fury.io/js/%40nrwl%2Fworkspace.svg)](https://www.npmjs.com/@nx/workspace)
13
+ [![Semantic Release](https://img.shields.io/badge/%20%20%F0%9F%93%A6%F0%9F%9A%80-semantic--release-e10079.svg?style=flat-square)]()
14
+ [![Commitizen friendly](https://img.shields.io/badge/commitizen-friendly-brightgreen.svg)](http://commitizen.github.io/cz-cli/)
15
+ [![Join the chat at https://gitter.im/nrwl-nx/community](https://badges.gitter.im/nrwl-nx/community.svg)](https://gitter.im/nrwl-nx/community?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge)
16
+ [![Join us on the Official Nx Discord Server](https://img.shields.io/discord/1143497901675401286?label=discord)](https://go.nx.dev/community)
17
+
18
+ </div>
19
+
20
+
21
+ <hr>
22
+
23
+ # Nx: Smart Monorepos · Fast CI
24
+
25
+ Nx is a build system with built-in tooling and advanced CI capabilities. It helps you maintain and scale monorepos, both locally and on CI.
26
+
27
+ This package is a [Webpack plugin for Nx](https://nx.dev/packages/webpack).
28
+
29
+ ## Getting Started
30
+
31
+ ### Creating an Nx Workspace
32
+
33
+ **Using `npx`**
34
+
35
+ ```bash
36
+ npx create-nx-workspace
37
+ ```
38
+
39
+ **Using `npm init`**
40
+
41
+ ```bash
42
+ npm init nx-workspace
43
+ ```
44
+
45
+ **Using `yarn create`**
46
+
47
+ ```bash
48
+ yarn create nx-workspace
49
+ ```
50
+
51
+ ### Adding Nx to an Existing Repository
52
+
53
+ Run:
54
+
55
+ ```bash
56
+ npx nx@latest init
57
+ ```
58
+
59
+ ## Documentation & Resources
60
+
61
+ - [Nx.Dev: Documentation, Guides, Tutorials](https://nx.dev)
62
+ - [Intro to Nx](https://nx.dev/getting-started/intro)
63
+ - [Official Nx YouTube Channel](https://www.youtube.com/@NxDevtools)
64
+ - [Blog Posts About Nx](https://blog.nrwl.io/nx/home)
65
+
66
+ <p style="text-align: center;"><a href="https://nx.dev/#learning-materials" target="_blank" rel="noreferrer"><img src="https://raw.githubusercontent.com/nrwl/nx/master/images/nx-courses-and-videos.svg"
67
+ width="100%" alt="Nx - Smart Monorepos · Fast CI"></a></p>
68
+
package/executors.json ADDED
@@ -0,0 +1,19 @@
1
+ {
2
+ "executors": {
3
+ "webpack": {
4
+ "implementation": "./src/executors/webpack/webpack.impl",
5
+ "schema": "./src/executors/webpack/schema.json",
6
+ "description": "Run webpack build."
7
+ },
8
+ "dev-server": {
9
+ "implementation": "./src/executors/dev-server/dev-server.impl",
10
+ "schema": "./src/executors/dev-server/schema.json",
11
+ "description": "Serve a web application."
12
+ },
13
+ "ssr-dev-server": {
14
+ "implementation": "./src/executors/ssr-dev-server/ssr-dev-server.impl",
15
+ "schema": "./src/executors/ssr-dev-server/schema.json",
16
+ "description": "Serve a SSR application."
17
+ }
18
+ }
19
+ }
@@ -0,0 +1,20 @@
1
+ {
2
+ "name": "Nx Webpack",
3
+ "version": "0.1",
4
+ "generators": {
5
+ "init": {
6
+ "factory": "./src/generators/init/init#webpackInitGeneratorInternal",
7
+ "schema": "./src/generators/init/schema.json",
8
+ "description": "Initialize the `@nrwl/webpack` plugin.",
9
+ "aliases": ["ng-add"],
10
+ "hidden": true
11
+ },
12
+ "configuration": {
13
+ "aliases": ["webpack-project"],
14
+ "factory": "./src/generators/configuration/configuration#configurationGeneratorInternal",
15
+ "schema": "./src/generators/configuration/schema.json",
16
+ "description": "Add webpack configuration to a project.",
17
+ "hidden": true
18
+ }
19
+ }
20
+ }
package/index.d.ts ADDED
@@ -0,0 +1,18 @@
1
+ import { configurationGenerator } from './src/generators/configuration/configuration';
2
+ export { configurationGenerator };
3
+ /** @deprecated Use `configurationGenerator` instead. */
4
+ export declare const webpackProjectGenerator: typeof configurationGenerator;
5
+ export * from './src/utils/create-copy-plugin';
6
+ export * from './src/utils/config';
7
+ export { webpackInitGenerator } from './src/generators/init/init';
8
+ export type { WebDevServerOptions } from './src/executors/dev-server/schema';
9
+ export * from './src/executors/dev-server/dev-server.impl';
10
+ export * from './src/executors/webpack/lib/normalize-options';
11
+ export type { WebpackExecutorOptions, NormalizedWebpackExecutorOptions, AssetGlobPattern, FileReplacement, } from './src/executors/webpack/schema';
12
+ export * from './src/executors/webpack/webpack.impl';
13
+ export * from './src/utils/get-css-module-local-ident';
14
+ export * from './src/utils/with-nx';
15
+ export * from './src/utils/with-web';
16
+ export * from './src/utils/module-federation/public-api';
17
+ export { NxWebpackPlugin } from './src/plugins/nx-webpack-plugin/nx-webpack-plugin';
18
+ export { NxTsconfigPathsWebpackPlugin } from './src/plugins/nx-typescript-webpack-plugin/nx-tsconfig-paths-webpack-plugin';
package/index.js ADDED
@@ -0,0 +1,24 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.NxTsconfigPathsWebpackPlugin = exports.NxWebpackPlugin = exports.webpackInitGenerator = exports.webpackProjectGenerator = exports.configurationGenerator = void 0;
4
+ const tslib_1 = require("tslib");
5
+ const configuration_1 = require("./src/generators/configuration/configuration");
6
+ Object.defineProperty(exports, "configurationGenerator", { enumerable: true, get: function () { return configuration_1.configurationGenerator; } });
7
+ // Exported for backwards compatibility in case a plugin is using the old name.
8
+ /** @deprecated Use `configurationGenerator` instead. */
9
+ exports.webpackProjectGenerator = configuration_1.configurationGenerator;
10
+ tslib_1.__exportStar(require("./src/utils/create-copy-plugin"), exports);
11
+ tslib_1.__exportStar(require("./src/utils/config"), exports);
12
+ var init_1 = require("./src/generators/init/init");
13
+ Object.defineProperty(exports, "webpackInitGenerator", { enumerable: true, get: function () { return init_1.webpackInitGenerator; } });
14
+ tslib_1.__exportStar(require("./src/executors/dev-server/dev-server.impl"), exports);
15
+ tslib_1.__exportStar(require("./src/executors/webpack/lib/normalize-options"), exports);
16
+ tslib_1.__exportStar(require("./src/executors/webpack/webpack.impl"), exports);
17
+ tslib_1.__exportStar(require("./src/utils/get-css-module-local-ident"), exports);
18
+ tslib_1.__exportStar(require("./src/utils/with-nx"), exports);
19
+ tslib_1.__exportStar(require("./src/utils/with-web"), exports);
20
+ tslib_1.__exportStar(require("./src/utils/module-federation/public-api"), exports);
21
+ var nx_webpack_plugin_1 = require("./src/plugins/nx-webpack-plugin/nx-webpack-plugin");
22
+ Object.defineProperty(exports, "NxWebpackPlugin", { enumerable: true, get: function () { return nx_webpack_plugin_1.NxWebpackPlugin; } });
23
+ var nx_tsconfig_paths_webpack_plugin_1 = require("./src/plugins/nx-typescript-webpack-plugin/nx-tsconfig-paths-webpack-plugin");
24
+ Object.defineProperty(exports, "NxTsconfigPathsWebpackPlugin", { enumerable: true, get: function () { return nx_tsconfig_paths_webpack_plugin_1.NxTsconfigPathsWebpackPlugin; } });
@@ -0,0 +1,60 @@
1
+ {
2
+ "generators": {
3
+ "add-babel-inputs": {
4
+ "cli": "nx",
5
+ "version": "15.0.0-beta.0",
6
+ "description": "Adds babel.config.json to the hash of all tasks",
7
+ "factory": "./src/migrations/update-15-0-0/add-babel-inputs"
8
+ },
9
+ "remove-es2015-polyfills-option": {
10
+ "cli": "nx",
11
+ "version": "15.4.5-beta.0",
12
+ "description": "Removes es2015Polyfills option since legacy browsers are no longer supported.",
13
+ "factory": "./src/migrations/update-15-4-5/remove-es2015-polyfills-option"
14
+ },
15
+ "webpack-config-setup": {
16
+ "cli": "nx",
17
+ "version": "15.6.3-beta.0",
18
+ "description": "Creates or updates webpack.config.js file with the new options for webpack.",
19
+ "factory": "./src/migrations/update-15-6-3/webpack-config-setup"
20
+ },
21
+ "add-babelUpwardRootMode-flag": {
22
+ "cli": "nx",
23
+ "version": "15.7.2-beta.0",
24
+ "description": "Add the babelUpwardRootMode option to the build executor options.",
25
+ "factory": "./src/migrations/update-15-7-2/add-babelUpwardRootMode-flag"
26
+ },
27
+ "update-16-0-0-add-nx-packages": {
28
+ "cli": "nx",
29
+ "version": "16.0.0-beta.1",
30
+ "description": "Replace @nrwl/webpack with @nx/webpack",
31
+ "implementation": "./src/migrations/update-16-0-0-add-nx-packages/update-16-0-0-add-nx-packages"
32
+ },
33
+ "update-17-2-1-webpack-config-setup": {
34
+ "cli": "nx",
35
+ "version": "17.2.1-beta.0",
36
+ "description": "Add webpack.config.js file when webpackConfig is not defined",
37
+ "implementation": "./src/migrations/update-17-2-1/webpack-config-setup"
38
+ }
39
+ },
40
+ "packageJsonUpdates": {
41
+ "16.3.0": {
42
+ "version": "16.3.0-beta.8",
43
+ "packages": {
44
+ "@svgr/webpack": {
45
+ "version": "^8.0.1",
46
+ "alwaysAddToPackageJson": false
47
+ }
48
+ }
49
+ },
50
+ "16.4.1": {
51
+ "version": "16.4.1-beta.0",
52
+ "packages": {
53
+ "webpack": {
54
+ "version": "^5.80.0",
55
+ "alwaysAddToPackageJson": false
56
+ }
57
+ }
58
+ }
59
+ }
60
+ }
package/package.json ADDED
@@ -0,0 +1,74 @@
1
+ {
2
+ "name": "@nx/webpack",
3
+ "version": "0.0.0-pr-22179-271588f",
4
+ "private": false,
5
+ "description": "The Nx Plugin for Webpack contains executors and generators that support building applications using Webpack.",
6
+ "repository": {
7
+ "type": "git",
8
+ "url": "https://github.com/nrwl/nx.git",
9
+ "directory": "packages/webpack"
10
+ },
11
+ "keywords": [
12
+ "Monorepo",
13
+ "Webpack",
14
+ "Web",
15
+ "CLI"
16
+ ],
17
+ "main": "./index.js",
18
+ "typings": "./index.d.ts",
19
+ "author": "Victor Savkin",
20
+ "license": "MIT",
21
+ "bugs": {
22
+ "url": "https://github.com/nrwl/nx/issues"
23
+ },
24
+ "homepage": "https://nx.dev",
25
+ "generators": "./generators.json",
26
+ "executors": "./executors.json",
27
+ "ng-update": {
28
+ "requirements": {},
29
+ "migrations": "./migrations.json"
30
+ },
31
+ "dependencies": {
32
+ "@babel/core": "^7.23.2",
33
+ "ajv": "^8.12.0",
34
+ "autoprefixer": "^10.4.9",
35
+ "babel-loader": "^9.1.2",
36
+ "browserslist": "^4.21.4",
37
+ "chalk": "^4.1.0",
38
+ "copy-webpack-plugin": "^10.2.4",
39
+ "css-loader": "^6.4.0",
40
+ "css-minimizer-webpack-plugin": "^5.0.0",
41
+ "fork-ts-checker-webpack-plugin": "7.2.13",
42
+ "less": "4.1.3",
43
+ "less-loader": "11.1.0",
44
+ "license-webpack-plugin": "^4.0.2",
45
+ "loader-utils": "^2.0.3",
46
+ "mini-css-extract-plugin": "~2.4.7",
47
+ "parse5": "4.0.0",
48
+ "postcss": "^8.4.14",
49
+ "postcss-import": "~14.1.0",
50
+ "postcss-loader": "^6.1.1",
51
+ "rxjs": "^7.8.0",
52
+ "sass": "^1.42.1",
53
+ "sass-loader": "^12.2.0",
54
+ "source-map-loader": "^3.0.0",
55
+ "style-loader": "^3.3.0",
56
+ "stylus": "^0.59.0",
57
+ "stylus-loader": "^7.1.0",
58
+ "terser-webpack-plugin": "^5.3.3",
59
+ "ts-loader": "^9.3.1",
60
+ "tsconfig-paths-webpack-plugin": "4.0.0",
61
+ "tslib": "^2.3.0",
62
+ "webpack": "^5.80.0",
63
+ "webpack-dev-server": "^4.9.3",
64
+ "webpack-node-externals": "^3.0.0",
65
+ "webpack-subresource-integrity": "^5.1.0",
66
+ "@nx/devkit": "0.0.0-pr-22179-271588f",
67
+ "@nx/js": "0.0.0-pr-22179-271588f",
68
+ "@nrwl/webpack": "0.0.0-pr-22179-271588f"
69
+ },
70
+ "publishConfig": {
71
+ "access": "public"
72
+ },
73
+ "type": "commonjs"
74
+ }
package/plugin.d.ts ADDED
@@ -0,0 +1 @@
1
+ export { createNodes } from './src/plugins/plugin';
package/plugin.js ADDED
@@ -0,0 +1,5 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.createNodes = void 0;
4
+ var plugin_1 = require("./src/plugins/plugin");
5
+ Object.defineProperty(exports, "createNodes", { enumerable: true, get: function () { return plugin_1.createNodes; } });
@@ -0,0 +1,7 @@
1
+ import { ExecutorContext } from '@nx/devkit';
2
+ import { WebDevServerOptions } from './schema';
3
+ export declare function devServerExecutor(serveOptions: WebDevServerOptions, context: ExecutorContext): AsyncGenerator<{
4
+ baseUrl: string;
5
+ success: boolean;
6
+ }, any, undefined>;
7
+ export default devServerExecutor;
@@ -0,0 +1,79 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.devServerExecutor = void 0;
4
+ const webpack = require("webpack");
5
+ const devkit_1 = require("@nx/devkit");
6
+ const rxjs_for_await_1 = require("@nx/devkit/src/utils/rxjs-for-await");
7
+ const operators_1 = require("rxjs/operators");
8
+ const WebpackDevServer = require("webpack-dev-server");
9
+ const get_dev_server_config_1 = require("./lib/get-dev-server-config");
10
+ const buildable_libs_utils_1 = require("@nx/js/src/utils/buildable-libs-utils");
11
+ const run_webpack_1 = require("../../utils/run-webpack");
12
+ const resolve_user_defined_webpack_config_1 = require("../../utils/webpack/resolve-user-defined-webpack-config");
13
+ const normalize_options_1 = require("../webpack/lib/normalize-options");
14
+ const config_1 = require("../../utils/config");
15
+ const js_1 = require("@nx/js");
16
+ async function* devServerExecutor(serveOptions, context) {
17
+ // Default to dev mode so builds are faster and HMR mode works better.
18
+ process.env.NODE_ENV ??= 'development';
19
+ const { root: projectRoot, sourceRoot } = context.projectsConfigurations.projects[context.projectName];
20
+ const buildOptions = (0, normalize_options_1.normalizeOptions)(getBuildOptions(serveOptions, context), context.root, projectRoot, sourceRoot);
21
+ process.env.NX_BUILD_LIBS_FROM_SOURCE = `${buildOptions.buildLibsFromSource}`;
22
+ process.env.NX_BUILD_TARGET = serveOptions.buildTarget;
23
+ // TODO(jack): Figure out a way to port this into NxWebpackPlugin
24
+ if (!buildOptions.buildLibsFromSource) {
25
+ if (!buildOptions.tsConfig) {
26
+ throw new Error(`Cannot find "tsConfig" to remap paths for. Set this option in project.json.`);
27
+ }
28
+ const { target, dependencies } = (0, buildable_libs_utils_1.calculateProjectBuildableDependencies)(context.taskGraph, context.projectGraph, context.root, context.projectName, 'build', // should be generalized
29
+ context.configurationName);
30
+ buildOptions.tsConfig = (0, buildable_libs_utils_1.createTmpTsConfig)(buildOptions.tsConfig, context.root, target.data.root, dependencies);
31
+ process.env.NX_TSCONFIG_PATH = buildOptions.tsConfig;
32
+ }
33
+ let config;
34
+ const devServer = (0, get_dev_server_config_1.getDevServerOptions)(context.root, serveOptions, buildOptions);
35
+ if (buildOptions.webpackConfig) {
36
+ let userDefinedWebpackConfig = (0, resolve_user_defined_webpack_config_1.resolveUserDefinedWebpackConfig)(buildOptions.webpackConfig, (0, js_1.getRootTsConfigPath)());
37
+ if (typeof userDefinedWebpackConfig.then === 'function') {
38
+ userDefinedWebpackConfig = await userDefinedWebpackConfig;
39
+ }
40
+ // Only add the dev server option if user is composable plugin.
41
+ // Otherwise, user should define `devServer` option directly in their webpack config.
42
+ if (typeof userDefinedWebpackConfig === 'function' &&
43
+ ((0, config_1.isNxWebpackComposablePlugin)(userDefinedWebpackConfig) ||
44
+ !buildOptions.standardWebpackConfigFunction)) {
45
+ config = await userDefinedWebpackConfig({ devServer }, {
46
+ options: buildOptions,
47
+ context,
48
+ configuration: serveOptions.buildTarget.split(':')[2],
49
+ });
50
+ }
51
+ }
52
+ return yield* (0, rxjs_for_await_1.eachValueFrom)((0, run_webpack_1.runWebpackDevServer)(config, webpack, WebpackDevServer).pipe((0, operators_1.tap)(({ stats }) => {
53
+ console.info(stats.toString(config.stats));
54
+ }), (0, operators_1.map)(({ baseUrl, stats }) => {
55
+ return {
56
+ baseUrl,
57
+ success: !stats.hasErrors(),
58
+ };
59
+ })));
60
+ }
61
+ exports.devServerExecutor = devServerExecutor;
62
+ function getBuildOptions(options, context) {
63
+ const target = (0, devkit_1.parseTargetString)(options.buildTarget, context);
64
+ const overrides = {
65
+ watch: false,
66
+ };
67
+ if (options.memoryLimit) {
68
+ overrides.memoryLimit = options.memoryLimit;
69
+ }
70
+ if (options.baseHref) {
71
+ overrides.baseHref = options.baseHref;
72
+ }
73
+ const buildOptions = (0, devkit_1.readTargetOptions)(target, context);
74
+ return {
75
+ ...buildOptions,
76
+ ...overrides,
77
+ };
78
+ }
79
+ exports.default = devServerExecutor;
@@ -0,0 +1,4 @@
1
+ import type { Configuration as WebpackDevServerConfiguration } from 'webpack-dev-server';
2
+ import { WebDevServerOptions } from '../schema';
3
+ import { NormalizedWebpackExecutorOptions } from '../../webpack/schema';
4
+ export declare function getDevServerOptions(root: string, serveOptions: WebDevServerOptions, buildOptions: NormalizedWebpackExecutorOptions): WebpackDevServerConfiguration;
@@ -0,0 +1,79 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.getDevServerOptions = void 0;
4
+ const devkit_1 = require("@nx/devkit");
5
+ const path = require("path");
6
+ const fs_1 = require("fs");
7
+ const serve_path_1 = require("./serve-path");
8
+ function getDevServerOptions(root, serveOptions, buildOptions) {
9
+ const servePath = (0, serve_path_1.buildServePath)(buildOptions);
10
+ let scriptsOptimization;
11
+ let stylesOptimization;
12
+ if (typeof buildOptions.optimization === 'boolean') {
13
+ scriptsOptimization = stylesOptimization = buildOptions.optimization;
14
+ }
15
+ else if (buildOptions.optimization) {
16
+ scriptsOptimization = buildOptions.optimization.scripts;
17
+ stylesOptimization = buildOptions.optimization.styles;
18
+ }
19
+ else {
20
+ scriptsOptimization = stylesOptimization = false;
21
+ }
22
+ const config = {
23
+ host: serveOptions.host,
24
+ port: serveOptions.port,
25
+ headers: { 'Access-Control-Allow-Origin': '*' },
26
+ historyApiFallback: {
27
+ index: buildOptions.index &&
28
+ `${servePath}${path.basename(buildOptions.index)}`,
29
+ disableDotRule: true,
30
+ htmlAcceptHeaders: ['text/html', 'application/xhtml+xml'],
31
+ },
32
+ onListening(server) {
33
+ const isHttps = server.options.https || server.options.server?.type === 'https';
34
+ devkit_1.logger.info(`NX Web Development Server is listening at ${isHttps ? 'https' : 'http'}://${server.options.host}:${server.options.port}${(0, serve_path_1.buildServePath)(buildOptions)}`);
35
+ },
36
+ open: serveOptions.open,
37
+ static: false,
38
+ compress: scriptsOptimization || stylesOptimization,
39
+ devMiddleware: {
40
+ publicPath: servePath,
41
+ stats: false,
42
+ },
43
+ client: {
44
+ webSocketURL: serveOptions.publicHost,
45
+ overlay: {
46
+ errors: !(scriptsOptimization || stylesOptimization),
47
+ warnings: false,
48
+ },
49
+ },
50
+ liveReload: serveOptions.hmr ? false : serveOptions.liveReload, // disable liveReload if hmr is enabled
51
+ hot: serveOptions.hmr,
52
+ };
53
+ if (serveOptions.ssl) {
54
+ config.server = {
55
+ type: 'https',
56
+ };
57
+ if (serveOptions.sslKey && serveOptions.sslCert) {
58
+ config.server.options = getSslConfig(root, serveOptions);
59
+ }
60
+ }
61
+ if (serveOptions.proxyConfig) {
62
+ config.proxy = getProxyConfig(root, serveOptions);
63
+ }
64
+ if (serveOptions.allowedHosts) {
65
+ config.allowedHosts = serveOptions.allowedHosts.split(',');
66
+ }
67
+ return config;
68
+ }
69
+ exports.getDevServerOptions = getDevServerOptions;
70
+ function getSslConfig(root, options) {
71
+ return {
72
+ key: (0, fs_1.readFileSync)(path.resolve(root, options.sslKey), 'utf-8'),
73
+ cert: (0, fs_1.readFileSync)(path.resolve(root, options.sslCert), 'utf-8'),
74
+ };
75
+ }
76
+ function getProxyConfig(root, options) {
77
+ const proxyPath = path.resolve(root, options.proxyConfig);
78
+ return require(proxyPath);
79
+ }
@@ -0,0 +1,3 @@
1
+ import type { NormalizedWebpackExecutorOptions } from '../../webpack/schema';
2
+ export declare function buildServePath(browserOptions: NormalizedWebpackExecutorOptions): string;
3
+ export declare function _findDefaultServePath(baseHref?: string, deployUrl?: string): string | null;
@@ -0,0 +1,45 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports._findDefaultServePath = exports.buildServePath = void 0;
4
+ function buildServePath(browserOptions) {
5
+ let servePath = _findDefaultServePath(browserOptions.baseHref, browserOptions.deployUrl) ||
6
+ '/';
7
+ if (servePath.endsWith('/')) {
8
+ servePath = servePath.slice(0, -1);
9
+ }
10
+ if (!servePath.startsWith('/')) {
11
+ servePath = `/${servePath}`;
12
+ }
13
+ return servePath;
14
+ }
15
+ exports.buildServePath = buildServePath;
16
+ function _findDefaultServePath(baseHref, deployUrl) {
17
+ if (!baseHref && !deployUrl) {
18
+ return '';
19
+ }
20
+ if (/^(\w+:)?\/\//.test(baseHref || '') ||
21
+ /^(\w+:)?\/\//.test(deployUrl || '')) {
22
+ // If baseHref or deployUrl is absolute, unsupported by nx serve
23
+ return null;
24
+ }
25
+ // normalize baseHref
26
+ // for nx serve the starting base is always `/` so a relative
27
+ // and root relative value are identical
28
+ const baseHrefParts = (baseHref || '')
29
+ .split('/')
30
+ .filter((part) => part !== '');
31
+ if (baseHref && !baseHref.endsWith('/')) {
32
+ baseHrefParts.pop();
33
+ }
34
+ const normalizedBaseHref = baseHrefParts.length === 0 ? '/' : `/${baseHrefParts.join('/')}/`;
35
+ if (deployUrl && deployUrl[0] === '/') {
36
+ if (baseHref && baseHref[0] === '/' && normalizedBaseHref !== deployUrl) {
37
+ // If baseHref and deployUrl are root relative and not equivalent, unsupported by nx serve
38
+ return null;
39
+ }
40
+ return deployUrl;
41
+ }
42
+ // Join together baseHref and deployUrl
43
+ return `${normalizedBaseHref}${deployUrl || ''}`;
44
+ }
45
+ exports._findDefaultServePath = _findDefaultServePath;
@@ -0,0 +1,17 @@
1
+ export interface WebDevServerOptions {
2
+ host?: string;
3
+ port?: number;
4
+ publicHost?: string;
5
+ ssl?: boolean;
6
+ sslKey?: string;
7
+ sslCert?: string;
8
+ proxyConfig?: string;
9
+ buildTarget: string;
10
+ open?: boolean;
11
+ liveReload?: boolean;
12
+ hmr?: boolean;
13
+ watch?: boolean;
14
+ allowedHosts?: string;
15
+ memoryLimit?: number;
16
+ baseHref?: string;
17
+ }
@@ -0,0 +1,76 @@
1
+ {
2
+ "version": 2,
3
+ "outputCapture": "direct-nodejs",
4
+ "title": "Webpack dev server",
5
+ "description": "Serve an application using webpack.",
6
+ "cli": "nx",
7
+ "type": "object",
8
+ "properties": {
9
+ "buildTarget": {
10
+ "type": "string",
11
+ "description": "Target which builds the application.",
12
+ "x-priority": "important"
13
+ },
14
+ "port": {
15
+ "type": "number",
16
+ "description": "Port to listen on.",
17
+ "default": 4200,
18
+ "x-priority": "important"
19
+ },
20
+ "host": {
21
+ "type": "string",
22
+ "description": "Host to listen on.",
23
+ "default": "localhost"
24
+ },
25
+ "ssl": {
26
+ "type": "boolean",
27
+ "description": "Serve using `HTTPS`.",
28
+ "default": false
29
+ },
30
+ "sslKey": {
31
+ "type": "string",
32
+ "description": "SSL key to use for serving `HTTPS`."
33
+ },
34
+ "sslCert": {
35
+ "type": "string",
36
+ "description": "SSL certificate to use for serving `HTTPS`."
37
+ },
38
+ "watch": {
39
+ "type": "boolean",
40
+ "description": "Watches for changes and rebuilds application.",
41
+ "default": true
42
+ },
43
+ "liveReload": {
44
+ "type": "boolean",
45
+ "description": "Whether to reload the page on change, using live-reload.",
46
+ "default": true
47
+ },
48
+ "hmr": {
49
+ "type": "boolean",
50
+ "description": "Enable hot module replacement.",
51
+ "default": false
52
+ },
53
+ "publicHost": {
54
+ "type": "string",
55
+ "description": "Public URL where the application will be served."
56
+ },
57
+ "open": {
58
+ "type": "boolean",
59
+ "description": "Open the application in the browser.",
60
+ "default": false,
61
+ "x-priority": "important"
62
+ },
63
+ "allowedHosts": {
64
+ "type": "string",
65
+ "description": "This option allows you to whitelist services that are allowed to access the dev server."
66
+ },
67
+ "memoryLimit": {
68
+ "type": "number",
69
+ "description": "Memory limit for type checking service process in `MB`."
70
+ },
71
+ "baseHref": {
72
+ "type": "string",
73
+ "description": "Base url for the application being built."
74
+ }
75
+ }
76
+ }
@@ -0,0 +1 @@
1
+ export declare function waitUntilServerIsListening(port: number): Promise<void>;