@nx/vite 0.0.0-pr-22179-271588f → 0.0.0-pr-26482-ebe2dba
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.
- package/LICENSE +1 -1
- package/README.md +1 -1
- package/executors.js.map +1 -1
- package/generators.json +6 -1
- package/index.js +3 -3
- package/index.js.map +1 -1
- package/migrations.json +0 -64
- package/package.json +7 -6
- package/plugin.d.ts +1 -1
- package/plugin.js +6 -3
- package/plugin.js.map +1 -1
- package/plugins/nx-tsconfig-paths.plugin.d.ts +8 -5
- package/plugins/nx-tsconfig-paths.plugin.js +41 -4
- package/plugins/nx-tsconfig-paths.plugin.js.map +1 -1
- package/plugins/nx-vite-build-coordination.plugin.d.ts +5 -0
- package/plugins/nx-vite-build-coordination.plugin.js +64 -0
- package/plugins/nx-vite-build-coordination.plugin.js.map +1 -0
- package/plugins/rollup-replace-files.plugin.js.map +1 -1
- package/src/executors/build/build.impl.js +7 -8
- package/src/executors/build/build.impl.js.map +1 -1
- package/src/executors/build/compat.js.map +1 -1
- package/src/executors/build/schema.d.js.map +1 -1
- package/src/executors/dev-server/compat.js.map +1 -1
- package/src/executors/dev-server/dev-server.impl.js +3 -3
- package/src/executors/dev-server/dev-server.impl.js.map +1 -1
- package/src/executors/dev-server/schema.d.js.map +1 -1
- package/src/executors/preview-server/compat.js.map +1 -1
- package/src/executors/preview-server/preview-server.impl.js +4 -4
- package/src/executors/preview-server/preview-server.impl.js.map +1 -1
- package/src/executors/preview-server/schema.d.js.map +1 -1
- package/src/executors/test/compat.js.map +1 -1
- package/src/executors/test/lib/nx-reporter.js.map +1 -1
- package/src/executors/test/lib/utils.js +9 -2
- package/src/executors/test/lib/utils.js.map +1 -1
- package/src/executors/test/schema.d.js.map +1 -1
- package/src/executors/test/vitest.impl.js +6 -5
- package/src/executors/test/vitest.impl.js.map +1 -1
- package/src/generators/configuration/configuration.js +11 -11
- package/src/generators/configuration/configuration.js.map +1 -1
- package/src/generators/configuration/lib/convert-non-vite.js.map +1 -1
- package/src/generators/configuration/schema.d.js.map +1 -1
- package/src/generators/init/init.js +38 -9
- package/src/generators/init/init.js.map +1 -1
- package/src/generators/init/lib/utils.d.ts +0 -1
- package/src/generators/init/lib/utils.js +2 -27
- package/src/generators/init/lib/utils.js.map +1 -1
- package/src/generators/init/schema.d.js.map +1 -1
- package/src/generators/init/schema.d.ts +2 -0
- package/src/generators/init/schema.json +5 -0
- package/src/generators/setup-paths-plugin/lib/utils.d.ts +0 -0
- package/src/generators/setup-paths-plugin/lib/utils.js +3 -0
- package/src/generators/setup-paths-plugin/lib/utils.js.map +1 -0
- package/src/generators/setup-paths-plugin/schema.d.js +3 -0
- package/src/generators/setup-paths-plugin/schema.d.js.map +1 -0
- package/src/generators/setup-paths-plugin/schema.d.ts +9 -0
- package/src/generators/setup-paths-plugin/schema.json +14 -0
- package/src/generators/setup-paths-plugin/setup-paths-plugin.d.ts +5 -0
- package/src/generators/setup-paths-plugin/setup-paths-plugin.js +112 -0
- package/src/generators/setup-paths-plugin/setup-paths-plugin.js.map +1 -0
- package/src/generators/vitest/schema.d.js.map +1 -1
- package/src/generators/vitest/vitest-generator.js +3 -3
- package/src/generators/vitest/vitest-generator.js.map +1 -1
- package/src/migrations/update-16-0-0-add-nx-packages/update-16-0-0-add-nx-packages.js.map +1 -1
- package/src/migrations/update-16-4-1-update-test-file-config/update-16-4-1-test-file-config.js.map +1 -1
- package/src/migrations/update-16-6-0-change-ts-paths-plugin/change-ts-paths-plugin.js.map +1 -1
- package/src/migrations/update-17-1-0/move-target-defaults.js.map +1 -1
- package/src/migrations/update-17-2-0/lib/add-file-replacements.js.map +1 -1
- package/src/migrations/update-17-2-0/lib/edit-build-config.js +0 -1
- package/src/migrations/update-17-2-0/lib/edit-build-config.js.map +1 -1
- package/src/migrations/update-17-2-0/lib/edit-test-config.js +0 -1
- package/src/migrations/update-17-2-0/lib/edit-test-config.js.map +1 -1
- package/src/migrations/update-17-2-0/lib/vite-config-with-additional-js.fixture.d.ts +1 -0
- package/src/migrations/update-17-2-0/lib/vite-config-with-additional-js.fixture.js +73 -0
- package/src/migrations/update-17-2-0/lib/vite-config-with-additional-js.fixture.js.map +1 -0
- package/src/migrations/update-17-2-0/update-vite-config.js +8 -6
- package/src/migrations/update-17-2-0/update-vite-config.js.map +1 -1
- package/src/migrations/update-17-3-0/lib/fix-coverage-and-reporters.js.map +1 -1
- package/src/migrations/update-17-3-0/vitest-coverage-and-reporters.js.map +1 -1
- package/src/plugins/plugin.d.ts +5 -1
- package/src/plugins/plugin.js +72 -40
- package/src/plugins/plugin.js.map +1 -1
- package/src/utils/ensure-dependencies.js.map +1 -1
- package/src/utils/executor-utils.d.ts +4 -3
- package/src/utils/executor-utils.js +8 -5
- package/src/utils/executor-utils.js.map +1 -1
- package/src/utils/find-vite-config.js.map +1 -1
- package/src/utils/generator-utils.js +31 -24
- package/src/utils/generator-utils.js.map +1 -1
- package/src/utils/options-utils.js +8 -8
- package/src/utils/options-utils.js.map +1 -1
- package/src/utils/test-files/test-vite-configs.js +21 -21
- package/src/utils/test-files/test-vite-configs.js.map +1 -1
- package/src/utils/test-utils.js +12 -12
- package/src/utils/test-utils.js.map +1 -1
- package/src/utils/versions.d.ts +2 -2
- package/src/utils/versions.js +21 -21
- package/src/utils/versions.js.map +1 -1
- package/src/utils/vite-config-edit-utils.js.map +1 -1
- package/src/migrations/update-15-3-1/update-vite-tsconfig-paths.d.ts +0 -3
- package/src/migrations/update-15-3-1/update-vite-tsconfig-paths.js +0 -67
- package/src/migrations/update-15-3-1/update-vite-tsconfig-paths.js.map +0 -1
- package/src/migrations/update-15-3-4/set-mode-in-configuration.d.ts +0 -3
- package/src/migrations/update-15-3-4/set-mode-in-configuration.js +0 -37
- package/src/migrations/update-15-3-4/set-mode-in-configuration.js.map +0 -1
- package/src/migrations/update-15-4-3/update-report-directory.d.ts +0 -3
- package/src/migrations/update-15-4-3/update-report-directory.js +0 -39
- package/src/migrations/update-15-4-3/update-report-directory.js.map +0 -1
package/LICENSE
CHANGED
package/README.md
CHANGED
|
@@ -24,7 +24,7 @@
|
|
|
24
24
|
|
|
25
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
26
|
|
|
27
|
-
This package is a [Vite plugin for Nx](https://nx.dev/
|
|
27
|
+
This package is a [Vite plugin for Nx](https://nx.dev/nx-api/vite).
|
|
28
28
|
|
|
29
29
|
## Getting Started
|
|
30
30
|
|
package/executors.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../packages/vite/executors.ts"],"sourcesContent":["export { type ViteBuildExecutorOptions } from './src/executors/build/schema';\nexport { viteBuildExecutor } from './src/executors/build/build.impl';\nexport { type ViteDevServerExecutorOptions } from './src/executors/dev-server/schema';\nexport { viteDevServerExecutor } from './src/executors/dev-server/dev-server.impl';\nexport { type VitePreviewServerExecutorOptions } from './src/executors/preview-server/schema';\nexport { vitePreviewServerExecutor } from './src/executors/preview-server/preview-server.impl';\nexport { type VitestExecutorOptions } from './src/executors/test/schema';\nexport { vitestExecutor } from './src/executors/test/vitest.impl';\n"],"names":["viteBuildExecutor","viteDevServerExecutor","vitePreviewServerExecutor","vitestExecutor"],"mappings":";;;;;;;;IACSA,iBAAiB;eAAjBA,4BAAiB;;IAEjBC,qBAAqB;eAArBA,oCAAqB;;IAErBC,yBAAyB;eAAzBA,4CAAyB;;IAEzBC,cAAc;eAAdA,0BAAc;;;2BANW;+BAEI;mCAEI;4BAEX"}
|
|
1
|
+
{"version":3,"sources":["../../../packages/vite/executors.ts"],"sourcesContent":["export { type ViteBuildExecutorOptions } from './src/executors/build/schema';\nexport { viteBuildExecutor } from './src/executors/build/build.impl';\nexport { type ViteDevServerExecutorOptions } from './src/executors/dev-server/schema';\nexport { viteDevServerExecutor } from './src/executors/dev-server/dev-server.impl';\nexport { type VitePreviewServerExecutorOptions } from './src/executors/preview-server/schema';\nexport { vitePreviewServerExecutor } from './src/executors/preview-server/preview-server.impl';\nexport { type VitestExecutorOptions } from './src/executors/test/schema';\nexport { vitestExecutor } from './src/executors/test/vitest.impl';\n"],"names":["viteBuildExecutor","viteDevServerExecutor","vitePreviewServerExecutor","vitestExecutor"],"rangeMappings":";;;;;;;;;;;;;;;;;;;;;;;;","mappings":";;;;;;;;IACSA,iBAAiB;eAAjBA,4BAAiB;;IAEjBC,qBAAqB;eAArBA,oCAAqB;;IAErBC,yBAAyB;eAAzBA,4CAAyB;;IAEzBC,cAAc;eAAdA,0BAAc;;;2BANW;+BAEI;mCAEI;4BAEX"}
|
package/generators.json
CHANGED
|
@@ -16,10 +16,15 @@
|
|
|
16
16
|
"aliases": ["config"],
|
|
17
17
|
"hidden": false
|
|
18
18
|
},
|
|
19
|
+
"setup-paths-plugin": {
|
|
20
|
+
"factory": "./src/generators/setup-paths-plugin/setup-paths-plugin",
|
|
21
|
+
"schema": "./src/generators/setup-paths-plugin/schema.json",
|
|
22
|
+
"description": "Sets up the nxViteTsPaths plugin to enable support for workspace libraries."
|
|
23
|
+
},
|
|
19
24
|
"vitest": {
|
|
20
25
|
"factory": "./src/generators/vitest/vitest-generator#vitestGeneratorInternal",
|
|
21
26
|
"schema": "./src/generators/vitest/schema.json",
|
|
22
|
-
"description": "Generate a vitest configuration"
|
|
27
|
+
"description": "Generate a vitest configuration."
|
|
23
28
|
}
|
|
24
29
|
}
|
|
25
30
|
}
|
package/index.js
CHANGED
|
@@ -6,14 +6,14 @@ function _export(target, all) {
|
|
|
6
6
|
});
|
|
7
7
|
}
|
|
8
8
|
_export(exports, {
|
|
9
|
+
initGenerator: function() {
|
|
10
|
+
return _init.initGenerator;
|
|
11
|
+
},
|
|
9
12
|
viteConfigurationGenerator: function() {
|
|
10
13
|
return _configuration.viteConfigurationGenerator;
|
|
11
14
|
},
|
|
12
15
|
vitestGenerator: function() {
|
|
13
16
|
return _vitestgenerator.vitestGenerator;
|
|
14
|
-
},
|
|
15
|
-
initGenerator: function() {
|
|
16
|
-
return _init.initGenerator;
|
|
17
17
|
}
|
|
18
18
|
});
|
|
19
19
|
const _export_star = require("@swc/helpers/_/_export_star");
|
package/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../packages/vite/index.ts"],"sourcesContent":["export * from './src/utils/versions';\nexport * from './src/utils/generator-utils';\nexport { type ViteConfigurationGeneratorSchema } from './src/generators/configuration/schema';\nexport { viteConfigurationGenerator } from './src/generators/configuration/configuration';\nexport { type VitestGeneratorSchema } from './src/generators/vitest/schema';\nexport { vitestGenerator } from './src/generators/vitest/vitest-generator';\nexport { type InitGeneratorSchema } from './src/generators/init/schema';\nexport { initGenerator } from './src/generators/init/init';\n"],"names":["viteConfigurationGenerator","vitestGenerator","
|
|
1
|
+
{"version":3,"sources":["../../../packages/vite/index.ts"],"sourcesContent":["export * from './src/utils/versions';\nexport * from './src/utils/generator-utils';\nexport { type ViteConfigurationGeneratorSchema } from './src/generators/configuration/schema';\nexport { viteConfigurationGenerator } from './src/generators/configuration/configuration';\nexport { type VitestGeneratorSchema } from './src/generators/vitest/schema';\nexport { vitestGenerator } from './src/generators/vitest/vitest-generator';\nexport { type InitGeneratorSchema } from './src/generators/init/schema';\nexport { initGenerator } from './src/generators/init/init';\n"],"names":["initGenerator","viteConfigurationGenerator","vitestGenerator"],"rangeMappings":";;;;;;;;;;;;;;;;;;;;;;;","mappings":";;;;;;;;IAOSA,aAAa;eAAbA,mBAAa;;IAJbC,0BAA0B;eAA1BA,yCAA0B;;IAE1BC,eAAe;eAAfA,gCAAe;;;;uBALV;uBACA;+BAE6B;iCAEX;sBAEF"}
|
package/migrations.json
CHANGED
|
@@ -1,23 +1,5 @@
|
|
|
1
1
|
{
|
|
2
2
|
"generators": {
|
|
3
|
-
"update-vite-tsconfig-paths": {
|
|
4
|
-
"cli": "nx",
|
|
5
|
-
"version": "15.3.1-beta.0",
|
|
6
|
-
"description": "Remove projects property from vite-tsconfig-paths plugin in vite.config.ts files.",
|
|
7
|
-
"factory": "./src/migrations/update-15-3-1/update-vite-tsconfig-paths"
|
|
8
|
-
},
|
|
9
|
-
"set-mode-in-configurations": {
|
|
10
|
-
"cli": "nx",
|
|
11
|
-
"version": "15.3.4-beta.0",
|
|
12
|
-
"description": "Set the mode in configurations to match the configurationName.",
|
|
13
|
-
"factory": "./src/migrations/update-15-3-4/set-mode-in-configuration"
|
|
14
|
-
},
|
|
15
|
-
"update-test-path-placeholder-vars": {
|
|
16
|
-
"cli": "nx",
|
|
17
|
-
"version": "15.4.3-beta.0",
|
|
18
|
-
"description": "Update @nrwl/vite:test reportsDirectory and outputs properties to point to correct paths.",
|
|
19
|
-
"factory": "./src/migrations/update-15-4-3/update-report-directory"
|
|
20
|
-
},
|
|
21
3
|
"update-16-0-0-add-nx-packages": {
|
|
22
4
|
"cli": "nx",
|
|
23
5
|
"version": "16.0.0-beta.1",
|
|
@@ -202,52 +184,6 @@
|
|
|
202
184
|
"alwaysAddToPackageJson": false
|
|
203
185
|
}
|
|
204
186
|
}
|
|
205
|
-
},
|
|
206
|
-
"15.3.1-beta.0": {
|
|
207
|
-
"version": "15.3.1-beta.0",
|
|
208
|
-
"packages": {
|
|
209
|
-
"vite-tsconfig-paths": {
|
|
210
|
-
"version": "4.0.0",
|
|
211
|
-
"alwaysAddToPackageJson": false
|
|
212
|
-
}
|
|
213
|
-
}
|
|
214
|
-
},
|
|
215
|
-
"15.3.4-beta.0": {
|
|
216
|
-
"version": "15.3.4-beta.0",
|
|
217
|
-
"packages": {
|
|
218
|
-
"vite": {
|
|
219
|
-
"version": "^4.0.1",
|
|
220
|
-
"alwaysAddToPackageJson": false
|
|
221
|
-
},
|
|
222
|
-
"vite-tsconfig-paths": {
|
|
223
|
-
"version": "^4.0.2",
|
|
224
|
-
"alwaysAddToPackageJson": false
|
|
225
|
-
},
|
|
226
|
-
"vitest": {
|
|
227
|
-
"version": "^0.25.8",
|
|
228
|
-
"alwaysAddToPackageJson": false
|
|
229
|
-
},
|
|
230
|
-
"vite-plugin-dts": {
|
|
231
|
-
"version": "~1.7.1",
|
|
232
|
-
"alwaysAddToPackageJson": false
|
|
233
|
-
},
|
|
234
|
-
"@vitejs/plugin-react": {
|
|
235
|
-
"version": "^3.0.0",
|
|
236
|
-
"alwaysAddToPackageJson": false
|
|
237
|
-
},
|
|
238
|
-
"@vitest/coverage-c8": {
|
|
239
|
-
"version": "^0.25.8",
|
|
240
|
-
"alwaysAddToPackageJson": false
|
|
241
|
-
},
|
|
242
|
-
"@vitest/ui": {
|
|
243
|
-
"version": "^0.25.8",
|
|
244
|
-
"alwaysAddToPackageJson": false
|
|
245
|
-
},
|
|
246
|
-
"@vitest/coverage-istanbul": {
|
|
247
|
-
"version": "^0.25.8",
|
|
248
|
-
"alwaysAddToPackageJson": false
|
|
249
|
-
}
|
|
250
|
-
}
|
|
251
187
|
}
|
|
252
188
|
}
|
|
253
189
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@nx/vite",
|
|
3
|
-
"version": "0.0.0-pr-
|
|
3
|
+
"version": "0.0.0-pr-26482-ebe2dba",
|
|
4
4
|
"private": false,
|
|
5
5
|
"description": "The Nx Plugin for building and testing applications using Vite",
|
|
6
6
|
"repository": {
|
|
@@ -12,9 +12,10 @@
|
|
|
12
12
|
"Monorepo",
|
|
13
13
|
"Vite",
|
|
14
14
|
"Web",
|
|
15
|
-
"CLI"
|
|
15
|
+
"CLI",
|
|
16
|
+
"Front-end"
|
|
16
17
|
],
|
|
17
|
-
"main": "./index
|
|
18
|
+
"main": "./index",
|
|
18
19
|
"typings": "./index.d.ts",
|
|
19
20
|
"author": "Victor Savkin",
|
|
20
21
|
"license": "MIT",
|
|
@@ -29,13 +30,13 @@
|
|
|
29
30
|
"migrations": "./migrations.json"
|
|
30
31
|
},
|
|
31
32
|
"dependencies": {
|
|
32
|
-
"@nx/devkit": "0.0.0-pr-
|
|
33
|
+
"@nx/devkit": "0.0.0-pr-26482-ebe2dba",
|
|
33
34
|
"@phenomnomnominal/tsquery": "~5.0.1",
|
|
34
35
|
"@swc/helpers": "~0.5.0",
|
|
35
36
|
"enquirer": "~2.3.6",
|
|
36
|
-
"@nx/js": "0.0.0-pr-
|
|
37
|
+
"@nx/js": "0.0.0-pr-26482-ebe2dba",
|
|
37
38
|
"tsconfig-paths": "^4.1.2",
|
|
38
|
-
"@nrwl/vite": "0.0.0-pr-
|
|
39
|
+
"@nrwl/vite": "0.0.0-pr-26482-ebe2dba"
|
|
39
40
|
},
|
|
40
41
|
"peerDependencies": {
|
|
41
42
|
"vite": "^5.0.0",
|
package/plugin.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export { createNodes, VitePluginOptions, createDependencies, } from './src/plugins/plugin';
|
|
1
|
+
export { createNodes, createNodesV2, VitePluginOptions, createDependencies, } from './src/plugins/plugin';
|
package/plugin.js
CHANGED
|
@@ -6,14 +6,17 @@ function _export(target, all) {
|
|
|
6
6
|
});
|
|
7
7
|
}
|
|
8
8
|
_export(exports, {
|
|
9
|
-
createNodes: function() {
|
|
10
|
-
return _plugin.createNodes;
|
|
11
|
-
},
|
|
12
9
|
VitePluginOptions: function() {
|
|
13
10
|
return _plugin.VitePluginOptions;
|
|
14
11
|
},
|
|
15
12
|
createDependencies: function() {
|
|
16
13
|
return _plugin.createDependencies;
|
|
14
|
+
},
|
|
15
|
+
createNodes: function() {
|
|
16
|
+
return _plugin.createNodes;
|
|
17
|
+
},
|
|
18
|
+
createNodesV2: function() {
|
|
19
|
+
return _plugin.createNodesV2;
|
|
17
20
|
}
|
|
18
21
|
});
|
|
19
22
|
const _plugin = require("./src/plugins/plugin");
|
package/plugin.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../packages/vite/plugin.ts"],"sourcesContent":["export {\n createNodes,\n VitePluginOptions,\n createDependencies,\n} from './src/plugins/plugin';\n"],"names":["
|
|
1
|
+
{"version":3,"sources":["../../../packages/vite/plugin.ts"],"sourcesContent":["export {\n createNodes,\n createNodesV2,\n VitePluginOptions,\n createDependencies,\n} from './src/plugins/plugin';\n"],"names":["VitePluginOptions","createDependencies","createNodes","createNodesV2"],"rangeMappings":";;;;;;;;;;;;;;;;;;;;;","mappings":";;;;;;;;IAGEA,iBAAiB;eAAjBA,yBAAiB;;IACjBC,kBAAkB;eAAlBA,0BAAkB;;IAHlBC,WAAW;eAAXA,mBAAW;;IACXC,aAAa;eAAbA,qBAAa;;;wBAGR"}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { Plugin } from 'vite';
|
|
1
2
|
export interface nxViteTsPathsOptions {
|
|
2
3
|
/**
|
|
3
4
|
* Enable debug logging
|
|
@@ -16,9 +17,11 @@ export interface nxViteTsPathsOptions {
|
|
|
16
17
|
* @default ['.ts', '.tsx', '.js', '.jsx', '.json', '.mjs', '.cjs']
|
|
17
18
|
**/
|
|
18
19
|
extensions?: string[];
|
|
20
|
+
/**
|
|
21
|
+
* Inform Nx whether to use the raw source or to use the built output for buildable dependencies.
|
|
22
|
+
* Set to `false` to use incremental builds.
|
|
23
|
+
* @default true
|
|
24
|
+
*/
|
|
25
|
+
buildLibsFromSource?: boolean;
|
|
19
26
|
}
|
|
20
|
-
export declare function nxViteTsPaths(options?: nxViteTsPathsOptions):
|
|
21
|
-
name: string;
|
|
22
|
-
configResolved(config: any): void;
|
|
23
|
-
resolveId(importPath: string): string;
|
|
24
|
-
};
|
|
27
|
+
export declare function nxViteTsPaths(options?: nxViteTsPathsOptions): Plugin<any>;
|
|
@@ -9,8 +9,10 @@ const _devkit = require("@nx/devkit");
|
|
|
9
9
|
const _nodefs = require("node:fs");
|
|
10
10
|
const _nodepath = require("node:path");
|
|
11
11
|
const _tsconfigpaths = require("tsconfig-paths");
|
|
12
|
+
const _buildablelibsutils = require("@nx/js/src/utils/buildable-libs-utils");
|
|
13
|
+
const _nxvitebuildcoordinationplugin = require("./nx-vite-build-coordination.plugin");
|
|
12
14
|
function nxViteTsPaths(options = {}) {
|
|
13
|
-
var _options, _options1;
|
|
15
|
+
var _options, _options1, _options2;
|
|
14
16
|
let matchTsPathEsm;
|
|
15
17
|
let matchTsPathFallback;
|
|
16
18
|
let tsConfigPathsEsm;
|
|
@@ -35,16 +37,39 @@ function nxViteTsPaths(options = {}) {
|
|
|
35
37
|
'module',
|
|
36
38
|
'main'
|
|
37
39
|
];
|
|
40
|
+
var _buildLibsFromSource;
|
|
41
|
+
(_buildLibsFromSource = (_options2 = options).buildLibsFromSource) != null ? _buildLibsFromSource : _options2.buildLibsFromSource = true;
|
|
42
|
+
let projectRoot = '';
|
|
38
43
|
return {
|
|
39
44
|
name: 'nx-vite-ts-paths',
|
|
40
|
-
configResolved (config) {
|
|
41
|
-
|
|
45
|
+
async configResolved (config) {
|
|
46
|
+
projectRoot = config.root;
|
|
42
47
|
const projectRootFromWorkspaceRoot = (0, _nodepath.relative)(_devkit.workspaceRoot, projectRoot);
|
|
43
|
-
|
|
48
|
+
var _process_env_NX_TASK_TARGET_TARGET;
|
|
49
|
+
let foundTsConfigPath = getTsConfig((0, _nodepath.join)(_devkit.workspaceRoot, 'tmp', projectRootFromWorkspaceRoot, (_process_env_NX_TASK_TARGET_TARGET = process.env.NX_TASK_TARGET_TARGET) != null ? _process_env_NX_TASK_TARGET_TARGET : 'build', 'tsconfig.generated.json'));
|
|
44
50
|
if (!foundTsConfigPath) {
|
|
45
51
|
throw new Error((0, _devkit.stripIndents)`Unable to find a tsconfig in the workspace!
|
|
46
52
|
There should at least be a tsconfig.base.json or tsconfig.json in the root of the workspace ${_devkit.workspaceRoot}`);
|
|
47
53
|
}
|
|
54
|
+
if (!options.buildLibsFromSource && !global.NX_GRAPH_CREATION) {
|
|
55
|
+
const projectGraph = await (0, _devkit.createProjectGraphAsync)({
|
|
56
|
+
exitOnError: false,
|
|
57
|
+
resetDaemonClient: true
|
|
58
|
+
});
|
|
59
|
+
const { dependencies } = (0, _buildablelibsutils.calculateProjectBuildableDependencies)(undefined, projectGraph, _devkit.workspaceRoot, process.env.NX_TASK_TARGET_PROJECT, // When using incremental building and the serve target is called
|
|
60
|
+
// we need to get the deps for the 'build' target instead.
|
|
61
|
+
process.env.NX_TASK_TARGET_TARGET === 'serve' ? 'build' : process.env.NX_TASK_TARGET_TARGET, process.env.NX_TASK_TARGET_CONFIGURATION);
|
|
62
|
+
// This tsconfig is used via the Vite ts paths plugin.
|
|
63
|
+
// It can be also used by other user-defined Vite plugins (e.g. for creating type declaration files).
|
|
64
|
+
foundTsConfigPath = (0, _buildablelibsutils.createTmpTsConfig)(foundTsConfigPath, _devkit.workspaceRoot, (0, _nodepath.relative)(_devkit.workspaceRoot, projectRoot), dependencies);
|
|
65
|
+
if (config.command === 'serve') {
|
|
66
|
+
const buildableLibraryDependencies = dependencies.filter((dep)=>dep.node.type === 'lib').map((dep)=>dep.node.name).join(',');
|
|
67
|
+
const buildCommand = `npx nx run-many --target=${process.env.NX_TASK_TARGET_TARGET} --projects=${buildableLibraryDependencies}`;
|
|
68
|
+
config.plugins.push((0, _nxvitebuildcoordinationplugin.nxViteBuildCoordinationPlugin)({
|
|
69
|
+
buildCommand
|
|
70
|
+
}));
|
|
71
|
+
}
|
|
72
|
+
}
|
|
48
73
|
const parsed = (0, _tsconfigpaths.loadConfig)(foundTsConfigPath);
|
|
49
74
|
logIt('first parsed tsconfig: ', parsed);
|
|
50
75
|
if (parsed.resultType === 'failed') {
|
|
@@ -83,6 +108,18 @@ There should at least be a tsconfig.base.json or tsconfig.json in the root of th
|
|
|
83
108
|
// Returning null defers to other resolveId functions and eventually the default resolution behavior
|
|
84
109
|
// https://rollupjs.org/plugin-development/#resolveid
|
|
85
110
|
return resolvedFile || null;
|
|
111
|
+
},
|
|
112
|
+
async writeBundle (options) {
|
|
113
|
+
const outDir = options.dir || 'dist';
|
|
114
|
+
const src = (0, _nodepath.resolve)(projectRoot, 'package.json');
|
|
115
|
+
if ((0, _nodefs.existsSync)(src)) {
|
|
116
|
+
const dest = (0, _nodepath.join)(outDir, 'package.json');
|
|
117
|
+
try {
|
|
118
|
+
(0, _nodefs.copyFileSync)(src, dest);
|
|
119
|
+
} catch (err) {
|
|
120
|
+
console.error('Error copying package.json:', err);
|
|
121
|
+
}
|
|
122
|
+
}
|
|
86
123
|
}
|
|
87
124
|
};
|
|
88
125
|
function getTsConfig(preferredTsConfigPath) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../packages/vite/plugins/nx-tsconfig-paths.plugin.ts"],"sourcesContent":["import { joinPathFragments, stripIndents, workspaceRoot } from '@nx/devkit';\nimport { existsSync } from 'node:fs';\nimport { relative, join, resolve } from 'node:path';\nimport {\n loadConfig,\n createMatchPath,\n MatchPath,\n ConfigLoaderSuccessResult,\n} from 'tsconfig-paths';\n\nexport interface nxViteTsPathsOptions {\n /**\n * Enable debug logging\n * @default false\n **/\n debug?: boolean;\n /**\n * export fields in package.json to use for resolving\n * @default [['exports', '.', 'import'], 'module', 'main']\n *\n * fallback resolution will use ['main', 'module']\n **/\n mainFields?: (string | string[])[];\n /**\n * extensions to check when resolving files when package.json resolution fails\n * @default ['.ts', '.tsx', '.js', '.jsx', '.json', '.mjs', '.cjs']\n **/\n extensions?: string[];\n}\n\nexport function nxViteTsPaths(options: nxViteTsPathsOptions = {}) {\n let matchTsPathEsm: MatchPath;\n let matchTsPathFallback: MatchPath | undefined;\n let tsConfigPathsEsm: ConfigLoaderSuccessResult;\n let tsConfigPathsFallback: ConfigLoaderSuccessResult;\n\n options.extensions ??= [\n '.ts',\n '.tsx',\n '.js',\n '.jsx',\n '.json',\n '.mjs',\n '.cjs',\n ];\n options.mainFields ??= [['exports', '.', 'import'], 'module', 'main'];\n\n return {\n name: 'nx-vite-ts-paths',\n configResolved(config: any) {\n const projectRoot = config.root;\n const projectRootFromWorkspaceRoot = relative(workspaceRoot, projectRoot);\n\n const foundTsConfigPath = getTsConfig(\n join(\n workspaceRoot,\n 'tmp',\n projectRootFromWorkspaceRoot,\n 'tsconfig.generated.json'\n )\n );\n if (!foundTsConfigPath) {\n throw new Error(stripIndents`Unable to find a tsconfig in the workspace! \nThere should at least be a tsconfig.base.json or tsconfig.json in the root of the workspace ${workspaceRoot}`);\n }\n const parsed = loadConfig(foundTsConfigPath);\n\n logIt('first parsed tsconfig: ', parsed);\n if (parsed.resultType === 'failed') {\n throw new Error(`Failed loading tsonfig at ${foundTsConfigPath}`);\n }\n tsConfigPathsEsm = parsed;\n\n matchTsPathEsm = createMatchPath(\n parsed.absoluteBaseUrl,\n parsed.paths,\n options.mainFields\n );\n\n const rootLevelTsConfig = getTsConfig(\n join(workspaceRoot, 'tsconfig.base.json')\n );\n const rootLevelParsed = loadConfig(rootLevelTsConfig);\n logIt('fallback parsed tsconfig: ', rootLevelParsed);\n if (rootLevelParsed.resultType === 'success') {\n tsConfigPathsFallback = rootLevelParsed;\n matchTsPathFallback = createMatchPath(\n rootLevelParsed.absoluteBaseUrl,\n rootLevelParsed.paths,\n ['main', 'module']\n );\n }\n },\n resolveId(importPath: string) {\n let resolvedFile: string;\n try {\n resolvedFile = matchTsPathEsm(importPath);\n } catch (e) {\n logIt('Using fallback path matching.');\n resolvedFile = matchTsPathFallback?.(importPath);\n }\n\n if (!resolvedFile) {\n if (tsConfigPathsEsm || tsConfigPathsFallback) {\n logIt(\n `Unable to resolve ${importPath} with tsconfig paths. Using fallback file matching.`\n );\n resolvedFile =\n loadFileFromPaths(tsConfigPathsEsm, importPath) ||\n loadFileFromPaths(tsConfigPathsFallback, importPath);\n } else {\n logIt(`Unable to resolve ${importPath} with tsconfig paths`);\n }\n }\n\n logIt(`Resolved ${importPath} to ${resolvedFile}`);\n // Returning null defers to other resolveId functions and eventually the default resolution behavior\n // https://rollupjs.org/plugin-development/#resolveid\n return resolvedFile || null;\n },\n };\n\n function getTsConfig(preferredTsConfigPath: string): string {\n return [\n resolve(preferredTsConfigPath),\n resolve(join(workspaceRoot, 'tsconfig.base.json')),\n resolve(join(workspaceRoot, 'tsconfig.json')),\n ].find((tsPath) => {\n if (existsSync(tsPath)) {\n logIt('Found tsconfig at', tsPath);\n return tsPath;\n }\n });\n }\n\n function logIt(...msg: any[]) {\n if (process.env.NX_VERBOSE_LOGGING === 'true' || options?.debug) {\n console.debug('\\n[Nx Vite TsPaths]', ...msg);\n }\n }\n\n function loadFileFromPaths(\n tsconfig: ConfigLoaderSuccessResult,\n importPath: string\n ) {\n logIt(\n `Trying to resolve file from config in ${tsconfig.configFileAbsolutePath}`\n );\n let resolvedFile: string;\n for (const alias in tsconfig.paths) {\n const paths = tsconfig.paths[alias];\n\n const normalizedImport = alias.replace(/\\/\\*$/, '');\n\n if (importPath.startsWith(normalizedImport)) {\n const joinedPath = joinPathFragments(\n tsconfig.absoluteBaseUrl,\n paths[0].replace(/\\/\\*$/, '')\n );\n\n resolvedFile = findFile(\n importPath.replace(normalizedImport, joinedPath)\n );\n }\n }\n\n return resolvedFile;\n }\n\n function findFile(path: string): string {\n for (const ext of options.extensions) {\n const resolvedPath = resolve(path + ext);\n if (existsSync(resolvedPath)) {\n return resolvedPath;\n }\n\n const resolvedIndexPath = resolve(path, `index${ext}`);\n if (existsSync(resolvedIndexPath)) {\n return resolvedIndexPath;\n }\n }\n }\n}\n"],"names":["nxViteTsPaths","options","matchTsPathEsm","matchTsPathFallback","tsConfigPathsEsm","tsConfigPathsFallback","extensions","mainFields","name","configResolved","config","projectRoot","root","projectRootFromWorkspaceRoot","relative","workspaceRoot","foundTsConfigPath","getTsConfig","join","Error","stripIndents","parsed","loadConfig","logIt","resultType","createMatchPath","absoluteBaseUrl","paths","rootLevelTsConfig","rootLevelParsed","resolveId","importPath","resolvedFile","e","loadFileFromPaths","preferredTsConfigPath","resolve","find","tsPath","existsSync","msg","process","env","NX_VERBOSE_LOGGING","debug","console","tsconfig","configFileAbsolutePath","alias","normalizedImport","replace","startsWith","joinedPath","joinPathFragments","findFile","path","ext","resolvedPath","resolvedIndexPath"],"mappings":";+BA8BgBA;;;eAAAA;;;w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C,MAAMA,QAAQmB,SAASnB,KAAK,CAACqB,MAAM;YAEnC,MAAMC,mBAAmBD,MAAME,OAAO,CAAC,SAAS;YAEhD,IAAInB,WAAWoB,UAAU,CAACF,mBAAmB;gBAC3C,MAAMG,aAAaC,IAAAA,yBAAiB,EAClCP,SAASpB,eAAe,EACxBC,KAAK,CAAC,EAAE,CAACuB,OAAO,CAAC,SAAS;gBAG5BlB,eAAesB,SACbvB,WAAWmB,OAAO,CAACD,kBAAkBG;YAEzC;QACF;QAEA,OAAOpB;IACT;IAEA,SAASsB,SAASC,IAAY;QAC5B,KAAK,MAAMC,OAAOvD,QAAQK,UAAU,CAAE;YACpC,MAAMmD,eAAerB,IAAAA,iBAAO,EAACmB,OAAOC;YACpC,IAAIjB,IAAAA,kBAAU,EAACkB,eAAe;gBAC5B,OAAOA;YACT;YAEA,MAAMC,oBAAoBtB,IAAAA,iBAAO,EAACmB,MAAM,CAAC,KAAK,EAAEC,IAAI,CAAC;YACrD,IAAIjB,IAAAA,kBAAU,EAACmB,oBAAoB;gBACjC,OAAOA;YACT;QACF;IACF;AACF"}
|
|
1
|
+
{"version":3,"sources":["../../../../packages/vite/plugins/nx-tsconfig-paths.plugin.ts"],"sourcesContent":["import {\n createProjectGraphAsync,\n joinPathFragments,\n stripIndents,\n workspaceRoot,\n} from '@nx/devkit';\nimport { copyFileSync, existsSync } from 'node:fs';\nimport { relative, join, resolve } from 'node:path';\nimport {\n loadConfig,\n createMatchPath,\n MatchPath,\n ConfigLoaderSuccessResult,\n} from 'tsconfig-paths';\nimport {\n calculateProjectBuildableDependencies,\n createTmpTsConfig,\n} from '@nx/js/src/utils/buildable-libs-utils';\nimport { Plugin } from 'vite';\nimport { nxViteBuildCoordinationPlugin } from './nx-vite-build-coordination.plugin';\n\nexport interface nxViteTsPathsOptions {\n /**\n * Enable debug logging\n * @default false\n **/\n debug?: boolean;\n /**\n * export fields in package.json to use for resolving\n * @default [['exports', '.', 'import'], 'module', 'main']\n *\n * fallback resolution will use ['main', 'module']\n **/\n mainFields?: (string | string[])[];\n /**\n * extensions to check when resolving files when package.json resolution fails\n * @default ['.ts', '.tsx', '.js', '.jsx', '.json', '.mjs', '.cjs']\n **/\n extensions?: string[];\n /**\n * Inform Nx whether to use the raw source or to use the built output for buildable dependencies.\n * Set to `false` to use incremental builds.\n * @default true\n */\n buildLibsFromSource?: boolean;\n}\n\nexport function nxViteTsPaths(options: nxViteTsPathsOptions = {}) {\n let matchTsPathEsm: MatchPath;\n let matchTsPathFallback: MatchPath | undefined;\n let tsConfigPathsEsm: ConfigLoaderSuccessResult;\n let tsConfigPathsFallback: ConfigLoaderSuccessResult;\n\n options.extensions ??= [\n '.ts',\n '.tsx',\n '.js',\n '.jsx',\n '.json',\n '.mjs',\n '.cjs',\n ];\n options.mainFields ??= [['exports', '.', 'import'], 'module', 'main'];\n options.buildLibsFromSource ??= true;\n let projectRoot = '';\n\n return {\n name: 'nx-vite-ts-paths',\n async configResolved(config: any) {\n projectRoot = config.root;\n const projectRootFromWorkspaceRoot = relative(workspaceRoot, projectRoot);\n let foundTsConfigPath = getTsConfig(\n join(\n workspaceRoot,\n 'tmp',\n projectRootFromWorkspaceRoot,\n process.env.NX_TASK_TARGET_TARGET ?? 'build',\n 'tsconfig.generated.json'\n )\n );\n if (!foundTsConfigPath) {\n throw new Error(stripIndents`Unable to find a tsconfig in the workspace! \nThere should at least be a tsconfig.base.json or tsconfig.json in the root of the workspace ${workspaceRoot}`);\n }\n\n if (!options.buildLibsFromSource && !global.NX_GRAPH_CREATION) {\n const projectGraph = await createProjectGraphAsync({\n exitOnError: false,\n resetDaemonClient: true,\n });\n const { dependencies } = calculateProjectBuildableDependencies(\n undefined,\n projectGraph,\n workspaceRoot,\n process.env.NX_TASK_TARGET_PROJECT,\n // When using incremental building and the serve target is called\n // we need to get the deps for the 'build' target instead.\n process.env.NX_TASK_TARGET_TARGET === 'serve'\n ? 'build'\n : process.env.NX_TASK_TARGET_TARGET,\n process.env.NX_TASK_TARGET_CONFIGURATION\n );\n // This tsconfig is used via the Vite ts paths plugin.\n // It can be also used by other user-defined Vite plugins (e.g. for creating type declaration files).\n foundTsConfigPath = createTmpTsConfig(\n foundTsConfigPath,\n workspaceRoot,\n relative(workspaceRoot, projectRoot),\n dependencies\n );\n\n if (config.command === 'serve') {\n const buildableLibraryDependencies = dependencies\n .filter((dep) => dep.node.type === 'lib')\n .map((dep) => dep.node.name)\n .join(',');\n const buildCommand = `npx nx run-many --target=${process.env.NX_TASK_TARGET_TARGET} --projects=${buildableLibraryDependencies}`;\n config.plugins.push(nxViteBuildCoordinationPlugin({ buildCommand }));\n }\n }\n\n const parsed = loadConfig(foundTsConfigPath);\n\n logIt('first parsed tsconfig: ', parsed);\n if (parsed.resultType === 'failed') {\n throw new Error(`Failed loading tsonfig at ${foundTsConfigPath}`);\n }\n tsConfigPathsEsm = parsed;\n\n matchTsPathEsm = createMatchPath(\n parsed.absoluteBaseUrl,\n parsed.paths,\n options.mainFields\n );\n\n const rootLevelTsConfig = getTsConfig(\n join(workspaceRoot, 'tsconfig.base.json')\n );\n const rootLevelParsed = loadConfig(rootLevelTsConfig);\n logIt('fallback parsed tsconfig: ', rootLevelParsed);\n if (rootLevelParsed.resultType === 'success') {\n tsConfigPathsFallback = rootLevelParsed;\n matchTsPathFallback = createMatchPath(\n rootLevelParsed.absoluteBaseUrl,\n rootLevelParsed.paths,\n ['main', 'module']\n );\n }\n },\n resolveId(importPath: string) {\n let resolvedFile: string;\n try {\n resolvedFile = matchTsPathEsm(importPath);\n } catch (e) {\n logIt('Using fallback path matching.');\n resolvedFile = matchTsPathFallback?.(importPath);\n }\n\n if (!resolvedFile) {\n if (tsConfigPathsEsm || tsConfigPathsFallback) {\n logIt(\n `Unable to resolve ${importPath} with tsconfig paths. Using fallback file matching.`\n );\n resolvedFile =\n loadFileFromPaths(tsConfigPathsEsm, importPath) ||\n loadFileFromPaths(tsConfigPathsFallback, importPath);\n } else {\n logIt(`Unable to resolve ${importPath} with tsconfig paths`);\n }\n }\n\n logIt(`Resolved ${importPath} to ${resolvedFile}`);\n // Returning null defers to other resolveId functions and eventually the default resolution behavior\n // https://rollupjs.org/plugin-development/#resolveid\n return resolvedFile || null;\n },\n async writeBundle(options) {\n const outDir = options.dir || 'dist';\n const src = resolve(projectRoot, 'package.json');\n if (existsSync(src)) {\n const dest = join(outDir, 'package.json');\n\n try {\n copyFileSync(src, dest);\n } catch (err) {\n console.error('Error copying package.json:', err);\n }\n }\n },\n } as Plugin;\n\n function getTsConfig(preferredTsConfigPath: string): string {\n return [\n resolve(preferredTsConfigPath),\n resolve(join(workspaceRoot, 'tsconfig.base.json')),\n resolve(join(workspaceRoot, 'tsconfig.json')),\n ].find((tsPath) => {\n if (existsSync(tsPath)) {\n logIt('Found tsconfig at', tsPath);\n return tsPath;\n }\n });\n }\n\n function logIt(...msg: any[]) {\n if (process.env.NX_VERBOSE_LOGGING === 'true' || options?.debug) {\n console.debug('\\n[Nx Vite TsPaths]', ...msg);\n }\n }\n\n function loadFileFromPaths(\n tsconfig: ConfigLoaderSuccessResult,\n importPath: string\n ) {\n logIt(\n `Trying to resolve file from config in ${tsconfig.configFileAbsolutePath}`\n );\n let resolvedFile: string;\n for (const alias in tsconfig.paths) {\n const paths = tsconfig.paths[alias];\n\n const normalizedImport = alias.replace(/\\/\\*$/, '');\n\n if (importPath.startsWith(normalizedImport)) {\n const joinedPath = joinPathFragments(\n tsconfig.absoluteBaseUrl,\n paths[0].replace(/\\/\\*$/, '')\n );\n\n resolvedFile = findFile(\n importPath.replace(normalizedImport, joinedPath)\n );\n }\n }\n\n return resolvedFile;\n }\n\n function findFile(path: string): string {\n for (const ext of options.extensions) {\n const resolvedPath = resolve(path + ext);\n if (existsSync(resolvedPath)) {\n return resolvedPath;\n }\n\n const resolvedIndexPath = resolve(path, `index${ext}`);\n if (existsSync(resolvedIndexPath)) {\n return resolvedIndexPath;\n }\n }\n }\n}\n"],"names":["nxViteTsPaths","options","matchTsPathEsm","matchTsPathFallback","tsConfigPathsEsm","tsConfigPathsFallback","extensions","mainFields","buildLibsFromSource","projectRoot","name","configResolved","config","root","projectRootFromWorkspaceRoot","relative","workspaceRoot","process","foundTsConfigPath","getTsConfig","join","env","NX_TASK_TARGET_TARGET","Error","stripIndents","global","NX_GRAPH_CREATION","projectGraph","createProjectGraphAsync","exitOnError","resetDaemonClient","dependencies","calculateProjectBuildableDependencies","undefined","NX_TASK_TARGET_PROJECT","NX_TASK_TARGET_CONFIGURATION","createTmpTsConfig","command","buildableLibraryDependencies","filter","dep","node","type","map","buildCommand","plugins","push","nxViteBuildCoordinationPlugin","parsed","loadConfig","logIt","resultType","createMatchPath","absoluteBaseUrl","paths","rootLevelTsConfig","rootLevelParsed","resolveId","importPath","resolvedFile","e","loadFileFromPaths","writeBundle","outDir","dir","src","resolve","existsSync","dest","copyFileSync","err","console","error","preferredTsConfigPath","find","tsPath","msg","NX_VERBOSE_LOGGING","debug","tsconfig","configFileAbsolutePath","alias","normalizedImport","replace","startsWith","joinedPath","joinPathFragments","findFile","path","ext","resolvedPath","resolvedIndexPath"],"rangeMappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;","mappings":";+BA+CgBA;;;eAAAA;;;wBA1CT;wBACkC;0BACD;+BAMjC;oCAIA;+CAEuC;AA4BvC,SAASA,cAAcC,UAAgC,CAAC,CAAC;QAM9DA,UASAA,WACAA;IAfA,IAAIC;IACJ,IAAIC;IACJ,IAAIC;IACJ,IAAIC;;IAEJJ,gBAAAA,WAAAA,SAAQK,oCAARL,SAAQK,aAAe;QACrB;QACA;QACA;QACA;QACA;QACA;QACA;KACD;;IACDL,gBAAAA,YAAAA,SAAQM,oCAARN,UAAQM,aAAe;QAAC;YAAC;YAAW;YAA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nC,MAAMC,mBAAmBD,MAAME,OAAO,CAAC,SAAS;YAEhD,IAAIzB,WAAW0B,UAAU,CAACF,mBAAmB;gBAC3C,MAAMG,aAAaC,IAAAA,yBAAiB,EAClCP,SAAS1B,eAAe,EACxBC,KAAK,CAAC,EAAE,CAAC6B,OAAO,CAAC,SAAS;gBAG5BxB,eAAe4B,SACb7B,WAAWyB,OAAO,CAACD,kBAAkBG;YAEzC;QACF;QAEA,OAAO1B;IACT;IAEA,SAAS4B,SAASC,IAAY;QAC5B,KAAK,MAAMC,OAAOxF,QAAQK,UAAU,CAAE;YACpC,MAAMoF,eAAexB,IAAAA,iBAAO,EAACsB,OAAOC;YACpC,IAAItB,IAAAA,kBAAU,EAACuB,eAAe;gBAC5B,OAAOA;YACT;YAEA,MAAMC,oBAAoBzB,IAAAA,iBAAO,EAACsB,MAAM,CAAC,KAAK,EAAEC,IAAI,CAAC;YACrD,IAAItB,IAAAA,kBAAU,EAACwB,oBAAoB;gBACjC,OAAOA;YACT;QACF;IACF;AACF"}
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "nxViteBuildCoordinationPlugin", {
|
|
3
|
+
enumerable: true,
|
|
4
|
+
get: function() {
|
|
5
|
+
return nxViteBuildCoordinationPlugin;
|
|
6
|
+
}
|
|
7
|
+
});
|
|
8
|
+
const _watch = require("nx/src/command-line/watch/watch");
|
|
9
|
+
const _child_process = require("child_process");
|
|
10
|
+
const _client = require("nx/src/daemon/client/client");
|
|
11
|
+
const _output = require("nx/src/utils/output");
|
|
12
|
+
function nxViteBuildCoordinationPlugin(options) {
|
|
13
|
+
let activeBuildProcess;
|
|
14
|
+
let unregisterFileWatcher;
|
|
15
|
+
async function buildChangedProjects() {
|
|
16
|
+
await new Promise((res)=>{
|
|
17
|
+
activeBuildProcess = (0, _child_process.exec)(options.buildCommand);
|
|
18
|
+
activeBuildProcess.stdout.pipe(process.stdout);
|
|
19
|
+
activeBuildProcess.stderr.pipe(process.stderr);
|
|
20
|
+
activeBuildProcess.on('exit', ()=>{
|
|
21
|
+
res();
|
|
22
|
+
});
|
|
23
|
+
activeBuildProcess.on('error', ()=>{
|
|
24
|
+
res();
|
|
25
|
+
});
|
|
26
|
+
});
|
|
27
|
+
activeBuildProcess = undefined;
|
|
28
|
+
}
|
|
29
|
+
function createFileWatcher() {
|
|
30
|
+
const runner = new _watch.BatchFunctionRunner(()=>buildChangedProjects());
|
|
31
|
+
return _client.daemonClient.registerFileWatcher({
|
|
32
|
+
watchProjects: 'all'
|
|
33
|
+
}, (err, { changedProjects, changedFiles })=>{
|
|
34
|
+
if (err === 'closed') {
|
|
35
|
+
_output.output.error({
|
|
36
|
+
title: 'Watch connection closed',
|
|
37
|
+
bodyLines: [
|
|
38
|
+
'The daemon had closed the connection to this watch process.',
|
|
39
|
+
'Please restart your watch command.'
|
|
40
|
+
]
|
|
41
|
+
});
|
|
42
|
+
process.exit(1);
|
|
43
|
+
}
|
|
44
|
+
if (activeBuildProcess) {
|
|
45
|
+
activeBuildProcess.kill(2);
|
|
46
|
+
activeBuildProcess = undefined;
|
|
47
|
+
}
|
|
48
|
+
runner.enqueue(changedProjects, changedFiles);
|
|
49
|
+
});
|
|
50
|
+
}
|
|
51
|
+
return {
|
|
52
|
+
name: 'nx-vite-build-coordination-plugin',
|
|
53
|
+
async buildStart () {
|
|
54
|
+
if (!unregisterFileWatcher) {
|
|
55
|
+
await buildChangedProjects();
|
|
56
|
+
unregisterFileWatcher = await createFileWatcher();
|
|
57
|
+
process.on('exit', ()=>unregisterFileWatcher());
|
|
58
|
+
process.on('SIGINT', ()=>process.exit());
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
};
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
//# sourceMappingURL=nx-vite-build-coordination.plugin.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../../packages/vite/plugins/nx-vite-build-coordination.plugin.ts"],"sourcesContent":["import { type Plugin } from 'vite';\nimport { BatchFunctionRunner } from 'nx/src/command-line/watch/watch';\nimport { exec, type ChildProcess } from 'child_process';\nimport {\n daemonClient,\n type UnregisterCallback,\n} from 'nx/src/daemon/client/client';\nimport { output } from 'nx/src/utils/output';\n\nexport interface NxViteBuildCoordinationPluginOptions {\n buildCommand: string;\n}\nexport function nxViteBuildCoordinationPlugin(\n options: NxViteBuildCoordinationPluginOptions\n): Plugin {\n let activeBuildProcess: ChildProcess | undefined;\n let unregisterFileWatcher: UnregisterCallback | undefined;\n\n async function buildChangedProjects() {\n await new Promise<void>((res) => {\n activeBuildProcess = exec(options.buildCommand);\n activeBuildProcess.stdout.pipe(process.stdout);\n activeBuildProcess.stderr.pipe(process.stderr);\n activeBuildProcess.on('exit', () => {\n res();\n });\n activeBuildProcess.on('error', () => {\n res();\n });\n });\n activeBuildProcess = undefined;\n }\n\n function createFileWatcher() {\n const runner = new BatchFunctionRunner(() => buildChangedProjects());\n return daemonClient.registerFileWatcher(\n { watchProjects: 'all' },\n (err, { changedProjects, changedFiles }) => {\n if (err === 'closed') {\n output.error({\n title: 'Watch connection closed',\n bodyLines: [\n 'The daemon had closed the connection to this watch process.',\n 'Please restart your watch command.',\n ],\n });\n process.exit(1);\n }\n\n if (activeBuildProcess) {\n activeBuildProcess.kill(2);\n activeBuildProcess = undefined;\n }\n\n runner.enqueue(changedProjects, changedFiles);\n }\n );\n }\n\n return {\n name: 'nx-vite-build-coordination-plugin',\n async buildStart() {\n if (!unregisterFileWatcher) {\n await buildChangedProjects();\n unregisterFileWatcher = await createFileWatcher();\n process.on('exit', () => unregisterFileWatcher());\n process.on('SIGINT', () => process.exit());\n }\n },\n };\n}\n"],"names":["nxViteBuildCoordinationPlugin","options","activeBuildProcess","unregisterFileWatcher","buildChangedProjects","Promise","res","exec","buildCommand","stdout","pipe","process","stderr","on","undefined","createFileWatcher","runner","BatchFunctionRunner","daemonClient","registerFileWatcher","watchProjects","err","changedProjects","changedFiles","output","error","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"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../packages/vite/plugins/rollup-replace-files.plugin.ts"],"sourcesContent":["// source: https://github.com/Myrmod/vitejs-theming/blob/master/build-plugins/rollup/replace-files.js\n\n/**\n * @function replaceFiles\n * @param {FileReplacement[]} replacements\n * @return {({name: \"rollup-plugin-replace-files\", enforce: \"pre\" | \"post\" | undefined, Promise<resolveId>})}\n */\nexport function replaceFiles(replacements: FileReplacement[]): {\n name: string;\n enforce: 'pre' | 'post' | undefined;\n resolveId(\n source: any,\n importer: any,\n options: any\n ): Promise<{\n id: string;\n }>;\n} {\n if (!replacements?.length) {\n return null;\n }\n return {\n name: 'rollup-plugin-replace-files',\n enforce: 'pre',\n async resolveId(source, importer, options) {\n const resolved = await this.resolve(source, importer, {\n ...options,\n skipSelf: true,\n });\n /**\n * The reason we're using endsWith here is because the resolved id\n * will be the absolute path to the file. We want to check if the\n * file ends with the file we're trying to replace, which will be essentially\n * the path from the root of our workspace.\n */\n\n const foundReplace = replacements.find((replacement) =>\n resolved?.id?.endsWith(replacement.replace)\n );\n if (foundReplace) {\n console.info(\n `replace \"${foundReplace.replace}\" with \"${foundReplace.with}\"`\n );\n try {\n // return new file content\n return {\n id: foundReplace.with,\n };\n } catch (err) {\n console.error(err);\n return null;\n }\n }\n return null;\n },\n };\n}\n\nexport interface FileReplacement {\n replace: string;\n with: string;\n}\n"],"names":["replaceFiles","replacements","length","name","enforce","resolveId","source","importer","options","resolved","resolve","skipSelf","foundReplace","find","replacement","id","endsWith","replace","console","info","with","err","error"],"mappings":"AAAA,qGAAqG;AAErG;;;;CAIC;+BACeA;;;eAAAA;;;;AAAT,SAASA,aAAaC,YAA+B;IAW1D,IAAI,EAACA,gCAAAA,aAAcC,MAAM,GAAE;QACzB,OAAO;IACT;IACA,OAAO;QACLC,MAAM;QACNC,SAAS;QACT,MAAMC,WAAUC,MAAM,EAAEC,QAAQ,EAAEC,OAAO;YACvC,MAAMC,WAAW,MAAM,IAAI,CAACC,OAAO,CAACJ,QAAQC,UAAU,eACjDC;gBACHG,UAAU;;YAEZ;;;;;OAKC,GAED,MAAMC,eAAeX,aAAaY,IAAI,CAAC,CAACC;oBACtCL;uBAAAA,6BAAAA,eAAAA,SAAUM,EAAE,qBAAZN,aAAcO,QAAQ,CAACF,YAAYG,OAAO;;YAE5C,IAAIL,cAAc;gBAChBM,QAAQC,IAAI,CACV,CAAC,SAAS,EAAEP,aAAaK,OAAO,CAAC,QAAQ,EAAEL,aAAaQ,IAAI,CAAC,CAAC,CAAC;gBAEjE,IAAI;oBACF,0BAA0B;oBAC1B,OAAO;wBACLL,IAAIH,aAAaQ,IAAI;oBACvB;gBACF,EAAE,OAAOC,KAAK;oBACZH,QAAQI,KAAK,CAACD;oBACd,OAAO;gBACT;YACF;YACA,OAAO;QACT;IACF;AACF"}
|
|
1
|
+
{"version":3,"sources":["../../../../packages/vite/plugins/rollup-replace-files.plugin.ts"],"sourcesContent":["// source: https://github.com/Myrmod/vitejs-theming/blob/master/build-plugins/rollup/replace-files.js\n\n/**\n * @function replaceFiles\n * @param {FileReplacement[]} replacements\n * @return {({name: \"rollup-plugin-replace-files\", enforce: \"pre\" | \"post\" | undefined, Promise<resolveId>})}\n */\nexport function replaceFiles(replacements: FileReplacement[]): {\n name: string;\n enforce: 'pre' | 'post' | undefined;\n resolveId(\n source: any,\n importer: any,\n options: any\n ): Promise<{\n id: string;\n }>;\n} {\n if (!replacements?.length) {\n return null;\n }\n return {\n name: 'rollup-plugin-replace-files',\n enforce: 'pre',\n async resolveId(source, importer, options) {\n const resolved = await this.resolve(source, importer, {\n ...options,\n skipSelf: true,\n });\n /**\n * The reason we're using endsWith here is because the resolved id\n * will be the absolute path to the file. We want to check if the\n * file ends with the file we're trying to replace, which will be essentially\n * the path from the root of our workspace.\n */\n\n const foundReplace = replacements.find((replacement) =>\n resolved?.id?.endsWith(replacement.replace)\n );\n if (foundReplace) {\n console.info(\n `replace \"${foundReplace.replace}\" with \"${foundReplace.with}\"`\n );\n try {\n // return new file content\n return {\n id: foundReplace.with,\n };\n } catch (err) {\n console.error(err);\n return null;\n }\n }\n return null;\n },\n };\n}\n\nexport interface FileReplacement {\n replace: string;\n with: string;\n}\n"],"names":["replaceFiles","replacements","length","name","enforce","resolveId","source","importer","options","resolved","resolve","skipSelf","foundReplace","find","replacement","id","endsWith","replace","console","info","with","err","error"],"rangeMappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;","mappings":"AAAA,qGAAqG;AAErG;;;;CAIC;+BACeA;;;eAAAA;;;;AAAT,SAASA,aAAaC,YAA+B;IAW1D,IAAI,EAACA,gCAAAA,aAAcC,MAAM,GAAE;QACzB,OAAO;IACT;IACA,OAAO;QACLC,MAAM;QACNC,SAAS;QACT,MAAMC,WAAUC,MAAM,EAAEC,QAAQ,EAAEC,OAAO;YACvC,MAAMC,WAAW,MAAM,IAAI,CAACC,OAAO,CAACJ,QAAQC,UAAU,eACjDC;gBACHG,UAAU;;YAEZ;;;;;OAKC,GAED,MAAMC,eAAeX,aAAaY,IAAI,CAAC,CAACC;oBACtCL;uBAAAA,6BAAAA,eAAAA,SAAUM,EAAE,qBAAZN,aAAcO,QAAQ,CAACF,YAAYG,OAAO;;YAE5C,IAAIL,cAAc;gBAChBM,QAAQC,IAAI,CACV,CAAC,SAAS,EAAEP,aAAaK,OAAO,CAAC,QAAQ,EAAEL,aAAaQ,IAAI,CAAC,CAAC,CAAC;gBAEjE,IAAI;oBACF,0BAA0B;oBAC1B,OAAO;wBACLL,IAAIH,aAAaQ,IAAI;oBACvB;gBACF,EAAE,OAAOC,KAAK;oBACZH,QAAQI,KAAK,CAACD;oBACd,OAAO;gBACT;YACF;YACA,OAAO;QACT;IACF;AACF"}
|
|
@@ -6,14 +6,14 @@ function _export(target, all) {
|
|
|
6
6
|
});
|
|
7
7
|
}
|
|
8
8
|
_export(exports, {
|
|
9
|
-
|
|
10
|
-
return
|
|
9
|
+
default: function() {
|
|
10
|
+
return _default;
|
|
11
11
|
},
|
|
12
12
|
getBuildExtraArgs: function() {
|
|
13
13
|
return getBuildExtraArgs;
|
|
14
14
|
},
|
|
15
|
-
|
|
16
|
-
return
|
|
15
|
+
viteBuildExecutor: function() {
|
|
16
|
+
return viteBuildExecutor;
|
|
17
17
|
}
|
|
18
18
|
});
|
|
19
19
|
const _extends = require("@swc/helpers/_/_extends");
|
|
@@ -30,7 +30,7 @@ async function* viteBuildExecutor(options, context) {
|
|
|
30
30
|
// Allows ESM to be required in CJS modules. Vite will be published as ESM in the future.
|
|
31
31
|
const { mergeConfig, build, loadConfigFromFile } = await (0, _executorutils.loadViteDynamicImport)();
|
|
32
32
|
const projectRoot = context.projectsConfigurations.projects[context.projectName].root;
|
|
33
|
-
(0, _executorutils.createBuildableTsConfig)(projectRoot, options, context);
|
|
33
|
+
const tsConfigForBuild = (0, _executorutils.createBuildableTsConfig)(projectRoot, options, context);
|
|
34
34
|
const viteConfigPath = (0, _optionsutils.normalizeViteConfigFilePath)(context.root, projectRoot, options.configFile);
|
|
35
35
|
const root = projectRoot === '.' ? process.cwd() : (0, _path.relative)(context.cwd, (0, _devkit.joinPathFragments)(context.root, projectRoot));
|
|
36
36
|
const { buildOptions, otherOptions } = await getBuildExtraArgs(options);
|
|
@@ -53,11 +53,10 @@ async function* viteBuildExecutor(options, context) {
|
|
|
53
53
|
}, buildOptions)
|
|
54
54
|
}, otherOptions));
|
|
55
55
|
if (!options.skipTypeCheck) {
|
|
56
|
-
var _options_tsConfig;
|
|
57
56
|
await (0, _executorutils.validateTypes)({
|
|
58
57
|
workspaceRoot: context.root,
|
|
59
58
|
projectRoot: projectRoot,
|
|
60
|
-
tsconfig:
|
|
59
|
+
tsconfig: tsConfigForBuild
|
|
61
60
|
});
|
|
62
61
|
}
|
|
63
62
|
const watcherOrOutput = await build(buildConfig);
|
|
@@ -71,7 +70,7 @@ async function* viteBuildExecutor(options, context) {
|
|
|
71
70
|
if (options.generatePackageJson) {
|
|
72
71
|
if (context.projectGraph.nodes[context.projectName].type !== 'app') {
|
|
73
72
|
_devkit.logger.warn((0, _devkit.stripIndents)`The project ${context.projectName} is using the 'generatePackageJson' option which is deprecated for library projects. It should only be used for applications.
|
|
74
|
-
For libraries, configure the project to use the '@nx/dependency-checks' ESLint rule instead (https://nx.dev/
|
|
73
|
+
For libraries, configure the project to use the '@nx/dependency-checks' ESLint rule instead (https://nx.dev/nx-api/eslint-plugin/documents/dependency-checks).`);
|
|
75
74
|
}
|
|
76
75
|
const builtPackageJson = (0, _js.createPackageJson)(context.projectName, context.projectGraph, {
|
|
77
76
|
target: context.targetName,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../../../packages/vite/src/executors/build/build.impl.ts"],"sourcesContent":["import {\n detectPackageManager,\n ExecutorContext,\n joinPathFragments,\n logger,\n offsetFromRoot,\n stripIndents,\n writeJsonFile,\n} from '@nx/devkit';\nimport {\n getProjectTsConfigPath,\n normalizeViteConfigFilePath,\n} from '../../utils/options-utils';\nimport { ViteBuildExecutorOptions } from './schema';\nimport {\n copyAssets,\n createLockFile,\n createPackageJson,\n getLockFileName,\n} from '@nx/js';\nimport { existsSync, writeFileSync } from 'fs';\nimport { relative, resolve } from 'path';\nimport { createAsyncIterable } from '@nx/devkit/src/utils/async-iterable';\nimport {\n createBuildableTsConfig,\n loadViteDynamicImport,\n validateTypes,\n} from '../../utils/executor-utils';\n\nexport async function* viteBuildExecutor(\n options: Record<string, any> & ViteBuildExecutorOptions,\n context: ExecutorContext\n) {\n process.env.VITE_CJS_IGNORE_WARNING = 'true';\n // Allows ESM to be required in CJS modules. Vite will be published as ESM in the future.\n const { mergeConfig, build, loadConfigFromFile } =\n await loadViteDynamicImport();\n const projectRoot =\n context.projectsConfigurations.projects[context.projectName].root;\n createBuildableTsConfig(projectRoot, options, context);\n\n const viteConfigPath = normalizeViteConfigFilePath(\n context.root,\n projectRoot,\n options.configFile\n );\n const root =\n projectRoot === '.'\n ? process.cwd()\n : relative(context.cwd, joinPathFragments(context.root, projectRoot));\n\n const { buildOptions, otherOptions } = await getBuildExtraArgs(options);\n\n const resolved = await loadConfigFromFile(\n {\n mode: otherOptions?.mode ?? 'production',\n command: 'build',\n },\n viteConfigPath\n );\n\n const outDir =\n joinPathFragments(offsetFromRoot(projectRoot), options.outputPath) ??\n resolved?.config?.build?.outDir;\n\n const buildConfig = mergeConfig(\n {\n // This should not be needed as it's going to be set in vite.config.ts\n // but leaving it here in case someone did not migrate correctly\n root: resolved.config.root ?? root,\n configFile: viteConfigPath,\n },\n {\n build: {\n outDir,\n ...buildOptions,\n },\n ...otherOptions,\n }\n );\n\n if (!options.skipTypeCheck) {\n await validateTypes({\n workspaceRoot: context.root,\n projectRoot: projectRoot,\n tsconfig: options.tsConfig ?? getProjectTsConfigPath(projectRoot),\n });\n }\n\n const watcherOrOutput = await build(buildConfig);\n\n const libraryPackageJson = resolve(projectRoot, 'package.json');\n const rootPackageJson = resolve(context.root, 'package.json');\n\n // Here, we want the outdir relative to the workspace root.\n // So, we calculate the relative path from the workspace root to the outdir.\n const outDirRelativeToWorkspaceRoot = outDir.replaceAll('../', '');\n const distPackageJson = resolve(\n outDirRelativeToWorkspaceRoot,\n 'package.json'\n );\n\n // Generate a package.json if option has been set.\n if (options.generatePackageJson) {\n if (context.projectGraph.nodes[context.projectName].type !== 'app') {\n logger.warn(\n stripIndents`The project ${context.projectName} is using the 'generatePackageJson' option which is deprecated for library projects. It should only be used for applications.\n For libraries, configure the project to use the '@nx/dependency-checks' ESLint rule instead (https://nx.dev/packages/eslint-plugin/documents/dependency-checks).`\n );\n }\n\n const builtPackageJson = createPackageJson(\n context.projectName,\n context.projectGraph,\n {\n target: context.targetName,\n root: context.root,\n isProduction: !options.includeDevDependenciesInPackageJson, // By default we remove devDependencies since this is a production build.\n }\n );\n\n builtPackageJson.type = 'module';\n\n writeJsonFile(\n `${outDirRelativeToWorkspaceRoot}/package.json`,\n builtPackageJson\n );\n const packageManager = detectPackageManager(context.root);\n\n const lockFile = createLockFile(\n builtPackageJson,\n context.projectGraph,\n packageManager\n );\n writeFileSync(\n `${outDirRelativeToWorkspaceRoot}/${getLockFileName(packageManager)}`,\n lockFile,\n {\n encoding: 'utf-8',\n }\n );\n }\n // For buildable libs, copy package.json if it exists.\n else if (\n options.generatePackageJson !== false &&\n !existsSync(distPackageJson) &&\n existsSync(libraryPackageJson) &&\n rootPackageJson !== libraryPackageJson\n ) {\n await copyAssets(\n {\n outputPath: outDirRelativeToWorkspaceRoot,\n assets: [\n {\n input: projectRoot,\n output: '.',\n glob: 'package.json',\n },\n ],\n },\n context\n );\n }\n\n if ('on' in watcherOrOutput) {\n const iterable = createAsyncIterable<{ success: boolean }>(({ next }) => {\n let success = true;\n watcherOrOutput.on('event', (event) => {\n if (event.code === 'START') {\n success = true;\n } else if (event.code === 'ERROR') {\n success = false;\n } else if (event.code === 'END') {\n next({ success });\n }\n // result must be closed when present.\n // see https://rollupjs.org/guide/en/#rollupwatch\n if ('result' in event && event.result) {\n event.result.close();\n }\n });\n });\n yield* iterable;\n } else {\n const output = watcherOrOutput?.['output'] || watcherOrOutput?.[0]?.output;\n const fileName = output?.[0]?.fileName || 'main.cjs';\n const outfile = resolve(outDirRelativeToWorkspaceRoot, fileName);\n yield { success: true, outfile };\n }\n}\n\nexport async function getBuildExtraArgs(\n options: ViteBuildExecutorOptions\n): Promise<{\n // vite BuildOptions\n buildOptions: Record<string, unknown>;\n otherOptions: Record<string, any>;\n}> {\n // support passing extra args to vite cli\n const schema = await import('./schema.json');\n const extraArgs = {};\n for (const key of Object.keys(options)) {\n if (!schema.properties[key]) {\n extraArgs[key] = options[key];\n }\n }\n\n const buildOptions = {};\n const buildSchemaKeys = [\n 'target',\n 'polyfillModulePreload',\n 'modulePreload',\n 'outDir',\n 'assetsDir',\n 'assetsInlineLimit',\n 'cssCodeSplit',\n 'cssTarget',\n 'cssMinify',\n 'sourcemap',\n 'minify',\n 'terserOptions',\n 'rollupOptions',\n 'commonjsOptions',\n 'dynamicImportVarsOptions',\n 'write',\n 'emptyOutDir',\n 'copyPublicDir',\n 'manifest',\n 'lib',\n 'ssr',\n 'ssrManifest',\n 'ssrEmitAssets',\n 'reportCompressedSize',\n 'chunkSizeWarningLimit',\n 'watch',\n ];\n const otherOptions = {};\n for (const key of Object.keys(extraArgs)) {\n if (buildSchemaKeys.includes(key)) {\n buildOptions[key] = extraArgs[key];\n } else {\n otherOptions[key] = extraArgs[key];\n }\n }\n\n buildOptions['watch'] = options.watch ?? undefined;\n\n return {\n buildOptions,\n otherOptions,\n };\n}\n\nexport default viteBuildExecutor;\n"],"names":["viteBuildExecutor","getBuildExtraArgs","options","context","resolved","process","env","VITE_CJS_IGNORE_WARNING","mergeConfig","build","loadConfigFromFile","loadViteDynamicImport","projectRoot","projectsConfigurations","projects","projectName","root","createBuildableTsConfig","viteConfigPath","normalizeViteConfigFilePath","configFile","cwd","relative","joinPathFragments","buildOptions","otherOptions","mode","command","outDir","offsetFromRoot","outputPath","config","buildConfig","skipTypeCheck","validateTypes","workspaceRoot","tsconfig","tsConfig","getProjectTsConfigPath","watcherOrOutput","libraryPackageJson","resolve","rootPackageJson","outDirRelativeToWorkspaceRoot","replaceAll","distPackageJson","generatePackageJson","projectGraph","nodes","type","logger","warn","stripIndents","builtPackageJson","createPackageJson","target","targetName","isProduction","includeDevDependenciesInPackageJson","writeJsonFile","packageManager","detectPackageManager","lockFile","createLockFile","writeFileSync","getLockFileName","encoding","existsSync","copyAssets","assets","input","output","glob","iterable","createAsyncIterable","next","success","on","event","code","result","close","fileName","outfile","schema","extraArgs","key","Object","keys","properties","buildSchemaKeys","includes","watch","undefined"],"mappings":";;;;;;;;IA6BuBA,iBAAiB;eAAjBA;;IAkKDC,iBAAiB;eAAjBA;;IA8DtB,OAAiC;eAAjC;;;;wBArPO;8BAIA;oBAOA;oBACmC;sBACR;+BACE;+BAK7B;AAEA,gBAAgBD,kBACrBE,OAAuD,EACvDC,OAAwB;QAgCtBC,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C5B,MAAMC,YAAY,CAAC;IACnB,KAAK,MAAMC,OAAOC,OAAOC,IAAI,CAACtF,SAAU;QACtC,IAAI,CAACkF,OAAOK,UAAU,CAACH,IAAI,EAAE;YAC3BD,SAAS,CAACC,IAAI,GAAGpF,OAAO,CAACoF,IAAI;QAC/B;IACF;IAEA,MAAM9D,eAAe,CAAC;IACtB,MAAMkE,kBAAkB;QACtB;QACA;QACA;QACA;QACA;QACA;QACA;QACA;QACA;QACA;QACA;QACA;QACA;QACA;QACA;QACA;QACA;QACA;QACA;QACA;QACA;QACA;QACA;QACA;QACA;QACA;KACD;IACD,MAAMjE,eAAe,CAAC;IACtB,KAAK,MAAM6D,OAAOC,OAAOC,IAAI,CAACH,WAAY;QACxC,IAAIK,gBAAgBC,QAAQ,CAACL,MAAM;YACjC9D,YAAY,CAAC8D,IAAI,GAAGD,SAAS,CAACC,IAAI;QACpC,OAAO;YACL7D,YAAY,CAAC6D,IAAI,GAAGD,SAAS,CAACC,IAAI;QACpC;IACF;QAEwBpF;IAAxBsB,YAAY,CAAC,QAAQ,GAAGtB,CAAAA,iBAAAA,QAAQ0F,KAAK,YAAb1F,iBAAiB2F;IAEzC,OAAO;QACLrE;QACAC;IACF;AACF;MAEA,WAAezB"}
|
|
1
|
+
{"version":3,"sources":["../../../../../../packages/vite/src/executors/build/build.impl.ts"],"sourcesContent":["import {\n detectPackageManager,\n ExecutorContext,\n joinPathFragments,\n logger,\n offsetFromRoot,\n stripIndents,\n writeJsonFile,\n} from '@nx/devkit';\nimport {\n getProjectTsConfigPath,\n normalizeViteConfigFilePath,\n} from '../../utils/options-utils';\nimport { ViteBuildExecutorOptions } from './schema';\nimport {\n copyAssets,\n createLockFile,\n createPackageJson,\n getLockFileName,\n} from '@nx/js';\nimport { existsSync, writeFileSync } from 'fs';\nimport { relative, resolve } from 'path';\nimport { createAsyncIterable } from '@nx/devkit/src/utils/async-iterable';\nimport {\n createBuildableTsConfig,\n loadViteDynamicImport,\n validateTypes,\n} from '../../utils/executor-utils';\n\nexport async function* viteBuildExecutor(\n options: Record<string, any> & ViteBuildExecutorOptions,\n context: ExecutorContext\n) {\n process.env.VITE_CJS_IGNORE_WARNING = 'true';\n // Allows ESM to be required in CJS modules. Vite will be published as ESM in the future.\n const { mergeConfig, build, loadConfigFromFile } =\n await loadViteDynamicImport();\n const projectRoot =\n context.projectsConfigurations.projects[context.projectName].root;\n const tsConfigForBuild = createBuildableTsConfig(\n projectRoot,\n options,\n context\n );\n\n const viteConfigPath = normalizeViteConfigFilePath(\n context.root,\n projectRoot,\n options.configFile\n );\n const root =\n projectRoot === '.'\n ? process.cwd()\n : relative(context.cwd, joinPathFragments(context.root, projectRoot));\n\n const { buildOptions, otherOptions } = await getBuildExtraArgs(options);\n\n const resolved = await loadConfigFromFile(\n {\n mode: otherOptions?.mode ?? 'production',\n command: 'build',\n },\n viteConfigPath\n );\n\n const outDir =\n joinPathFragments(offsetFromRoot(projectRoot), options.outputPath) ??\n resolved?.config?.build?.outDir;\n\n const buildConfig = mergeConfig(\n {\n // This should not be needed as it's going to be set in vite.config.ts\n // but leaving it here in case someone did not migrate correctly\n root: resolved.config.root ?? root,\n configFile: viteConfigPath,\n },\n {\n build: {\n outDir,\n ...buildOptions,\n },\n ...otherOptions,\n }\n );\n\n if (!options.skipTypeCheck) {\n await validateTypes({\n workspaceRoot: context.root,\n projectRoot: projectRoot,\n tsconfig: tsConfigForBuild,\n });\n }\n\n const watcherOrOutput = await build(buildConfig);\n\n const libraryPackageJson = resolve(projectRoot, 'package.json');\n const rootPackageJson = resolve(context.root, 'package.json');\n\n // Here, we want the outdir relative to the workspace root.\n // So, we calculate the relative path from the workspace root to the outdir.\n const outDirRelativeToWorkspaceRoot = outDir.replaceAll('../', '');\n const distPackageJson = resolve(\n outDirRelativeToWorkspaceRoot,\n 'package.json'\n );\n\n // Generate a package.json if option has been set.\n if (options.generatePackageJson) {\n if (context.projectGraph.nodes[context.projectName].type !== 'app') {\n logger.warn(\n stripIndents`The project ${context.projectName} is using the 'generatePackageJson' option which is deprecated for library projects. It should only be used for applications.\n For libraries, configure the project to use the '@nx/dependency-checks' ESLint rule instead (https://nx.dev/nx-api/eslint-plugin/documents/dependency-checks).`\n );\n }\n\n const builtPackageJson = createPackageJson(\n context.projectName,\n context.projectGraph,\n {\n target: context.targetName,\n root: context.root,\n isProduction: !options.includeDevDependenciesInPackageJson, // By default we remove devDependencies since this is a production build.\n }\n );\n\n builtPackageJson.type = 'module';\n\n writeJsonFile(\n `${outDirRelativeToWorkspaceRoot}/package.json`,\n builtPackageJson\n );\n const packageManager = detectPackageManager(context.root);\n\n const lockFile = createLockFile(\n builtPackageJson,\n context.projectGraph,\n packageManager\n );\n writeFileSync(\n `${outDirRelativeToWorkspaceRoot}/${getLockFileName(packageManager)}`,\n lockFile,\n {\n encoding: 'utf-8',\n }\n );\n }\n // For buildable libs, copy package.json if it exists.\n else if (\n options.generatePackageJson !== false &&\n !existsSync(distPackageJson) &&\n existsSync(libraryPackageJson) &&\n rootPackageJson !== libraryPackageJson\n ) {\n await copyAssets(\n {\n outputPath: outDirRelativeToWorkspaceRoot,\n assets: [\n {\n input: projectRoot,\n output: '.',\n glob: 'package.json',\n },\n ],\n },\n context\n );\n }\n\n if ('on' in watcherOrOutput) {\n const iterable = createAsyncIterable<{ success: boolean }>(({ next }) => {\n let success = true;\n watcherOrOutput.on('event', (event) => {\n if (event.code === 'START') {\n success = true;\n } else if (event.code === 'ERROR') {\n success = false;\n } else if (event.code === 'END') {\n next({ success });\n }\n // result must be closed when present.\n // see https://rollupjs.org/guide/en/#rollupwatch\n if ('result' in event && event.result) {\n event.result.close();\n }\n });\n });\n yield* iterable;\n } else {\n const output = watcherOrOutput?.['output'] || watcherOrOutput?.[0]?.output;\n const fileName = output?.[0]?.fileName || 'main.cjs';\n const outfile = resolve(outDirRelativeToWorkspaceRoot, fileName);\n yield { success: true, outfile };\n }\n}\n\nexport async function getBuildExtraArgs(\n options: ViteBuildExecutorOptions\n): Promise<{\n // vite BuildOptions\n buildOptions: Record<string, unknown>;\n otherOptions: Record<string, any>;\n}> {\n // support passing extra args to vite cli\n const schema = await import('./schema.json');\n const extraArgs = {};\n for (const key of Object.keys(options)) {\n if (!schema.properties[key]) {\n extraArgs[key] = options[key];\n }\n }\n\n const buildOptions = {};\n const buildSchemaKeys = [\n 'target',\n 'polyfillModulePreload',\n 'modulePreload',\n 'outDir',\n 'assetsDir',\n 'assetsInlineLimit',\n 'cssCodeSplit',\n 'cssTarget',\n 'cssMinify',\n 'sourcemap',\n 'minify',\n 'terserOptions',\n 'rollupOptions',\n 'commonjsOptions',\n 'dynamicImportVarsOptions',\n 'write',\n 'emptyOutDir',\n 'copyPublicDir',\n 'manifest',\n 'lib',\n 'ssr',\n 'ssrManifest',\n 'ssrEmitAssets',\n 'reportCompressedSize',\n 'chunkSizeWarningLimit',\n 'watch',\n ];\n const otherOptions = {};\n for (const key of Object.keys(extraArgs)) {\n if (buildSchemaKeys.includes(key)) {\n buildOptions[key] = extraArgs[key];\n } else {\n otherOptions[key] = extraArgs[key];\n }\n }\n\n buildOptions['watch'] = options.watch ?? undefined;\n\n return {\n buildOptions,\n otherOptions,\n };\n}\n\nexport default viteBuildExecutor;\n"],"names":["getBuildExtraArgs","viteBuildExecutor","options","context","resolved","process","env","VITE_CJS_IGNORE_WARNING","mergeConfig","build","loadConfigFromFile","loadViteDynamicImport","projectRoot","projectsConfigurations","projects","projectName","root","tsConfigForBuild","createBuildableTsConfig","viteConfigPath","normalizeViteConfigFilePath","configFile","cwd","relative","joinPathFragments","buildOptions","otherOptions","mode","command","outDir","offsetFromRoot","outputPath","config","buildConfig","skipTypeCheck","validateTypes","workspaceRoot","tsconfig","watcherOrOutput","libraryPackageJson","resolve","rootPackageJson","outDirRelativeToWorkspaceRoot","replaceAll","distPackageJson","generatePackageJson","projectGraph","nodes","type","logger","warn","stripIndents","builtPackageJson","createPackageJson","target","targetName","isProduction","includeDevDependenciesInPackageJson","writeJsonFile","packageManager","detectPackageManager","lockFile","createLockFile","writeFileSync","getLockFileName","encoding","existsSync","copyAssets","assets","input","output","glob","iterable","createAsyncIterable","next","success","on","event","code","result","close","fileName","outfile","schema","extraArgs","key","Object","keys","properties","buildSchemaKeys","includes","watch","undefined"],"rangeMappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;","mappings":";;;;;;;;IAiQA,OAAiC;eAAjC;;IA9DsBA,iBAAiB;eAAjBA;;IAtKCC,iBAAiB;eAAjBA;;;;wBArBhB;8BAIA;oBAOA;oBACmC;sBACR;+BACE;+BAK7B;AAEA,gBAAgBA,kBACrBC,OAAuD,EACvDC,OAAwB;QAoCtBC,wBAAAA;IAlCFC,QAAQC,GAAG,CAACC,uBAAuB,GAAG;IACtC,yFAAyF;IACzF,MAAM,EAAEC,WAAW,EAAEC,KAAK,EAAEC,kBAAkB,EAAE,GAC9C,MAAMC,IAAAA,oCAAqB;IAC7B,MAAMC,cACJT,QAAQU,sBAAsB,CAACC,QAAQ,CAACX,QAAQY,WAAW,CAAC,CAACC,IAAI;IACnE,MAAMC,mBAAmBC,IAAAA,sCAAuB,EAC9CN,aACAV,SACAC;IAGF,MAAMgB,iBAAiBC,IAAAA,yCAA2B,EAChDjB,QAAQa,IAAI,EACZJ,aACAV,QAAQmB,UAAU;IAEpB,MAAML,OACJJ,gBAAgB,MACZP,QAAQiB,GAAG,KACXC,IAAAA,cAAQ,EAACpB,QAAQmB,GAAG,EAAEE,IAAAA,yBAAiB,EAACrB,QAAQa,IAAI,EAAEJ;IAE5D,MAAM,EAAEa,YAAY,EAAEC,YAAY,EAAE,GAAG,MAAM1B,kBAAkBE;QAIrDwB;IAFV,MAAMtB,WAAW,MAAMM,mBACrB;QAC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EzC,OAAO;QACLnE;QACAC;IACF;AACF;MAEA,WAAezB"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../../../packages/vite/src/executors/build/compat.ts"],"sourcesContent":["import { convertNxExecutor } from '@nx/devkit';\nimport viteBuildExecutor from './build.impl';\n\nexport default convertNxExecutor(viteBuildExecutor);\n"],"names":["convertNxExecutor","viteBuildExecutor"],"mappings":";+BAGA;;;eAAA;;;wBAHkC;2BACJ;MAE9B,WAAeA,IAAAA,yBAAiB,EAACC,kBAAiB"}
|
|
1
|
+
{"version":3,"sources":["../../../../../../packages/vite/src/executors/build/compat.ts"],"sourcesContent":["import { convertNxExecutor } from '@nx/devkit';\nimport viteBuildExecutor from './build.impl';\n\nexport default convertNxExecutor(viteBuildExecutor);\n"],"names":["convertNxExecutor","viteBuildExecutor"],"rangeMappings":";;;;;;;;;","mappings":";+BAGA;;;eAAA;;;wBAHkC;2BACJ;MAE9B,WAAeA,IAAAA,yBAAiB,EAACC,kBAAiB"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../../../packages/vite/src/executors/build/schema.d.ts"],"names":[],"mappings":""}
|
|
1
|
+
{"version":3,"sources":["../../../../../../packages/vite/src/executors/build/schema.d.ts"],"names":[],"rangeMappings":"","mappings":""}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../../../packages/vite/src/executors/dev-server/compat.ts"],"sourcesContent":["import { convertNxExecutor } from '@nx/devkit';\nimport viteDevServerExecutor from './dev-server.impl';\n\nexport default convertNxExecutor(viteDevServerExecutor);\n"],"names":["convertNxExecutor","viteDevServerExecutor"],"mappings":";+BAGA;;;eAAA;;;wBAHkC;+BACA;MAElC,WAAeA,IAAAA,yBAAiB,EAACC,sBAAqB"}
|
|
1
|
+
{"version":3,"sources":["../../../../../../packages/vite/src/executors/dev-server/compat.ts"],"sourcesContent":["import { convertNxExecutor } from '@nx/devkit';\nimport viteDevServerExecutor from './dev-server.impl';\n\nexport default convertNxExecutor(viteDevServerExecutor);\n"],"names":["convertNxExecutor","viteDevServerExecutor"],"rangeMappings":";;;;;;;;;","mappings":";+BAGA;;;eAAA;;;wBAHkC;+BACA;MAElC,WAAeA,IAAAA,yBAAiB,EAACC,sBAAqB"}
|