@nx/rspack 0.0.0-pr-28218-5048fd1

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 (133) hide show
  1. package/LICENSE +22 -0
  2. package/README.md +117 -0
  3. package/executors.json +35 -0
  4. package/generators.json +31 -0
  5. package/migrations.json +98 -0
  6. package/module-federation.d.ts +1 -0
  7. package/module-federation.js +4 -0
  8. package/package.json +49 -0
  9. package/plugin.d.ts +2 -0
  10. package/plugin.js +6 -0
  11. package/src/executors/dev-server/dev-server.impl.d.ts +6 -0
  12. package/src/executors/dev-server/dev-server.impl.js +50 -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 +69 -0
  15. package/src/executors/dev-server/lib/serve-path.d.ts +3 -0
  16. package/src/executors/dev-server/lib/serve-path.js +44 -0
  17. package/src/executors/dev-server/schema.d.ts +12 -0
  18. package/src/executors/dev-server/schema.json +45 -0
  19. package/src/executors/module-federation-dev-server/module-federation-dev-server.impl.d.ts +6 -0
  20. package/src/executors/module-federation-dev-server/module-federation-dev-server.impl.js +177 -0
  21. package/src/executors/module-federation-dev-server/schema.d.ts +18 -0
  22. package/src/executors/module-federation-dev-server/schema.json +98 -0
  23. package/src/executors/module-federation-ssr-dev-server/module-federation-ssr-dev-server.impl.d.ts +21 -0
  24. package/src/executors/module-federation-ssr-dev-server/module-federation-ssr-dev-server.impl.js +214 -0
  25. package/src/executors/module-federation-ssr-dev-server/schema.json +79 -0
  26. package/src/executors/module-federation-static-server/module-federation-static-server.impl.d.ts +12 -0
  27. package/src/executors/module-federation-static-server/module-federation-static-server.impl.js +244 -0
  28. package/src/executors/module-federation-static-server/schema.d.ts +3 -0
  29. package/src/executors/module-federation-static-server/schema.json +14 -0
  30. package/src/executors/rspack/rspack.impl.d.ts +6 -0
  31. package/src/executors/rspack/rspack.impl.js +118 -0
  32. package/src/executors/rspack/schema.d.ts +34 -0
  33. package/src/executors/rspack/schema.json +177 -0
  34. package/src/executors/ssr-dev-server/lib/wait-until-server-is-listening.d.ts +1 -0
  35. package/src/executors/ssr-dev-server/lib/wait-until-server-is-listening.js +39 -0
  36. package/src/executors/ssr-dev-server/schema.d.ts +11 -0
  37. package/src/executors/ssr-dev-server/schema.json +36 -0
  38. package/src/executors/ssr-dev-server/ssr-dev-server.impl.d.ts +8 -0
  39. package/src/executors/ssr-dev-server/ssr-dev-server.impl.js +38 -0
  40. package/src/generators/application/application.d.ts +3 -0
  41. package/src/generators/application/application.js +90 -0
  42. package/src/generators/application/lib/create-ts-config.d.ts +3 -0
  43. package/src/generators/application/lib/create-ts-config.js +49 -0
  44. package/src/generators/application/lib/normalize-options.d.ts +5 -0
  45. package/src/generators/application/lib/normalize-options.js +42 -0
  46. package/src/generators/application/schema.d.ts +16 -0
  47. package/src/generators/application/schema.json +98 -0
  48. package/src/generators/configuration/configuration.d.ts +4 -0
  49. package/src/generators/configuration/configuration.js +79 -0
  50. package/src/generators/configuration/schema.d.ts +12 -0
  51. package/src/generators/configuration/schema.json +73 -0
  52. package/src/generators/init/init.d.ts +5 -0
  53. package/src/generators/init/init.js +71 -0
  54. package/src/generators/init/schema.d.ts +11 -0
  55. package/src/generators/init/schema.json +31 -0
  56. package/src/generators/preset/preset.d.ts +3 -0
  57. package/src/generators/preset/preset.js +34 -0
  58. package/src/generators/preset/schema.d.ts +18 -0
  59. package/src/generators/preset/schema.json +71 -0
  60. package/src/index.d.ts +6 -0
  61. package/src/index.js +9 -0
  62. package/src/migrations/update-16-0-0-add-nx-packages/update-16-0-0-add-nx-packages.d.ts +2 -0
  63. package/src/migrations/update-16-0-0-add-nx-packages/update-16-0-0-add-nx-packages.js +9 -0
  64. package/src/plugins/generate-package-json-plugin.d.ts +12 -0
  65. package/src/plugins/generate-package-json-plugin.js +46 -0
  66. package/src/plugins/plugin.d.ts +9 -0
  67. package/src/plugins/plugin.js +149 -0
  68. package/src/utils/config.d.ts +17 -0
  69. package/src/utils/config.js +22 -0
  70. package/src/utils/create-compiler.d.ts +7 -0
  71. package/src/utils/create-compiler.js +33 -0
  72. package/src/utils/generator-utils.d.ts +34 -0
  73. package/src/utils/generator-utils.js +444 -0
  74. package/src/utils/get-copy-patterns.d.ts +9 -0
  75. package/src/utils/get-copy-patterns.js +22 -0
  76. package/src/utils/jest-utils.d.ts +1 -0
  77. package/src/utils/jest-utils.js +8 -0
  78. package/src/utils/mode-utils.d.ts +2 -0
  79. package/src/utils/mode-utils.js +6 -0
  80. package/src/utils/model.d.ts +6 -0
  81. package/src/utils/model.js +2 -0
  82. package/src/utils/module-federation/build-static.remotes.d.ts +4 -0
  83. package/src/utils/module-federation/build-static.remotes.js +69 -0
  84. package/src/utils/module-federation/dependencies.d.ts +6 -0
  85. package/src/utils/module-federation/dependencies.js +56 -0
  86. package/src/utils/module-federation/get-remotes-for-host.d.ts +16 -0
  87. package/src/utils/module-federation/get-remotes-for-host.js +99 -0
  88. package/src/utils/module-federation/index.d.ts +6 -0
  89. package/src/utils/module-federation/index.js +9 -0
  90. package/src/utils/module-federation/models/index.d.ts +47 -0
  91. package/src/utils/module-federation/models/index.js +2 -0
  92. package/src/utils/module-federation/package-json.d.ts +8 -0
  93. package/src/utils/module-federation/package-json.js +12 -0
  94. package/src/utils/module-federation/parse-static-remotes-config.d.ts +13 -0
  95. package/src/utils/module-federation/parse-static-remotes-config.js +34 -0
  96. package/src/utils/module-federation/plugins/runtime-library-control.plugin.d.ts +3 -0
  97. package/src/utils/module-federation/plugins/runtime-library-control.plugin.js +54 -0
  98. package/src/utils/module-federation/public-api.d.ts +8 -0
  99. package/src/utils/module-federation/public-api.js +20 -0
  100. package/src/utils/module-federation/remotes.d.ts +19 -0
  101. package/src/utils/module-federation/remotes.js +77 -0
  102. package/src/utils/module-federation/secondary-entry-points.d.ts +12 -0
  103. package/src/utils/module-federation/secondary-entry-points.js +104 -0
  104. package/src/utils/module-federation/share.d.ts +48 -0
  105. package/src/utils/module-federation/share.js +235 -0
  106. package/src/utils/module-federation/start-remote-proxies.d.ts +5 -0
  107. package/src/utils/module-federation/start-remote-proxies.js +45 -0
  108. package/src/utils/module-federation/start-ssr-remote-proxies.d.ts +5 -0
  109. package/src/utils/module-federation/start-ssr-remote-proxies.js +59 -0
  110. package/src/utils/module-federation/typescript.d.ts +4 -0
  111. package/src/utils/module-federation/typescript.js +53 -0
  112. package/src/utils/module-federation/with-module-federation/package-json.d.ts +8 -0
  113. package/src/utils/module-federation/with-module-federation/package-json.js +12 -0
  114. package/src/utils/module-federation/with-module-federation/utils.d.ts +12 -0
  115. package/src/utils/module-federation/with-module-federation/utils.js +76 -0
  116. package/src/utils/module-federation/with-module-federation/with-module-federation-ssr.d.ts +3 -0
  117. package/src/utils/module-federation/with-module-federation/with-module-federation-ssr.js +55 -0
  118. package/src/utils/module-federation/with-module-federation/with-module-federation.d.ts +8 -0
  119. package/src/utils/module-federation/with-module-federation/with-module-federation.js +70 -0
  120. package/src/utils/normalize-assets.d.ts +1 -0
  121. package/src/utils/normalize-assets.js +42 -0
  122. package/src/utils/read-rspack-options.d.ts +10 -0
  123. package/src/utils/read-rspack-options.js +37 -0
  124. package/src/utils/resolve-user-defined-rspack-config.d.ts +3 -0
  125. package/src/utils/resolve-user-defined-rspack-config.js +38 -0
  126. package/src/utils/versions.d.ts +21 -0
  127. package/src/utils/versions.js +24 -0
  128. package/src/utils/with-nx.d.ts +3 -0
  129. package/src/utils/with-nx.js +187 -0
  130. package/src/utils/with-react.d.ts +3 -0
  131. package/src/utils/with-react.js +69 -0
  132. package/src/utils/with-web.d.ts +9 -0
  133. package/src/utils/with-web.js +106 -0
package/LICENSE ADDED
@@ -0,0 +1,22 @@
1
+ (The MIT License)
2
+
3
+ Copyright (c) 2017-2024 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,117 @@
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, optimized for monorepos, with plugins for popular frameworks and tools and advanced CI capabilities including caching and distribution.
26
+
27
+ This package is a [Rspack plugin for Nx](https://nx.dev/nx-api/rspack).
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://nx.dev/blog)
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
+
69
+
70
+ <p style="text-align: center;"><img src="https://raw.githubusercontent.com/nrwl/nx/master/images/nx.png" width="600" alt="Nx - Smart, Fast and Extensible Build System"></p>
71
+
72
+ <hr>
73
+
74
+ # Nx: Smart, Fast and Extensible Build System
75
+
76
+ Nx is a next generation build system with first class monorepo support and powerful integrations.
77
+
78
+ This package is a Rspack plugin for Nx.
79
+
80
+ ## Getting Started
81
+
82
+ Use `--preset=@nx/rspack` when creating new workspace.
83
+
84
+ e.g.
85
+
86
+ ```bash
87
+ npx create-nx-workspace@latest rspack-demo --preset=@nx/rspack
88
+ ```
89
+
90
+ Now, you can go into the `rspack-demo` folder and start development.
91
+
92
+ ```bash
93
+ cd rspack-demo
94
+ npm start
95
+ ```
96
+
97
+ You can also run lint, test, and e2e scripts for the project.
98
+
99
+ ```bash
100
+ npm run lint
101
+ npm run test
102
+ npm run e2e
103
+ ```
104
+
105
+ ## Existing workspaces
106
+
107
+ You can add Rspack to any existing Nx workspace.
108
+
109
+ First, install the plugin:
110
+
111
+ ```bash
112
+ npm install --save-dev @nx/rspack
113
+ ```
114
+
115
+ Then, r
116
+
117
+ **Note:** You must restart the server if you make any changes to your library.
package/executors.json ADDED
@@ -0,0 +1,35 @@
1
+ {
2
+ "$schema": "http://json-schema.org/schema",
3
+ "executors": {
4
+ "rspack": {
5
+ "implementation": "./src/executors/rspack/rspack.impl",
6
+ "schema": "./src/executors/rspack/schema.json",
7
+ "description": "Run Rspack via an executor for a project."
8
+ },
9
+ "dev-server": {
10
+ "implementation": "./src/executors/dev-server/dev-server.impl",
11
+ "schema": "./src/executors/dev-server/schema.json",
12
+ "description": "Run @rspack/dev-server to serve a project."
13
+ },
14
+ "ssr-dev-server": {
15
+ "implementation": "./src/executors/ssr-dev-server/ssr-dev-server.impl",
16
+ "schema": "./src/executors/ssr-dev-server/schema.json",
17
+ "description": "Serve a SSR application."
18
+ },
19
+ "module-federation-dev-server": {
20
+ "implementation": "./src/executors/module-federation-dev-server/module-federation-dev-server.impl",
21
+ "schema": "./src/executors/module-federation-dev-server/schema.json",
22
+ "description": "Serve a host or remote application."
23
+ },
24
+ "module-federation-ssr-dev-server": {
25
+ "implementation": "./src/executors/module-federation-ssr-dev-server/module-federation-ssr-dev-server.impl",
26
+ "schema": "./src/executors/module-federation-ssr-dev-server/schema.json",
27
+ "description": "Serve a host application along with it's known remotes."
28
+ },
29
+ "module-federation-static-server": {
30
+ "implementation": "./src/executors/module-federation-static-server/module-federation-static-server.impl",
31
+ "schema": "./src/executors/module-federation-static-server/schema.json",
32
+ "description": "Serve a host and its remotes statically."
33
+ }
34
+ }
35
+ }
@@ -0,0 +1,31 @@
1
+ {
2
+ "$schema": "http://json-schema.org/schema",
3
+ "name": "rspack",
4
+ "version": "0.0.1",
5
+ "generators": {
6
+ "configuration": {
7
+ "factory": "./src/generators/configuration/configuration",
8
+ "schema": "./src/generators/configuration/schema.json",
9
+ "description": "Rspack configuration generator."
10
+ },
11
+ "init": {
12
+ "factory": "./src/generators/init/init",
13
+ "schema": "./src/generators/init/schema.json",
14
+ "description": "Rspack init generator.",
15
+ "hidden": true
16
+ },
17
+ "preset": {
18
+ "factory": "./src/generators/preset/preset",
19
+ "schema": "./src/generators/preset/schema.json",
20
+ "description": "React preset generator.",
21
+ "hidden": true
22
+ },
23
+ "application": {
24
+ "factory": "./src/generators/application/application",
25
+ "schema": "./src/generators/application/schema.json",
26
+ "aliases": ["app"],
27
+ "x-type": "application",
28
+ "description": "React application generator."
29
+ }
30
+ }
31
+ }
@@ -0,0 +1,98 @@
1
+ {
2
+ "generators": {
3
+ "update-16-0-0-add-nx-packages": {
4
+ "cli": "nx",
5
+ "version": "16.0.0-beta.1",
6
+ "description": "Replace @nrwl/rspack with @nx/rspack",
7
+ "implementation": "./src/migrations/update-16-0-0-add-nx-packages/update-16-0-0-add-nx-packages"
8
+ }
9
+ },
10
+ "packageJsonUpdates": {
11
+ "16.1.3": {
12
+ "version": "16.1.3-beta.0",
13
+ "packages": {
14
+ "@rspack/core": {
15
+ "version": "~0.1.12",
16
+ "alwaysAddToPackageJson": false
17
+ },
18
+ "@rspack/dev-server": {
19
+ "version": "~0.1.12",
20
+ "alwaysAddToPackageJson": false
21
+ },
22
+ "@rspack/plugin-minify": {
23
+ "version": "~0.1.12",
24
+ "alwaysAddToPackageJson": false
25
+ }
26
+ }
27
+ },
28
+ "18.1.0": {
29
+ "version": "18.1.0-beta.0",
30
+ "packages": {
31
+ "@rspack/core": {
32
+ "version": "~0.5.6",
33
+ "alwaysAddToPackageJson": false
34
+ },
35
+ "@rspack/dev-server": {
36
+ "version": "~0.5.6",
37
+ "alwaysAddToPackageJson": false
38
+ },
39
+ "@rspack/plugin-minify": {
40
+ "version": "~0.5.6",
41
+ "alwaysAddToPackageJson": false
42
+ }
43
+ }
44
+ },
45
+ "18.1.3": {
46
+ "version": "18.1.3",
47
+ "packages": {
48
+ "@rspack/core": {
49
+ "version": "^0.6.1",
50
+ "alwaysAddToPackageJson": false
51
+ },
52
+ "@rspack/dev-server": {
53
+ "version": "^0.6.1",
54
+ "alwaysAddToPackageJson": false
55
+ },
56
+ "@rspack/plugin-minify": {
57
+ "version": "^0.6.1",
58
+ "alwaysAddToPackageJson": false
59
+ }
60
+ }
61
+ },
62
+ "19.3.0": {
63
+ "version": "19.3.0-beta.0",
64
+ "packages": {
65
+ "@rspack/core": {
66
+ "version": "^0.7.5",
67
+ "alwaysAddToPackageJson": false
68
+ },
69
+ "@rspack/dev-server": {
70
+ "version": "^0.7.5",
71
+ "alwaysAddToPackageJson": false
72
+ },
73
+ "@rspack/plugin-minify": {
74
+ "version": "^0.7.5",
75
+ "alwaysAddToPackageJson": false
76
+ }
77
+ }
78
+ },
79
+ "19.7.0": {
80
+ "version": "19.7.0-beta.1",
81
+ "packages": {
82
+ "@rspack/core": {
83
+ "version": "^1.0.0",
84
+ "alwaysAddToPackageJson": false
85
+ },
86
+ "@rspack/dev-server": {
87
+ "version": "^1.0.0",
88
+ "alwaysAddToPackageJson": false
89
+ },
90
+ "@rspack/plugin-react-refresh": {
91
+ "version": "^1.0.0",
92
+ "alwaysAddToPackageJson": false
93
+ }
94
+ }
95
+ }
96
+ },
97
+ "version": "0.1"
98
+ }
@@ -0,0 +1 @@
1
+ export * from './src/utils/module-federation/public-api';
@@ -0,0 +1,4 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const tslib_1 = require("tslib");
4
+ tslib_1.__exportStar(require("./src/utils/module-federation/public-api"), exports);
package/package.json ADDED
@@ -0,0 +1,49 @@
1
+ {
2
+ "name": "@nx/rspack",
3
+ "description": "The Nx Plugin for Rspack contains executors and generators that support building applications using Rspack.",
4
+ "version": "0.0.0-pr-28218-5048fd1",
5
+ "type": "commonjs",
6
+ "repository": {
7
+ "type": "git",
8
+ "url": "https://github.com/nrwl/nx.git",
9
+ "directory": "packages/rspack"
10
+ },
11
+ "bugs": {
12
+ "url": "https://github.com/nrwl/nx/issues"
13
+ },
14
+ "keywords": [
15
+ "Monorepo",
16
+ "Rspack",
17
+ "Bundling",
18
+ "Module Federation"
19
+ ],
20
+ "author": "Jack Hsu",
21
+ "license": "MIT",
22
+ "homepage": "https://nx.dev",
23
+ "main": "src/index.js",
24
+ "generators": "./generators.json",
25
+ "executors": "./executors.json",
26
+ "dependencies": {
27
+ "@nx/js": "0.0.0-pr-28218-5048fd1",
28
+ "@nx/devkit": "0.0.0-pr-28218-5048fd1",
29
+ "@nx/eslint": "0.0.0-pr-28218-5048fd1",
30
+ "@phenomnomnominal/tsquery": "~5.0.1",
31
+ "less-loader": "11.1.0",
32
+ "license-webpack-plugin": "^4.0.2",
33
+ "sass-loader": "^12.2.0",
34
+ "stylus-loader": "^7.1.0",
35
+ "postcss-loader": "^8.1.1",
36
+ "@rspack/core": "^1.0.4",
37
+ "@rspack/plugin-react-refresh": "^1.0.0",
38
+ "@rspack/plugin-minify": "^0.7.5",
39
+ "chalk": "~4.1.0"
40
+ },
41
+ "peerDependencies": {
42
+ "@module-federation/enhanced": "~0.6.0",
43
+ "@module-federation/node": "~2.5.10"
44
+ },
45
+ "nx-migrations": {
46
+ "migrations": "./migrations.json"
47
+ },
48
+ "types": "./src/index.d.ts"
49
+ }
package/plugin.d.ts ADDED
@@ -0,0 +1,2 @@
1
+ export { createDependencies, createNodesV2 } from './src/plugins/plugin';
2
+ export type { RspackPluginOptions } from './src/plugins/plugin';
package/plugin.js ADDED
@@ -0,0 +1,6 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.createNodesV2 = exports.createDependencies = void 0;
4
+ var plugin_1 = require("./src/plugins/plugin");
5
+ Object.defineProperty(exports, "createDependencies", { enumerable: true, get: function () { return plugin_1.createDependencies; } });
6
+ Object.defineProperty(exports, "createNodesV2", { enumerable: true, get: function () { return plugin_1.createNodesV2; } });
@@ -0,0 +1,6 @@
1
+ import { ExecutorContext } from '@nx/devkit';
2
+ import { DevServerExecutorSchema } from './schema';
3
+ export default function runExecutor(options: DevServerExecutorSchema, context: ExecutorContext): AsyncIterableIterator<{
4
+ success: boolean;
5
+ baseUrl?: string;
6
+ }>;
@@ -0,0 +1,50 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.default = runExecutor;
4
+ const devkit_1 = require("@nx/devkit");
5
+ const async_iterable_1 = require("@nx/devkit/src/utils/async-iterable");
6
+ const dev_server_1 = require("@rspack/dev-server");
7
+ const create_compiler_1 = require("../../utils/create-compiler");
8
+ const mode_utils_1 = require("../../utils/mode-utils");
9
+ const get_dev_server_config_1 = require("./lib/get-dev-server-config");
10
+ async function* runExecutor(options, context) {
11
+ process.env.NODE_ENV ??= options.mode ?? 'development';
12
+ if ((0, mode_utils_1.isMode)(process.env.NODE_ENV)) {
13
+ options.mode = process.env.NODE_ENV;
14
+ }
15
+ const buildTarget = (0, devkit_1.parseTargetString)(options.buildTarget, context.projectGraph);
16
+ const buildOptions = (0, devkit_1.readTargetOptions)(buildTarget, context);
17
+ let devServerConfig = (0, get_dev_server_config_1.getDevServerOptions)(context.root, options, buildOptions);
18
+ const compiler = await (0, create_compiler_1.createCompiler)({ ...buildOptions, devServer: devServerConfig, mode: options.mode }, context);
19
+ // Use the first one if it's MultiCompiler
20
+ // https://webpack.js.org/configuration/dev-server/#root:~:text=Be%20aware%20that%20when%20exporting%20multiple%20configurations%20only%20the%20devServer%20options%20for%20the%20first%20configuration%20will%20be%20taken%20into%20account%20and%20used%20for%20all%20the%20configurations%20in%20the%20array.
21
+ const firstCompiler = (0, create_compiler_1.isMultiCompiler)(compiler)
22
+ ? compiler.compilers[0]
23
+ : compiler;
24
+ devServerConfig = {
25
+ ...devServerConfig,
26
+ ...firstCompiler.options.devServer,
27
+ port: devServerConfig.port,
28
+ };
29
+ const baseUrl = `http://localhost:${options.port ?? 4200}`;
30
+ return yield* (0, async_iterable_1.createAsyncIterable)(({ next }) => {
31
+ const server = new dev_server_1.RspackDevServer({
32
+ ...devServerConfig,
33
+ onListening: () => {
34
+ next({
35
+ success: true,
36
+ baseUrl,
37
+ });
38
+ },
39
+ }, compiler);
40
+ server.compiler.hooks.done.tap('NX Rspack Dev Server', (stats) => {
41
+ if (stats.hasErrors()) {
42
+ devkit_1.logger.error(`NX Compilation failed. See above for more details.`);
43
+ }
44
+ else {
45
+ devkit_1.logger.info(`NX Server ready at ${baseUrl}`);
46
+ }
47
+ });
48
+ server.start();
49
+ });
50
+ }
@@ -0,0 +1,4 @@
1
+ import type { Configuration as RspackDevServerConfiguration } from '@rspack/dev-server';
2
+ import { RspackExecutorSchema } from '../../rspack/schema';
3
+ import { DevServerExecutorSchema } from '../schema';
4
+ export declare function getDevServerOptions(root: string, serveOptions: DevServerExecutorSchema, buildOptions: RspackExecutorSchema): RspackDevServerConfiguration;
@@ -0,0 +1,69 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.getDevServerOptions = getDevServerOptions;
4
+ const tslib_1 = require("tslib");
5
+ const devkit_1 = require("@nx/devkit");
6
+ const fs_1 = require("fs");
7
+ const path = tslib_1.__importStar(require("path"));
8
+ const serve_path_1 = require("./serve-path");
9
+ function getDevServerOptions(root, serveOptions, buildOptions) {
10
+ const servePath = (0, serve_path_1.buildServePath)(buildOptions);
11
+ let scriptsOptimization;
12
+ let stylesOptimization;
13
+ if (typeof buildOptions.optimization === 'boolean') {
14
+ scriptsOptimization = stylesOptimization = buildOptions.optimization;
15
+ }
16
+ else if (buildOptions.optimization) {
17
+ scriptsOptimization = buildOptions.optimization.scripts;
18
+ stylesOptimization = buildOptions.optimization.styles;
19
+ }
20
+ else {
21
+ scriptsOptimization = stylesOptimization = false;
22
+ }
23
+ const config = {
24
+ host: serveOptions.host,
25
+ port: serveOptions.port,
26
+ headers: { 'Access-Control-Allow-Origin': '*' },
27
+ historyApiFallback: {
28
+ index: buildOptions.index &&
29
+ `${servePath}${path.basename(buildOptions.index)}`,
30
+ disableDotRule: true,
31
+ htmlAcceptHeaders: ['text/html', 'application/xhtml+xml'],
32
+ },
33
+ onListening(server) {
34
+ const isHttps = server.options.https ||
35
+ server.options.server?.type === 'https';
36
+ 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)}`);
37
+ },
38
+ open: false,
39
+ static: false,
40
+ compress: scriptsOptimization || stylesOptimization,
41
+ devMiddleware: {
42
+ publicPath: servePath,
43
+ stats: false,
44
+ },
45
+ client: {
46
+ webSocketURL: serveOptions.publicHost,
47
+ overlay: {
48
+ errors: !(scriptsOptimization || stylesOptimization),
49
+ warnings: false,
50
+ },
51
+ },
52
+ hot: true,
53
+ };
54
+ if (serveOptions.ssl) {
55
+ config.server = {
56
+ type: 'https',
57
+ };
58
+ if (serveOptions.sslKey && serveOptions.sslCert) {
59
+ config.server.options = getSslConfig(root, serveOptions);
60
+ }
61
+ }
62
+ return config;
63
+ }
64
+ function getSslConfig(root, options) {
65
+ return {
66
+ key: (0, fs_1.readFileSync)(path.resolve(root, options.sslKey), 'utf-8'),
67
+ cert: (0, fs_1.readFileSync)(path.resolve(root, options.sslCert), 'utf-8'),
68
+ };
69
+ }
@@ -0,0 +1,3 @@
1
+ import type { RspackExecutorSchema } from '../../rspack/schema';
2
+ export declare function buildServePath(browserOptions: RspackExecutorSchema): string;
3
+ export declare function _findDefaultServePath(baseHref?: string, deployUrl?: string): string | null;
@@ -0,0 +1,44 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.buildServePath = buildServePath;
4
+ exports._findDefaultServePath = _findDefaultServePath;
5
+ function buildServePath(browserOptions) {
6
+ let servePath = _findDefaultServePath(browserOptions.baseHref, browserOptions.deployUrl) ||
7
+ '/';
8
+ if (servePath.endsWith('/')) {
9
+ servePath = servePath.slice(0, -1);
10
+ }
11
+ if (!servePath.startsWith('/')) {
12
+ servePath = `/${servePath}`;
13
+ }
14
+ return servePath;
15
+ }
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
+ }
@@ -0,0 +1,12 @@
1
+ import type { Mode } from '@rspack/core';
2
+
3
+ export interface DevServerExecutorSchema {
4
+ buildTarget: string;
5
+ mode?: Mode;
6
+ host?: string;
7
+ port?: number;
8
+ ssl?: boolean;
9
+ sslKey?: string;
10
+ sslCert?: string;
11
+ publicHost?: string;
12
+ }
@@ -0,0 +1,45 @@
1
+ {
2
+ "$schema": "http://json-schema.org/schema",
3
+ "version": 2,
4
+ "title": "Rspack dev-server executor",
5
+ "description": "Run @rspack/dev-server to serve a project.",
6
+ "type": "object",
7
+ "properties": {
8
+ "buildTarget": {
9
+ "type": "string",
10
+ "description": "The build target for rspack."
11
+ },
12
+ "port": {
13
+ "type": "number",
14
+ "description": "The port to for the dev-server to listen on."
15
+ },
16
+ "mode": {
17
+ "type": "string",
18
+ "description": "Mode to run the server in.",
19
+ "enum": ["development", "production", "none"]
20
+ },
21
+ "host": {
22
+ "type": "string",
23
+ "description": "Host to listen on.",
24
+ "default": "localhost"
25
+ },
26
+ "ssl": {
27
+ "type": "boolean",
28
+ "description": "Serve using `HTTPS`.",
29
+ "default": false
30
+ },
31
+ "sslKey": {
32
+ "type": "string",
33
+ "description": "SSL key to use for serving `HTTPS`."
34
+ },
35
+ "sslCert": {
36
+ "type": "string",
37
+ "description": "SSL certificate to use for serving `HTTPS`."
38
+ },
39
+ "publicHost": {
40
+ "type": "string",
41
+ "description": "Public URL where the application will be served."
42
+ }
43
+ },
44
+ "required": ["buildTarget"]
45
+ }
@@ -0,0 +1,6 @@
1
+ import { ExecutorContext } from '@nx/devkit';
2
+ import { ModuleFederationDevServerOptions } from './schema';
3
+ export default function moduleFederationDevServer(options: ModuleFederationDevServerOptions, context: ExecutorContext): AsyncIterableIterator<{
4
+ success: boolean;
5
+ baseUrl?: string;
6
+ }>;