@nx/vite 21.3.7 → 21.4.0-beta.1
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/executors.d.ts +1 -0
- package/executors.d.ts.map +1 -0
- package/executors.js +10 -26
- package/index.d.ts +1 -0
- package/index.d.ts.map +1 -0
- package/index.js +12 -26
- package/package.json +7 -4
- package/plugin.d.ts +1 -0
- package/plugin.d.ts.map +1 -0
- package/plugin.js +6 -23
- package/plugins/nx-copy-assets.plugin.d.ts +1 -0
- package/plugins/nx-copy-assets.plugin.d.ts.map +1 -0
- package/plugins/nx-copy-assets.plugin.js +28 -30
- package/plugins/nx-tsconfig-paths.plugin.d.ts +1 -0
- package/plugins/nx-tsconfig-paths.plugin.d.ts.map +1 -0
- package/plugins/nx-tsconfig-paths.plugin.js +86 -88
- package/plugins/nx-vite-build-coordination.plugin.d.ts +1 -0
- package/plugins/nx-vite-build-coordination.plugin.d.ts.map +1 -0
- package/plugins/nx-vite-build-coordination.plugin.js +25 -32
- package/plugins/rollup-replace-files.plugin.d.ts +1 -0
- package/plugins/rollup-replace-files.plugin.d.ts.map +1 -0
- package/plugins/rollup-replace-files.plugin.js +20 -26
- package/project.json +52 -0
- package/src/executors/build/build.impl.d.ts +1 -0
- package/src/executors/build/build.impl.d.ts.map +1 -0
- package/src/executors/build/build.impl.js +98 -112
- package/src/executors/build/compat.d.ts +1 -0
- package/src/executors/build/compat.d.ts.map +1 -0
- package/src/executors/build/compat.js +4 -11
- package/src/executors/dev-server/compat.d.ts +1 -0
- package/src/executors/dev-server/compat.d.ts.map +1 -0
- package/src/executors/dev-server/compat.js +4 -11
- package/src/executors/dev-server/dev-server.impl.d.ts +1 -0
- package/src/executors/dev-server/dev-server.impl.d.ts.map +1 -0
- package/src/executors/dev-server/dev-server.impl.js +54 -62
- package/src/executors/preview-server/compat.d.ts +1 -0
- package/src/executors/preview-server/compat.d.ts.map +1 -0
- package/src/executors/preview-server/compat.js +4 -11
- package/src/executors/preview-server/preview-server.impl.d.ts +1 -0
- package/src/executors/preview-server/preview-server.impl.d.ts.map +1 -0
- package/src/executors/preview-server/preview-server.impl.js +74 -77
- package/src/executors/test/compat.d.ts +1 -0
- package/src/executors/test/compat.d.ts.map +1 -0
- package/src/executors/test/compat.js +4 -11
- package/src/executors/test/lib/nx-reporter.d.ts +1 -0
- package/src/executors/test/lib/nx-reporter.d.ts.map +1 -0
- package/src/executors/test/lib/nx-reporter.js +17 -25
- package/src/executors/test/lib/utils.d.ts +1 -0
- package/src/executors/test/lib/utils.d.ts.map +1 -0
- package/src/executors/test/lib/utils.js +36 -59
- package/src/executors/test/vitest.impl.d.ts +1 -0
- package/src/executors/test/vitest.impl.d.ts.map +1 -0
- package/src/executors/test/vitest.impl.js +29 -43
- package/src/generators/configuration/configuration.d.ts +1 -0
- package/src/generators/configuration/configuration.d.ts.map +1 -0
- package/src/generators/configuration/configuration.js +82 -102
- package/src/generators/configuration/lib/convert-non-vite.d.ts +1 -0
- package/src/generators/configuration/lib/convert-non-vite.d.ts.map +1 -0
- package/src/generators/configuration/lib/convert-non-vite.js +33 -32
- package/src/generators/convert-to-inferred/convert-to-inferred.d.ts +1 -0
- package/src/generators/convert-to-inferred/convert-to-inferred.d.ts.map +1 -0
- package/src/generators/convert-to-inferred/convert-to-inferred.js +31 -61
- package/src/generators/convert-to-inferred/lib/build-post-target-transformer.d.ts +1 -0
- package/src/generators/convert-to-inferred/lib/build-post-target-transformer.d.ts.map +1 -0
- package/src/generators/convert-to-inferred/lib/build-post-target-transformer.js +46 -58
- package/src/generators/convert-to-inferred/lib/preview-post-target-transformer.d.ts +1 -0
- package/src/generators/convert-to-inferred/lib/preview-post-target-transformer.d.ts.map +1 -0
- package/src/generators/convert-to-inferred/lib/preview-post-target-transformer.js +9 -14
- package/src/generators/convert-to-inferred/lib/serve-post-target-transformer.d.ts +1 -0
- package/src/generators/convert-to-inferred/lib/serve-post-target-transformer.d.ts.map +1 -0
- package/src/generators/convert-to-inferred/lib/serve-post-target-transformer.js +10 -15
- package/src/generators/convert-to-inferred/lib/test-post-target-transformer.d.ts +1 -0
- package/src/generators/convert-to-inferred/lib/test-post-target-transformer.d.ts.map +1 -0
- package/src/generators/convert-to-inferred/lib/test-post-target-transformer.js +16 -23
- package/src/generators/convert-to-inferred/lib/utils.d.ts +1 -0
- package/src/generators/convert-to-inferred/lib/utils.d.ts.map +1 -0
- package/src/generators/convert-to-inferred/lib/utils.js +18 -33
- package/src/generators/init/init.d.ts +1 -0
- package/src/generators/init/init.d.ts.map +1 -0
- package/src/generators/init/init.js +44 -96
- package/src/generators/init/lib/utils.d.ts +1 -0
- package/src/generators/init/lib/utils.d.ts.map +1 -0
- package/src/generators/init/lib/utils.js +20 -35
- package/src/generators/setup-paths-plugin/lib/utils.d.ts +1 -0
- package/src/generators/setup-paths-plugin/lib/utils.d.ts.map +1 -0
- package/src/generators/setup-paths-plugin/lib/utils.js +0 -3
- package/src/generators/setup-paths-plugin/setup-paths-plugin.d.ts +1 -0
- package/src/generators/setup-paths-plugin/setup-paths-plugin.d.ts.map +1 -0
- package/src/generators/setup-paths-plugin/setup-paths-plugin.js +45 -54
- package/src/generators/vitest/vitest-generator.d.ts +1 -0
- package/src/generators/vitest/vitest-generator.d.ts.map +1 -0
- package/src/generators/vitest/vitest-generator.js +134 -174
- package/src/migrations/update-19-6-0/add-depends-on-for-preview.d.ts +1 -0
- package/src/migrations/update-19-6-0/add-depends-on-for-preview.d.ts.map +1 -0
- package/src/migrations/update-19-6-0/add-depends-on-for-preview.js +10 -18
- package/src/migrations/update-20-0-4/add-vite-temp-files-to-git-ignore.d.ts +1 -0
- package/src/migrations/update-20-0-4/add-vite-temp-files-to-git-ignore.d.ts.map +1 -0
- package/src/migrations/update-20-0-4/add-vite-temp-files-to-git-ignore.js +4 -10
- package/src/migrations/update-20-3-0/add-vitest-temp-files-to-git-ignore.d.ts +1 -0
- package/src/migrations/update-20-3-0/add-vitest-temp-files-to-git-ignore.d.ts.map +1 -0
- package/src/migrations/update-20-3-0/add-vitest-temp-files-to-git-ignore.js +4 -10
- package/src/migrations/update-20-5-0/eslint-ignore-vite-temp-files.d.ts +1 -0
- package/src/migrations/update-20-5-0/eslint-ignore-vite-temp-files.d.ts.map +1 -0
- package/src/migrations/update-20-5-0/eslint-ignore-vite-temp-files.js +20 -24
- package/src/migrations/update-20-5-0/install-jiti.d.ts +1 -0
- package/src/migrations/update-20-5-0/install-jiti.d.ts.map +1 -0
- package/src/migrations/update-20-5-0/install-jiti.js +6 -12
- package/src/migrations/update-20-5-0/update-resolve-conditions.d.ts +1 -0
- package/src/migrations/update-20-5-0/update-resolve-conditions.d.ts.map +1 -0
- package/src/migrations/update-20-5-0/update-resolve-conditions.js +26 -28
- package/src/plugins/plugin.d.ts +1 -0
- package/src/plugins/plugin.d.ts.map +1 -0
- package/src/plugins/plugin.js +189 -267
- package/src/utils/detect-ui-framework.d.ts +1 -0
- package/src/utils/detect-ui-framework.d.ts.map +1 -0
- package/src/utils/detect-ui-framework.js +9 -20
- package/src/utils/e2e-web-server-info-utils.d.ts +1 -0
- package/src/utils/e2e-web-server-info-utils.d.ts.map +1 -0
- package/src/utils/e2e-web-server-info-utils.js +23 -35
- package/src/utils/ensure-dependencies.d.ts +1 -0
- package/src/utils/ensure-dependencies.d.ts.map +1 -0
- package/src/utils/ensure-dependencies.js +24 -26
- package/src/utils/executor-utils.d.ts +1 -0
- package/src/utils/executor-utils.d.ts.map +1 -0
- package/src/utils/executor-utils.js +27 -43
- package/src/utils/find-vite-config.d.ts +1 -0
- package/src/utils/find-vite-config.d.ts.map +1 -0
- package/src/utils/find-vite-config.js +12 -37
- package/src/utils/generator-utils.d.ts +1 -0
- package/src/utils/generator-utils.d.ts.map +1 -0
- package/src/utils/generator-utils.js +204 -216
- package/src/utils/ignore-vite-temp-files.d.ts +1 -0
- package/src/utils/ignore-vite-temp-files.d.ts.map +1 -0
- package/src/utils/ignore-vite-temp-files.js +22 -32
- package/src/utils/nx-tsconfig-paths-find-file.d.ts +1 -0
- package/src/utils/nx-tsconfig-paths-find-file.d.ts.map +1 -0
- package/src/utils/nx-tsconfig-paths-find-file.js +10 -16
- package/src/utils/options-utils.d.ts +1 -0
- package/src/utils/options-utils.d.ts.map +1 -0
- package/src/utils/options-utils.js +48 -58
- package/src/utils/test-files/test-vite-configs.d.ts +1 -0
- package/src/utils/test-files/test-vite-configs.d.ts.map +1 -0
- package/src/utils/test-files/test-vite-configs.js +21 -82
- package/src/utils/test-utils.d.ts +1 -0
- package/src/utils/test-utils.d.ts.map +1 -0
- package/src/utils/test-utils.js +103 -130
- package/src/utils/version-utils.d.ts +1 -0
- package/src/utils/version-utils.d.ts.map +1 -0
- package/src/utils/version-utils.js +26 -44
- package/src/utils/versions.d.ts +1 -0
- package/src/utils/versions.d.ts.map +1 -0
- package/src/utils/versions.js +22 -82
- package/src/utils/vite-config-edit-utils.d.ts +1 -0
- package/src/utils/vite-config-edit-utils.d.ts.map +1 -0
- package/src/utils/vite-config-edit-utils.js +145 -125
- package/executors.js.map +0 -1
- package/index.js.map +0 -1
- package/plugin.js.map +0 -1
- package/plugins/nx-copy-assets.plugin.js.map +0 -1
- package/plugins/nx-tsconfig-paths.plugin.js.map +0 -1
- package/plugins/nx-vite-build-coordination.plugin.js.map +0 -1
- package/plugins/rollup-replace-files.plugin.js.map +0 -1
- package/src/executors/build/build.impl.js.map +0 -1
- package/src/executors/build/compat.js.map +0 -1
- package/src/executors/build/schema.d.js +0 -3
- package/src/executors/build/schema.d.js.map +0 -1
- package/src/executors/dev-server/compat.js.map +0 -1
- package/src/executors/dev-server/dev-server.impl.js.map +0 -1
- package/src/executors/dev-server/schema.d.js +0 -3
- package/src/executors/dev-server/schema.d.js.map +0 -1
- package/src/executors/preview-server/compat.js.map +0 -1
- package/src/executors/preview-server/preview-server.impl.js.map +0 -1
- package/src/executors/preview-server/schema.d.js +0 -3
- package/src/executors/preview-server/schema.d.js.map +0 -1
- package/src/executors/test/compat.js.map +0 -1
- package/src/executors/test/lib/nx-reporter.js.map +0 -1
- package/src/executors/test/lib/utils.js.map +0 -1
- package/src/executors/test/schema.d.js +0 -3
- package/src/executors/test/schema.d.js.map +0 -1
- package/src/executors/test/vitest.impl.js.map +0 -1
- package/src/generators/configuration/configuration.js.map +0 -1
- package/src/generators/configuration/lib/convert-non-vite.js.map +0 -1
- package/src/generators/configuration/schema.d.js +0 -3
- package/src/generators/configuration/schema.d.js.map +0 -1
- package/src/generators/convert-to-inferred/convert-to-inferred.js.map +0 -1
- package/src/generators/convert-to-inferred/lib/build-post-target-transformer.js.map +0 -1
- package/src/generators/convert-to-inferred/lib/preview-post-target-transformer.js.map +0 -1
- package/src/generators/convert-to-inferred/lib/serve-post-target-transformer.js.map +0 -1
- package/src/generators/convert-to-inferred/lib/test-post-target-transformer.js.map +0 -1
- package/src/generators/convert-to-inferred/lib/utils.js.map +0 -1
- package/src/generators/init/init.js.map +0 -1
- package/src/generators/init/lib/utils.js.map +0 -1
- package/src/generators/init/schema.d.js +0 -3
- package/src/generators/init/schema.d.js.map +0 -1
- package/src/generators/setup-paths-plugin/lib/utils.js.map +0 -1
- package/src/generators/setup-paths-plugin/schema.d.js +0 -3
- package/src/generators/setup-paths-plugin/schema.d.js.map +0 -1
- package/src/generators/setup-paths-plugin/setup-paths-plugin.js.map +0 -1
- package/src/generators/vitest/schema.d.js +0 -3
- package/src/generators/vitest/schema.d.js.map +0 -1
- package/src/generators/vitest/vitest-generator.js.map +0 -1
- package/src/migrations/update-19-6-0/add-depends-on-for-preview.js.map +0 -1
- package/src/migrations/update-20-0-4/add-vite-temp-files-to-git-ignore.js.map +0 -1
- package/src/migrations/update-20-3-0/add-vitest-temp-files-to-git-ignore.js.map +0 -1
- package/src/migrations/update-20-5-0/eslint-ignore-vite-temp-files.js.map +0 -1
- package/src/migrations/update-20-5-0/install-jiti.js.map +0 -1
- package/src/migrations/update-20-5-0/update-resolve-conditions.js.map +0 -1
- package/src/plugins/plugin.js.map +0 -1
- package/src/utils/detect-ui-framework.js.map +0 -1
- package/src/utils/e2e-web-server-info-utils.js.map +0 -1
- package/src/utils/ensure-dependencies.js.map +0 -1
- package/src/utils/executor-utils.js.map +0 -1
- package/src/utils/find-vite-config.js.map +0 -1
- package/src/utils/generator-utils.js.map +0 -1
- package/src/utils/ignore-vite-temp-files.js.map +0 -1
- package/src/utils/nx-tsconfig-paths-find-file.js.map +0 -1
- package/src/utils/options-utils.js.map +0 -1
- package/src/utils/test-files/test-vite-configs.js.map +0 -1
- package/src/utils/test-utils.js.map +0 -1
- package/src/utils/version-utils.js.map +0 -1
- package/src/utils/versions.js.map +0 -1
- package/src/utils/vite-config-edit-utils.js.map +0 -1
package/src/plugins/plugin.js
CHANGED
|
@@ -1,55 +1,45 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
return createNodes;
|
|
14
|
-
},
|
|
15
|
-
createNodesV2: function() {
|
|
16
|
-
return createNodesV2;
|
|
17
|
-
}
|
|
18
|
-
});
|
|
19
|
-
const _extends = require("@swc/helpers/_/_extends");
|
|
20
|
-
const _devkit = require("@nx/devkit");
|
|
21
|
-
const _path = require("path");
|
|
22
|
-
const _getnamedinputs = require("@nx/devkit/src/utils/get-named-inputs");
|
|
23
|
-
const _fs = require("fs");
|
|
24
|
-
const _calculatehashforcreatenodes = require("@nx/devkit/src/utils/calculate-hash-for-create-nodes");
|
|
25
|
-
const _cachedirectory = require("nx/src/utils/cache-directory");
|
|
26
|
-
const _js = require("@nx/js");
|
|
27
|
-
const _executorutils = require("../utils/executor-utils");
|
|
28
|
-
const _filehasher = require("nx/src/hasher/file-hasher");
|
|
29
|
-
const _tssolutionsetup = require("@nx/js/src/utils/typescript/ts-solution-setup");
|
|
30
|
-
const _util = require("@nx/js/src/plugins/typescript/util");
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.createNodes = exports.createNodesV2 = exports.createDependencies = void 0;
|
|
4
|
+
const devkit_1 = require("@nx/devkit");
|
|
5
|
+
const path_1 = require("path");
|
|
6
|
+
const get_named_inputs_1 = require("@nx/devkit/src/utils/get-named-inputs");
|
|
7
|
+
const fs_1 = require("fs");
|
|
8
|
+
const calculate_hash_for_create_nodes_1 = require("@nx/devkit/src/utils/calculate-hash-for-create-nodes");
|
|
9
|
+
const cache_directory_1 = require("nx/src/utils/cache-directory");
|
|
10
|
+
const js_1 = require("@nx/js");
|
|
11
|
+
const executor_utils_1 = require("../utils/executor-utils");
|
|
12
|
+
const file_hasher_1 = require("nx/src/hasher/file-hasher");
|
|
31
13
|
const picomatch = require("picomatch");
|
|
32
|
-
const
|
|
14
|
+
const ts_solution_setup_1 = require("@nx/js/src/utils/typescript/ts-solution-setup");
|
|
15
|
+
const util_1 = require("@nx/js/src/plugins/typescript/util");
|
|
16
|
+
const pmc = (0, devkit_1.getPackageManagerCommand)();
|
|
33
17
|
function readTargetsCache(cachePath) {
|
|
34
|
-
return process.env.NX_CACHE_PROJECT_GRAPH !== 'false' && (0,
|
|
18
|
+
return process.env.NX_CACHE_PROJECT_GRAPH !== 'false' && (0, fs_1.existsSync)(cachePath)
|
|
19
|
+
? (0, devkit_1.readJsonFile)(cachePath)
|
|
20
|
+
: {};
|
|
35
21
|
}
|
|
36
22
|
function writeTargetsToCache(cachePath, results) {
|
|
37
|
-
(0,
|
|
23
|
+
(0, devkit_1.writeJsonFile)(cachePath, results);
|
|
38
24
|
}
|
|
39
|
-
|
|
25
|
+
/**
|
|
26
|
+
* @deprecated The 'createDependencies' function is now a no-op. This functionality is included in 'createNodesV2'.
|
|
27
|
+
*/
|
|
28
|
+
const createDependencies = () => {
|
|
40
29
|
return [];
|
|
41
30
|
};
|
|
31
|
+
exports.createDependencies = createDependencies;
|
|
42
32
|
const viteVitestConfigGlob = '**/{vite,vitest}.config.{js,ts,mjs,mts,cjs,cts}';
|
|
43
|
-
|
|
33
|
+
exports.createNodesV2 = [
|
|
44
34
|
viteVitestConfigGlob,
|
|
45
|
-
async (configFilePaths, options, context)=>{
|
|
46
|
-
const optionsHash = (0,
|
|
35
|
+
async (configFilePaths, options, context) => {
|
|
36
|
+
const optionsHash = (0, file_hasher_1.hashObject)(options);
|
|
47
37
|
const normalizedOptions = normalizeOptions(options);
|
|
48
|
-
const cachePath = (0,
|
|
38
|
+
const cachePath = (0, path_1.join)(cache_directory_1.workspaceDataDirectory, `vite-${optionsHash}.hash`);
|
|
49
39
|
const targetsCache = readTargetsCache(cachePath);
|
|
50
|
-
const isUsingTsSolutionSetup = (0,
|
|
51
|
-
const { roots: projectRoots, configFiles: validConfigFiles } = configFilePaths.reduce((acc, configFile)=>{
|
|
52
|
-
const potentialRoot = (0,
|
|
40
|
+
const isUsingTsSolutionSetup = (0, ts_solution_setup_1.isUsingTsSolutionSetup)();
|
|
41
|
+
const { roots: projectRoots, configFiles: validConfigFiles } = configFilePaths.reduce((acc, configFile) => {
|
|
42
|
+
const potentialRoot = (0, path_1.dirname)(configFile);
|
|
53
43
|
if (checkIfConfigFileShouldBeProject(potentialRoot, context)) {
|
|
54
44
|
acc.roots.push(potentialRoot);
|
|
55
45
|
acc.configFiles.push(configFile);
|
|
@@ -57,37 +47,33 @@ const createNodesV2 = [
|
|
|
57
47
|
return acc;
|
|
58
48
|
}, {
|
|
59
49
|
roots: [],
|
|
60
|
-
configFiles: []
|
|
50
|
+
configFiles: [],
|
|
61
51
|
});
|
|
62
|
-
const lockfile = (0,
|
|
63
|
-
const hashes = await (0,
|
|
64
|
-
isUsingTsSolutionSetup
|
|
65
|
-
}), context, projectRoots.map((r)=>[
|
|
66
|
-
lockfile
|
|
67
|
-
]));
|
|
52
|
+
const lockfile = (0, js_1.getLockFileName)((0, devkit_1.detectPackageManager)(context.workspaceRoot));
|
|
53
|
+
const hashes = await (0, calculate_hash_for_create_nodes_1.calculateHashesForCreateNodes)(projectRoots, { ...normalizedOptions, isUsingTsSolutionSetup }, context, projectRoots.map((r) => [lockfile]));
|
|
68
54
|
try {
|
|
69
|
-
return await (0,
|
|
70
|
-
|
|
71
|
-
const projectRoot = (0, _path.dirname)(configFile);
|
|
55
|
+
return await (0, devkit_1.createNodesFromFiles)(async (configFile, _, context, idx) => {
|
|
56
|
+
const projectRoot = (0, path_1.dirname)(configFile);
|
|
72
57
|
// Do not create a project if package.json and project.json isn't there.
|
|
73
|
-
const siblingFiles = (0,
|
|
74
|
-
|
|
75
|
-
const
|
|
76
|
-
const hasReactRouterConfig = siblingFiles.some((configFile)=>{
|
|
58
|
+
const siblingFiles = (0, fs_1.readdirSync)((0, path_1.join)(context.workspaceRoot, projectRoot));
|
|
59
|
+
const tsConfigFiles = siblingFiles.filter((p) => picomatch('tsconfig*{.json,.*.json}')(p)) ?? [];
|
|
60
|
+
const hasReactRouterConfig = siblingFiles.some((configFile) => {
|
|
77
61
|
const parts = configFile.split('.');
|
|
78
|
-
return parts[0] === 'react-router' &&
|
|
62
|
+
return (parts[0] === 'react-router' &&
|
|
63
|
+
parts[1] === 'config' &&
|
|
64
|
+
parts.length > 2);
|
|
79
65
|
});
|
|
80
66
|
// results from vitest.config.js will be different from results of vite.config.js
|
|
81
67
|
// but the hash will be the same because it is based on the files under the project root.
|
|
82
68
|
// Adding the config file path to the hash ensures that the final hash value is different
|
|
83
69
|
// for different config files.
|
|
84
70
|
const hash = hashes[idx] + configFile;
|
|
85
|
-
|
|
86
|
-
|
|
71
|
+
const { projectType, metadata, targets } = (targetsCache[hash] ??=
|
|
72
|
+
await buildViteTargets(configFile, projectRoot, normalizedOptions, tsConfigFiles, hasReactRouterConfig, isUsingTsSolutionSetup, context));
|
|
87
73
|
const project = {
|
|
88
74
|
root: projectRoot,
|
|
89
75
|
targets,
|
|
90
|
-
metadata
|
|
76
|
+
metadata,
|
|
91
77
|
};
|
|
92
78
|
// If project is buildable, then the project type.
|
|
93
79
|
// If it is not buildable, then leave it to other plugins/project.json to set the project type.
|
|
@@ -96,38 +82,40 @@ const createNodesV2 = [
|
|
|
96
82
|
}
|
|
97
83
|
return {
|
|
98
84
|
projects: {
|
|
99
|
-
[projectRoot]: project
|
|
100
|
-
}
|
|
85
|
+
[projectRoot]: project,
|
|
86
|
+
},
|
|
101
87
|
};
|
|
102
88
|
}, validConfigFiles, options, context);
|
|
103
|
-
}
|
|
89
|
+
}
|
|
90
|
+
finally {
|
|
104
91
|
writeTargetsToCache(cachePath, targetsCache);
|
|
105
92
|
}
|
|
106
|
-
}
|
|
93
|
+
},
|
|
107
94
|
];
|
|
108
|
-
|
|
95
|
+
exports.createNodes = [
|
|
109
96
|
viteVitestConfigGlob,
|
|
110
|
-
async (configFilePath, options, context)=>{
|
|
111
|
-
|
|
112
|
-
const projectRoot = (0,
|
|
97
|
+
async (configFilePath, options, context) => {
|
|
98
|
+
devkit_1.logger.warn('`createNodes` is deprecated. Update your plugin to utilize createNodesV2 instead. In Nx 20, this will change to the createNodesV2 API.');
|
|
99
|
+
const projectRoot = (0, path_1.dirname)(configFilePath);
|
|
113
100
|
// Do not create a project if package.json and project.json isn't there.
|
|
114
|
-
const siblingFiles = (0,
|
|
115
|
-
if (!siblingFiles.includes('package.json') &&
|
|
101
|
+
const siblingFiles = (0, fs_1.readdirSync)((0, path_1.join)(context.workspaceRoot, projectRoot));
|
|
102
|
+
if (!siblingFiles.includes('package.json') &&
|
|
103
|
+
!siblingFiles.includes('project.json')) {
|
|
116
104
|
return {};
|
|
117
105
|
}
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
const hasReactRouterConfig = siblingFiles.some((configFile)=>{
|
|
106
|
+
const tsConfigFiles = siblingFiles.filter((p) => picomatch('tsconfig*{.json,.*.json}')(p)) ??
|
|
107
|
+
[];
|
|
108
|
+
const hasReactRouterConfig = siblingFiles.some((configFile) => {
|
|
121
109
|
const parts = configFile.split('.');
|
|
122
|
-
return parts[0] === 'react-router' && parts[1] === 'config' && parts.length > 2;
|
|
110
|
+
return (parts[0] === 'react-router' && parts[1] === 'config' && parts.length > 2);
|
|
123
111
|
});
|
|
124
112
|
const normalizedOptions = normalizeOptions(options);
|
|
125
|
-
const isUsingTsSolutionSetup = (0,
|
|
113
|
+
const isUsingTsSolutionSetup = (0, ts_solution_setup_1.isUsingTsSolutionSetup)();
|
|
126
114
|
const { projectType, metadata, targets } = await buildViteTargets(configFilePath, projectRoot, normalizedOptions, tsConfigFiles, hasReactRouterConfig, isUsingTsSolutionSetup, context);
|
|
127
115
|
const project = {
|
|
128
116
|
root: projectRoot,
|
|
129
117
|
targets,
|
|
130
|
-
metadata
|
|
118
|
+
metadata,
|
|
131
119
|
};
|
|
132
120
|
// If project is buildable, then the project type.
|
|
133
121
|
// If it is not buildable, then leave it to other plugins/project.json to set the project type.
|
|
@@ -136,29 +124,29 @@ const createNodes = [
|
|
|
136
124
|
}
|
|
137
125
|
return {
|
|
138
126
|
projects: {
|
|
139
|
-
[projectRoot]: project
|
|
140
|
-
}
|
|
127
|
+
[projectRoot]: project,
|
|
128
|
+
},
|
|
141
129
|
};
|
|
142
|
-
}
|
|
130
|
+
},
|
|
143
131
|
];
|
|
144
132
|
async function buildViteTargets(configFilePath, projectRoot, options, tsConfigFiles, hasReactRouterConfig, isUsingTsSolutionSetup, context) {
|
|
145
|
-
|
|
146
|
-
const absoluteConfigFilePath = (0, _devkit.joinPathFragments)(context.workspaceRoot, configFilePath);
|
|
133
|
+
const absoluteConfigFilePath = (0, devkit_1.joinPathFragments)(context.workspaceRoot, configFilePath);
|
|
147
134
|
// Workaround for the `build$3 is not a function` error that we sometimes see in agents.
|
|
148
135
|
// This should be removed later once we address the issue properly
|
|
149
136
|
try {
|
|
150
|
-
const importEsbuild = ()=>new Function('return import("esbuild")')();
|
|
137
|
+
const importEsbuild = () => new Function('return import("esbuild")')();
|
|
151
138
|
await importEsbuild();
|
|
152
|
-
} catch (e) {
|
|
153
|
-
// do nothing
|
|
154
139
|
}
|
|
155
|
-
|
|
140
|
+
catch {
|
|
141
|
+
// do nothing
|
|
142
|
+
}
|
|
143
|
+
const { resolveConfig } = await (0, executor_utils_1.loadViteDynamicImport)();
|
|
156
144
|
const viteBuildConfig = await resolveConfig({
|
|
157
145
|
configFile: absoluteConfigFilePath,
|
|
158
|
-
mode: 'development'
|
|
146
|
+
mode: 'development',
|
|
159
147
|
}, 'build');
|
|
160
148
|
const { buildOutputs, testOutputs, hasTest, isBuildable, hasServeConfig } = getOutputs(viteBuildConfig, projectRoot, context.workspaceRoot);
|
|
161
|
-
const namedInputs = (0,
|
|
149
|
+
const namedInputs = (0, get_named_inputs_1.getNamedInputs)(projectRoot, context);
|
|
162
150
|
const targets = {};
|
|
163
151
|
// if file is vitest.config or vite.config has definition for test, create target for test
|
|
164
152
|
if (configFilePath.includes('vitest.config') || hasTest) {
|
|
@@ -166,148 +154,112 @@ async function buildViteTargets(configFilePath, projectRoot, options, tsConfigFi
|
|
|
166
154
|
}
|
|
167
155
|
if (hasReactRouterConfig) {
|
|
168
156
|
// If we have a react-router config, we can skip the rest of the targets
|
|
169
|
-
return {
|
|
170
|
-
targets,
|
|
171
|
-
metadata: {},
|
|
172
|
-
projectType: 'application'
|
|
173
|
-
};
|
|
157
|
+
return { targets, metadata: {}, projectType: 'application' };
|
|
174
158
|
}
|
|
175
159
|
// If file is not vitest.config and buildable, create targets for build, serve, preview and serve-static
|
|
176
|
-
const hasRemixPlugin = viteBuildConfig.plugins &&
|
|
177
|
-
|
|
178
|
-
|
|
160
|
+
const hasRemixPlugin = viteBuildConfig.plugins &&
|
|
161
|
+
viteBuildConfig.plugins.some((p) => p.name === 'remix');
|
|
162
|
+
if (!configFilePath.includes('vitest.config') &&
|
|
163
|
+
!hasRemixPlugin &&
|
|
164
|
+
isBuildable) {
|
|
179
165
|
targets[options.buildTargetName] = await buildTarget(options.buildTargetName, namedInputs, buildOutputs, projectRoot, isUsingTsSolutionSetup);
|
|
180
166
|
// If running in library mode, then there is nothing to serve.
|
|
181
|
-
if (!
|
|
167
|
+
if (!viteBuildConfig.build?.lib || hasServeConfig) {
|
|
182
168
|
const devTarget = serveTarget(projectRoot, isUsingTsSolutionSetup);
|
|
183
|
-
targets[options.serveTargetName] =
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
169
|
+
targets[options.serveTargetName] = {
|
|
170
|
+
...devTarget,
|
|
171
|
+
metadata: {
|
|
172
|
+
...devTarget.metadata,
|
|
173
|
+
deprecated: 'Use devTargetName instead. This option will be removed in Nx 22.',
|
|
174
|
+
},
|
|
175
|
+
};
|
|
188
176
|
targets[options.devTargetName] = devTarget;
|
|
189
177
|
targets[options.previewTargetName] = previewTarget(projectRoot, options.buildTargetName);
|
|
190
178
|
targets[options.serveStaticTargetName] = serveStaticTarget(options, isUsingTsSolutionSetup);
|
|
191
179
|
}
|
|
192
180
|
}
|
|
193
181
|
if (tsConfigFiles.length) {
|
|
194
|
-
|
|
195
|
-
var _find;
|
|
196
|
-
const tsConfigToUse = (_find = [
|
|
197
|
-
'tsconfig.app.json',
|
|
198
|
-
'tsconfig.lib.json',
|
|
199
|
-
'tsconfig.json'
|
|
200
|
-
].find((t)=>tsConfigFiles.includes(t))) != null ? _find : tsConfigFiles[0];
|
|
182
|
+
const tsConfigToUse = ['tsconfig.app.json', 'tsconfig.lib.json', 'tsconfig.json'].find((t) => tsConfigFiles.includes(t)) ?? tsConfigFiles[0];
|
|
201
183
|
// Check if the project uses Vue plugin
|
|
202
|
-
const hasVuePlugin =
|
|
184
|
+
const hasVuePlugin = viteBuildConfig.plugins?.some((p) => p.name === 'vite:vue');
|
|
203
185
|
const typeCheckCommand = hasVuePlugin ? 'vue-tsc' : 'tsc';
|
|
204
186
|
targets[options.typecheckTargetName] = {
|
|
205
187
|
cache: true,
|
|
206
188
|
inputs: [
|
|
207
|
-
...'production' in namedInputs
|
|
208
|
-
'production',
|
|
209
|
-
'^
|
|
210
|
-
] : [
|
|
211
|
-
'default',
|
|
212
|
-
'^default'
|
|
213
|
-
],
|
|
189
|
+
...('production' in namedInputs
|
|
190
|
+
? ['production', '^production']
|
|
191
|
+
: ['default', '^default']),
|
|
214
192
|
{
|
|
215
|
-
externalDependencies: hasVuePlugin
|
|
216
|
-
'vue-tsc',
|
|
217
|
-
'typescript'
|
|
218
|
-
|
|
219
|
-
'typescript'
|
|
220
|
-
]
|
|
221
|
-
}
|
|
193
|
+
externalDependencies: hasVuePlugin
|
|
194
|
+
? ['vue-tsc', 'typescript']
|
|
195
|
+
: ['typescript'],
|
|
196
|
+
},
|
|
222
197
|
],
|
|
223
|
-
command: isUsingTsSolutionSetup
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
},
|
|
198
|
+
command: isUsingTsSolutionSetup
|
|
199
|
+
? `${typeCheckCommand} --build --emitDeclarationOnly`
|
|
200
|
+
: `${typeCheckCommand} --noEmit -p ${tsConfigToUse}`,
|
|
201
|
+
options: { cwd: (0, devkit_1.joinPathFragments)(projectRoot) },
|
|
227
202
|
metadata: {
|
|
228
203
|
description: `Runs type-checking for the project.`,
|
|
229
|
-
technologies: hasVuePlugin ? [
|
|
230
|
-
'typescript',
|
|
231
|
-
'vue'
|
|
232
|
-
] : [
|
|
233
|
-
'typescript'
|
|
234
|
-
],
|
|
204
|
+
technologies: hasVuePlugin ? ['typescript', 'vue'] : ['typescript'],
|
|
235
205
|
help: {
|
|
236
|
-
command: isUsingTsSolutionSetup
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
]
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
}
|
|
245
|
-
}
|
|
246
|
-
}
|
|
247
|
-
}
|
|
206
|
+
command: isUsingTsSolutionSetup
|
|
207
|
+
? `${pmc.exec} ${typeCheckCommand} --build --help`
|
|
208
|
+
: `${pmc.exec} ${typeCheckCommand} -p ${tsConfigToUse} --help`,
|
|
209
|
+
example: isUsingTsSolutionSetup
|
|
210
|
+
? { args: ['--force'] }
|
|
211
|
+
: { options: { noEmit: true } },
|
|
212
|
+
},
|
|
213
|
+
},
|
|
248
214
|
};
|
|
249
215
|
if (isUsingTsSolutionSetup) {
|
|
250
216
|
targets[options.typecheckTargetName].dependsOn = [
|
|
251
|
-
`^${options.typecheckTargetName}
|
|
217
|
+
`^${options.typecheckTargetName}`,
|
|
252
218
|
];
|
|
253
219
|
targets[options.typecheckTargetName].syncGenerators = [
|
|
254
|
-
'@nx/js:typescript-sync'
|
|
220
|
+
'@nx/js:typescript-sync',
|
|
255
221
|
];
|
|
256
222
|
}
|
|
257
223
|
}
|
|
258
|
-
(0,
|
|
224
|
+
(0, util_1.addBuildAndWatchDepsTargets)(context.workspaceRoot, projectRoot, targets, options, pmc);
|
|
259
225
|
const metadata = {};
|
|
260
226
|
return {
|
|
261
227
|
targets,
|
|
262
228
|
metadata,
|
|
263
|
-
projectType:
|
|
229
|
+
projectType: viteBuildConfig.build?.lib ? 'library' : 'application',
|
|
264
230
|
};
|
|
265
231
|
}
|
|
266
232
|
async function buildTarget(buildTargetName, namedInputs, outputs, projectRoot, isUsingTsSolutionSetup) {
|
|
267
233
|
const buildTarget = {
|
|
268
234
|
command: `vite build`,
|
|
269
|
-
options: {
|
|
270
|
-
cwd: (0, _devkit.joinPathFragments)(projectRoot)
|
|
271
|
-
},
|
|
235
|
+
options: { cwd: (0, devkit_1.joinPathFragments)(projectRoot) },
|
|
272
236
|
cache: true,
|
|
273
|
-
dependsOn: [
|
|
274
|
-
`^${buildTargetName}`
|
|
275
|
-
],
|
|
237
|
+
dependsOn: [`^${buildTargetName}`],
|
|
276
238
|
inputs: [
|
|
277
|
-
...'production' in namedInputs
|
|
278
|
-
'production',
|
|
279
|
-
'^
|
|
280
|
-
] : [
|
|
281
|
-
'default',
|
|
282
|
-
'^default'
|
|
283
|
-
],
|
|
239
|
+
...('production' in namedInputs
|
|
240
|
+
? ['production', '^production']
|
|
241
|
+
: ['default', '^default']),
|
|
284
242
|
{
|
|
285
|
-
externalDependencies: [
|
|
286
|
-
|
|
287
|
-
]
|
|
288
|
-
}
|
|
243
|
+
externalDependencies: ['vite'],
|
|
244
|
+
},
|
|
289
245
|
],
|
|
290
246
|
outputs,
|
|
291
247
|
metadata: {
|
|
292
|
-
technologies: [
|
|
293
|
-
'vite'
|
|
294
|
-
],
|
|
248
|
+
technologies: ['vite'],
|
|
295
249
|
description: `Run Vite build`,
|
|
296
250
|
help: {
|
|
297
251
|
command: `${pmc.exec} vite build --help`,
|
|
298
252
|
example: {
|
|
299
253
|
options: {
|
|
300
254
|
sourcemap: true,
|
|
301
|
-
manifest: 'manifest.json'
|
|
302
|
-
}
|
|
303
|
-
}
|
|
304
|
-
}
|
|
305
|
-
}
|
|
255
|
+
manifest: 'manifest.json',
|
|
256
|
+
},
|
|
257
|
+
},
|
|
258
|
+
},
|
|
259
|
+
},
|
|
306
260
|
};
|
|
307
261
|
if (isUsingTsSolutionSetup) {
|
|
308
|
-
buildTarget.syncGenerators = [
|
|
309
|
-
'@nx/js:typescript-sync'
|
|
310
|
-
];
|
|
262
|
+
buildTarget.syncGenerators = ['@nx/js:typescript-sync'];
|
|
311
263
|
}
|
|
312
264
|
return buildTarget;
|
|
313
265
|
}
|
|
@@ -316,27 +268,23 @@ function serveTarget(projectRoot, isUsingTsSolutionSetup) {
|
|
|
316
268
|
continuous: true,
|
|
317
269
|
command: `vite`,
|
|
318
270
|
options: {
|
|
319
|
-
cwd: (0,
|
|
271
|
+
cwd: (0, devkit_1.joinPathFragments)(projectRoot),
|
|
320
272
|
},
|
|
321
273
|
metadata: {
|
|
322
|
-
technologies: [
|
|
323
|
-
'vite'
|
|
324
|
-
],
|
|
274
|
+
technologies: ['vite'],
|
|
325
275
|
description: `Starts Vite dev server`,
|
|
326
276
|
help: {
|
|
327
277
|
command: `${pmc.exec} vite --help`,
|
|
328
278
|
example: {
|
|
329
279
|
options: {
|
|
330
|
-
port: 3000
|
|
331
|
-
}
|
|
332
|
-
}
|
|
333
|
-
}
|
|
334
|
-
}
|
|
280
|
+
port: 3000,
|
|
281
|
+
},
|
|
282
|
+
},
|
|
283
|
+
},
|
|
284
|
+
},
|
|
335
285
|
};
|
|
336
286
|
if (isUsingTsSolutionSetup) {
|
|
337
|
-
targetConfig.syncGenerators = [
|
|
338
|
-
'@nx/js:typescript-sync'
|
|
339
|
-
];
|
|
287
|
+
targetConfig.syncGenerators = ['@nx/js:typescript-sync'];
|
|
340
288
|
}
|
|
341
289
|
return targetConfig;
|
|
342
290
|
}
|
|
@@ -344,69 +292,53 @@ function previewTarget(projectRoot, buildTargetName) {
|
|
|
344
292
|
const targetConfig = {
|
|
345
293
|
continuous: true,
|
|
346
294
|
command: `vite preview`,
|
|
347
|
-
dependsOn: [
|
|
348
|
-
buildTargetName
|
|
349
|
-
],
|
|
295
|
+
dependsOn: [buildTargetName],
|
|
350
296
|
options: {
|
|
351
|
-
cwd: (0,
|
|
297
|
+
cwd: (0, devkit_1.joinPathFragments)(projectRoot),
|
|
352
298
|
},
|
|
353
299
|
metadata: {
|
|
354
|
-
technologies: [
|
|
355
|
-
'vite'
|
|
356
|
-
],
|
|
300
|
+
technologies: ['vite'],
|
|
357
301
|
description: `Locally preview Vite production build`,
|
|
358
302
|
help: {
|
|
359
303
|
command: `${pmc.exec} vite preview --help`,
|
|
360
304
|
example: {
|
|
361
305
|
options: {
|
|
362
|
-
port: 3000
|
|
363
|
-
}
|
|
364
|
-
}
|
|
365
|
-
}
|
|
366
|
-
}
|
|
306
|
+
port: 3000,
|
|
307
|
+
},
|
|
308
|
+
},
|
|
309
|
+
},
|
|
310
|
+
},
|
|
367
311
|
};
|
|
368
312
|
return targetConfig;
|
|
369
313
|
}
|
|
370
314
|
async function testTarget(namedInputs, outputs, projectRoot) {
|
|
371
315
|
return {
|
|
372
316
|
command: `vitest`,
|
|
373
|
-
options: {
|
|
374
|
-
cwd: (0, _devkit.joinPathFragments)(projectRoot)
|
|
375
|
-
},
|
|
317
|
+
options: { cwd: (0, devkit_1.joinPathFragments)(projectRoot) },
|
|
376
318
|
cache: true,
|
|
377
319
|
inputs: [
|
|
378
|
-
...'production' in namedInputs
|
|
379
|
-
'default',
|
|
380
|
-
'^
|
|
381
|
-
] : [
|
|
382
|
-
'default',
|
|
383
|
-
'^default'
|
|
384
|
-
],
|
|
320
|
+
...('production' in namedInputs
|
|
321
|
+
? ['default', '^production']
|
|
322
|
+
: ['default', '^default']),
|
|
385
323
|
{
|
|
386
|
-
externalDependencies: [
|
|
387
|
-
'vitest'
|
|
388
|
-
]
|
|
324
|
+
externalDependencies: ['vitest'],
|
|
389
325
|
},
|
|
390
|
-
{
|
|
391
|
-
env: 'CI'
|
|
392
|
-
}
|
|
326
|
+
{ env: 'CI' },
|
|
393
327
|
],
|
|
394
328
|
outputs,
|
|
395
329
|
metadata: {
|
|
396
|
-
technologies: [
|
|
397
|
-
'vite'
|
|
398
|
-
],
|
|
330
|
+
technologies: ['vite'],
|
|
399
331
|
description: `Run Vite tests`,
|
|
400
332
|
help: {
|
|
401
333
|
command: `${pmc.exec} vitest --help`,
|
|
402
334
|
example: {
|
|
403
335
|
options: {
|
|
404
336
|
bail: 1,
|
|
405
|
-
coverage: true
|
|
406
|
-
}
|
|
407
|
-
}
|
|
408
|
-
}
|
|
409
|
-
}
|
|
337
|
+
coverage: true,
|
|
338
|
+
},
|
|
339
|
+
},
|
|
340
|
+
},
|
|
341
|
+
},
|
|
410
342
|
};
|
|
411
343
|
}
|
|
412
344
|
function serveStaticTarget(options, isUsingTsSolutionSetup) {
|
|
@@ -415,80 +347,70 @@ function serveStaticTarget(options, isUsingTsSolutionSetup) {
|
|
|
415
347
|
executor: '@nx/web:file-server',
|
|
416
348
|
options: {
|
|
417
349
|
buildTarget: `${options.buildTargetName}`,
|
|
418
|
-
spa: true
|
|
419
|
-
}
|
|
350
|
+
spa: true,
|
|
351
|
+
},
|
|
420
352
|
};
|
|
421
353
|
if (isUsingTsSolutionSetup) {
|
|
422
|
-
targetConfig.syncGenerators = [
|
|
423
|
-
'@nx/js:typescript-sync'
|
|
424
|
-
];
|
|
354
|
+
targetConfig.syncGenerators = ['@nx/js:typescript-sync'];
|
|
425
355
|
}
|
|
426
356
|
return targetConfig;
|
|
427
357
|
}
|
|
428
358
|
function getOutputs(viteBuildConfig, projectRoot, workspaceRoot) {
|
|
429
|
-
var _build_rollupOptions, _test_coverage;
|
|
430
359
|
const { build, test, server } = viteBuildConfig;
|
|
431
|
-
const buildOutputPath = normalizeOutputPath(build
|
|
432
|
-
const isBuildable =
|
|
360
|
+
const buildOutputPath = normalizeOutputPath(build?.outDir, projectRoot, workspaceRoot, 'dist');
|
|
361
|
+
const isBuildable = build?.lib ||
|
|
362
|
+
build?.rollupOptions?.input ||
|
|
363
|
+
(0, fs_1.existsSync)((0, path_1.join)(workspaceRoot, projectRoot, 'index.html'));
|
|
433
364
|
const hasServeConfig = Boolean(server);
|
|
434
|
-
const reportsDirectoryPath = normalizeOutputPath(test
|
|
365
|
+
const reportsDirectoryPath = normalizeOutputPath(test?.coverage?.reportsDirectory, projectRoot, workspaceRoot, 'coverage');
|
|
435
366
|
return {
|
|
436
|
-
buildOutputs: [
|
|
437
|
-
|
|
438
|
-
],
|
|
439
|
-
testOutputs: [
|
|
440
|
-
reportsDirectoryPath
|
|
441
|
-
],
|
|
367
|
+
buildOutputs: [buildOutputPath],
|
|
368
|
+
testOutputs: [reportsDirectoryPath],
|
|
442
369
|
hasTest: !!test,
|
|
443
370
|
isBuildable,
|
|
444
|
-
hasServeConfig
|
|
371
|
+
hasServeConfig,
|
|
445
372
|
};
|
|
446
373
|
}
|
|
447
374
|
function normalizeOutputPath(outputPath, projectRoot, workspaceRoot, path) {
|
|
448
375
|
if (!outputPath) {
|
|
449
376
|
if (projectRoot === '.') {
|
|
450
377
|
return `{projectRoot}/${path}`;
|
|
451
|
-
}
|
|
378
|
+
}
|
|
379
|
+
else {
|
|
452
380
|
return `{workspaceRoot}/${path}/{projectRoot}`;
|
|
453
381
|
}
|
|
454
|
-
}
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
382
|
+
}
|
|
383
|
+
else {
|
|
384
|
+
if ((0, path_1.isAbsolute)(outputPath)) {
|
|
385
|
+
return `{workspaceRoot}/${(0, path_1.relative)(workspaceRoot, outputPath)}`;
|
|
386
|
+
}
|
|
387
|
+
else {
|
|
458
388
|
if (outputPath.startsWith('..')) {
|
|
459
|
-
return (0,
|
|
460
|
-
}
|
|
461
|
-
|
|
389
|
+
return (0, path_1.join)('{workspaceRoot}', (0, path_1.join)(projectRoot, outputPath));
|
|
390
|
+
}
|
|
391
|
+
else {
|
|
392
|
+
return (0, path_1.join)('{projectRoot}', outputPath);
|
|
462
393
|
}
|
|
463
394
|
}
|
|
464
395
|
}
|
|
465
396
|
}
|
|
466
397
|
function normalizeOptions(options) {
|
|
467
|
-
|
|
468
|
-
options
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
var _previewTargetName;
|
|
476
|
-
(_previewTargetName = (_options3 = options).previewTargetName) != null ? _previewTargetName : _options3.previewTargetName = 'preview';
|
|
477
|
-
var _testTargetName;
|
|
478
|
-
(_testTargetName = (_options4 = options).testTargetName) != null ? _testTargetName : _options4.testTargetName = 'test';
|
|
479
|
-
var _serveStaticTargetName;
|
|
480
|
-
(_serveStaticTargetName = (_options5 = options).serveStaticTargetName) != null ? _serveStaticTargetName : _options5.serveStaticTargetName = 'serve-static';
|
|
481
|
-
var _typecheckTargetName;
|
|
482
|
-
(_typecheckTargetName = (_options6 = options).typecheckTargetName) != null ? _typecheckTargetName : _options6.typecheckTargetName = 'typecheck';
|
|
398
|
+
options ??= {};
|
|
399
|
+
options.buildTargetName ??= 'build';
|
|
400
|
+
options.serveTargetName ??= 'serve';
|
|
401
|
+
options.devTargetName ??= 'dev';
|
|
402
|
+
options.previewTargetName ??= 'preview';
|
|
403
|
+
options.testTargetName ??= 'test';
|
|
404
|
+
options.serveStaticTargetName ??= 'serve-static';
|
|
405
|
+
options.typecheckTargetName ??= 'typecheck';
|
|
483
406
|
return options;
|
|
484
407
|
}
|
|
485
408
|
function checkIfConfigFileShouldBeProject(projectRoot, context) {
|
|
486
409
|
// Do not create a project if package.json and project.json isn't there.
|
|
487
|
-
const siblingFiles = (0,
|
|
488
|
-
if (!siblingFiles.includes('package.json') &&
|
|
410
|
+
const siblingFiles = (0, fs_1.readdirSync)((0, path_1.join)(context.workspaceRoot, projectRoot));
|
|
411
|
+
if (!siblingFiles.includes('package.json') &&
|
|
412
|
+
!siblingFiles.includes('project.json')) {
|
|
489
413
|
return false;
|
|
490
414
|
}
|
|
491
415
|
return true;
|
|
492
416
|
}
|
|
493
|
-
|
|
494
|
-
//# sourceMappingURL=plugin.js.map
|