@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
|
@@ -1,63 +1,26 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
},
|
|
21
|
-
createOrEditViteConfig: function() {
|
|
22
|
-
return createOrEditViteConfig;
|
|
23
|
-
},
|
|
24
|
-
deleteWebpackConfig: function() {
|
|
25
|
-
return deleteWebpackConfig;
|
|
26
|
-
},
|
|
27
|
-
editTsConfig: function() {
|
|
28
|
-
return editTsConfig;
|
|
29
|
-
},
|
|
30
|
-
findExistingJsBuildTargetInProject: function() {
|
|
31
|
-
return findExistingJsBuildTargetInProject;
|
|
32
|
-
},
|
|
33
|
-
getViteConfigPathForProject: function() {
|
|
34
|
-
return getViteConfigPathForProject;
|
|
35
|
-
},
|
|
36
|
-
handleUnknownConfiguration: function() {
|
|
37
|
-
return handleUnknownConfiguration;
|
|
38
|
-
},
|
|
39
|
-
handleUnsupportedUserProvidedTargets: function() {
|
|
40
|
-
return handleUnsupportedUserProvidedTargets;
|
|
41
|
-
},
|
|
42
|
-
moveAndEditIndexHtml: function() {
|
|
43
|
-
return moveAndEditIndexHtml;
|
|
44
|
-
},
|
|
45
|
-
normalizeViteConfigFilePathWithTree: function() {
|
|
46
|
-
return normalizeViteConfigFilePathWithTree;
|
|
47
|
-
}
|
|
48
|
-
});
|
|
49
|
-
const _devkit = require("@nx/devkit");
|
|
50
|
-
const _targetdefaultsutils = require("@nx/devkit/src/generators/target-defaults-utils");
|
|
51
|
-
const _tssolutionsetup = require("@nx/js/src/utils/typescript/ts-solution-setup");
|
|
52
|
-
const _viteconfigeditutils = require("./vite-config-edit-utils");
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.findExistingJsBuildTargetInProject = findExistingJsBuildTargetInProject;
|
|
4
|
+
exports.addOrChangeTestTarget = addOrChangeTestTarget;
|
|
5
|
+
exports.addBuildTarget = addBuildTarget;
|
|
6
|
+
exports.addServeTarget = addServeTarget;
|
|
7
|
+
exports.addPreviewTarget = addPreviewTarget;
|
|
8
|
+
exports.editTsConfig = editTsConfig;
|
|
9
|
+
exports.deleteWebpackConfig = deleteWebpackConfig;
|
|
10
|
+
exports.moveAndEditIndexHtml = moveAndEditIndexHtml;
|
|
11
|
+
exports.createOrEditViteConfig = createOrEditViteConfig;
|
|
12
|
+
exports.normalizeViteConfigFilePathWithTree = normalizeViteConfigFilePathWithTree;
|
|
13
|
+
exports.getViteConfigPathForProject = getViteConfigPathForProject;
|
|
14
|
+
exports.handleUnsupportedUserProvidedTargets = handleUnsupportedUserProvidedTargets;
|
|
15
|
+
exports.handleUnknownConfiguration = handleUnknownConfiguration;
|
|
16
|
+
const devkit_1 = require("@nx/devkit");
|
|
17
|
+
const target_defaults_utils_1 = require("@nx/devkit/src/generators/target-defaults-utils");
|
|
18
|
+
const ts_solution_setup_1 = require("@nx/js/src/utils/typescript/ts-solution-setup");
|
|
19
|
+
const vite_config_edit_utils_1 = require("./vite-config-edit-utils");
|
|
53
20
|
function findExistingJsBuildTargetInProject(targets) {
|
|
54
21
|
const output = {};
|
|
55
22
|
const supportedExecutors = {
|
|
56
|
-
build: [
|
|
57
|
-
'@nx/js:babel',
|
|
58
|
-
'@nx/js:swc',
|
|
59
|
-
'@nx/rollup:rollup'
|
|
60
|
-
]
|
|
23
|
+
build: ['@nx/js:babel', '@nx/js:swc', '@nx/rollup:rollup'],
|
|
61
24
|
};
|
|
62
25
|
const unsupportedExecutors = [
|
|
63
26
|
'@nx/angular:ng-packagr-lite',
|
|
@@ -86,158 +49,154 @@ function findExistingJsBuildTargetInProject(targets) {
|
|
|
86
49
|
'@nrwl/js:tsc',
|
|
87
50
|
'@angular-devkit/build-angular:browser',
|
|
88
51
|
'@angular-devkit/build-angular:browser-esbuild',
|
|
89
|
-
'@angular-devkit/build-angular:application'
|
|
52
|
+
'@angular-devkit/build-angular:application',
|
|
90
53
|
];
|
|
91
54
|
// We try to find the target that is using the supported executors
|
|
92
55
|
// for build since this is the one we will be converting
|
|
93
|
-
for(const target in targets){
|
|
56
|
+
for (const target in targets) {
|
|
94
57
|
const executorName = targets[target].executor;
|
|
95
58
|
if (supportedExecutors.build.includes(executorName)) {
|
|
96
59
|
output.supported = target;
|
|
97
|
-
}
|
|
60
|
+
}
|
|
61
|
+
else if (unsupportedExecutors.includes(executorName)) {
|
|
98
62
|
output.unsupported = target;
|
|
99
63
|
}
|
|
100
64
|
}
|
|
101
65
|
return output;
|
|
102
66
|
}
|
|
103
67
|
function addOrChangeTestTarget(tree, options, hasPlugin) {
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
68
|
+
const nxJson = (0, devkit_1.readNxJson)(tree);
|
|
69
|
+
hasPlugin = nxJson.plugins?.some((p) => typeof p === 'string'
|
|
70
|
+
? p === '@nx/vite/plugin'
|
|
71
|
+
: p.plugin === '@nx/vite/plugin' || hasPlugin);
|
|
108
72
|
if (hasPlugin) {
|
|
109
73
|
return;
|
|
110
74
|
}
|
|
111
|
-
const project = (0,
|
|
112
|
-
|
|
113
|
-
const
|
|
114
|
-
const reportsDirectory = (0, _devkit.joinPathFragments)((0, _devkit.offsetFromRoot)(project.root), 'coverage', project.root === '.' ? options.project : project.root);
|
|
75
|
+
const project = (0, devkit_1.readProjectConfiguration)(tree, options.project);
|
|
76
|
+
const target = options.testTarget ?? 'test';
|
|
77
|
+
const reportsDirectory = (0, devkit_1.joinPathFragments)((0, devkit_1.offsetFromRoot)(project.root), 'coverage', project.root === '.' ? options.project : project.root);
|
|
115
78
|
const testOptions = {
|
|
116
|
-
reportsDirectory
|
|
79
|
+
reportsDirectory,
|
|
117
80
|
};
|
|
118
|
-
|
|
119
|
-
(_targets = (_project = project).targets) != null ? _targets : _project.targets = {};
|
|
81
|
+
project.targets ??= {};
|
|
120
82
|
if (project.targets[target]) {
|
|
121
83
|
throw new Error(`Target "${target}" already exists in the project.`);
|
|
122
|
-
}
|
|
84
|
+
}
|
|
85
|
+
else {
|
|
123
86
|
project.targets[target] = {
|
|
124
87
|
executor: '@nx/vite:test',
|
|
125
|
-
outputs: [
|
|
126
|
-
|
|
127
|
-
],
|
|
128
|
-
options: testOptions
|
|
88
|
+
outputs: ['{options.reportsDirectory}'],
|
|
89
|
+
options: testOptions,
|
|
129
90
|
};
|
|
130
91
|
}
|
|
131
|
-
(0,
|
|
92
|
+
(0, devkit_1.updateProjectConfiguration)(tree, options.project, project);
|
|
132
93
|
}
|
|
133
94
|
function addBuildTarget(tree, options, target) {
|
|
134
|
-
|
|
135
|
-
(0,
|
|
136
|
-
const
|
|
137
|
-
const isTsSolutionSetup = (0, _tssolutionsetup.isUsingTsSolutionSetup)(tree);
|
|
95
|
+
(0, target_defaults_utils_1.addBuildTargetDefaults)(tree, '@nx/vite:build');
|
|
96
|
+
const project = (0, devkit_1.readProjectConfiguration)(tree, options.project);
|
|
97
|
+
const isTsSolutionSetup = (0, ts_solution_setup_1.isUsingTsSolutionSetup)(tree);
|
|
138
98
|
const buildOptions = {
|
|
139
|
-
outputPath: isTsSolutionSetup
|
|
99
|
+
outputPath: isTsSolutionSetup
|
|
100
|
+
? (0, devkit_1.joinPathFragments)(project.root, 'dist')
|
|
101
|
+
: (0, devkit_1.joinPathFragments)('dist', project.root != '.' ? project.root : options.project),
|
|
140
102
|
};
|
|
141
|
-
|
|
142
|
-
(_targets = (_project = project).targets) != null ? _targets : _project.targets = {};
|
|
103
|
+
project.targets ??= {};
|
|
143
104
|
project.targets[target] = {
|
|
144
105
|
executor: '@nx/vite:build',
|
|
145
|
-
outputs: [
|
|
146
|
-
'{options.outputPath}'
|
|
147
|
-
],
|
|
106
|
+
outputs: ['{options.outputPath}'],
|
|
148
107
|
defaultConfiguration: 'production',
|
|
149
108
|
options: buildOptions,
|
|
150
109
|
configurations: {
|
|
151
110
|
development: {
|
|
152
|
-
mode: 'development'
|
|
111
|
+
mode: 'development',
|
|
153
112
|
},
|
|
154
113
|
production: {
|
|
155
|
-
mode: 'production'
|
|
156
|
-
}
|
|
157
|
-
}
|
|
114
|
+
mode: 'production',
|
|
115
|
+
},
|
|
116
|
+
},
|
|
158
117
|
};
|
|
159
|
-
(0,
|
|
118
|
+
(0, devkit_1.updateProjectConfiguration)(tree, options.project, project);
|
|
160
119
|
}
|
|
161
120
|
function addServeTarget(tree, options, target) {
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
var _targets;
|
|
165
|
-
(_targets = (_project = project).targets) != null ? _targets : _project.targets = {};
|
|
121
|
+
const project = (0, devkit_1.readProjectConfiguration)(tree, options.project);
|
|
122
|
+
project.targets ??= {};
|
|
166
123
|
project.targets[target] = {
|
|
167
124
|
executor: '@nx/vite:dev-server',
|
|
168
125
|
defaultConfiguration: 'development',
|
|
169
126
|
options: {
|
|
170
|
-
buildTarget: `${options.project}:build
|
|
127
|
+
buildTarget: `${options.project}:build`,
|
|
171
128
|
},
|
|
172
129
|
configurations: {
|
|
173
130
|
development: {
|
|
174
131
|
buildTarget: `${options.project}:build:development`,
|
|
175
|
-
hmr: true
|
|
132
|
+
hmr: true,
|
|
176
133
|
},
|
|
177
134
|
production: {
|
|
178
135
|
buildTarget: `${options.project}:build:production`,
|
|
179
|
-
hmr: false
|
|
180
|
-
}
|
|
181
|
-
}
|
|
136
|
+
hmr: false,
|
|
137
|
+
},
|
|
138
|
+
},
|
|
182
139
|
};
|
|
183
|
-
(0,
|
|
140
|
+
(0, devkit_1.updateProjectConfiguration)(tree, options.project, project);
|
|
184
141
|
}
|
|
142
|
+
/**
|
|
143
|
+
* Adds a target for the preview server.
|
|
144
|
+
*
|
|
145
|
+
* @param tree
|
|
146
|
+
* @param options
|
|
147
|
+
* @param serveTarget An existing serve target.
|
|
148
|
+
*/
|
|
185
149
|
function addPreviewTarget(tree, options, serveTarget) {
|
|
186
|
-
|
|
187
|
-
const project = (0, _devkit.readProjectConfiguration)(tree, options.project);
|
|
150
|
+
const project = (0, devkit_1.readProjectConfiguration)(tree, options.project);
|
|
188
151
|
const previewOptions = {
|
|
189
|
-
buildTarget: `${options.project}:build
|
|
152
|
+
buildTarget: `${options.project}:build`,
|
|
190
153
|
};
|
|
191
|
-
|
|
192
|
-
(_targets = (_project = project).targets) != null ? _targets : _project.targets = {};
|
|
154
|
+
project.targets ??= {};
|
|
193
155
|
// Update the options from the passed serve target.
|
|
194
156
|
if (project.targets[serveTarget]) {
|
|
195
|
-
var _target_options, _target_options1;
|
|
196
157
|
const target = project.targets[serveTarget];
|
|
197
158
|
if (target.executor === '@nxext/vite:dev') {
|
|
198
159
|
previewOptions.proxyConfig = target.options.proxyConfig;
|
|
199
160
|
}
|
|
200
|
-
previewOptions['https'] =
|
|
201
|
-
previewOptions['open'] =
|
|
161
|
+
previewOptions['https'] = target.options?.https;
|
|
162
|
+
previewOptions['open'] = target.options?.open;
|
|
202
163
|
}
|
|
203
164
|
// Adds a preview target.
|
|
204
165
|
project.targets.preview = {
|
|
205
|
-
dependsOn: [
|
|
206
|
-
'build'
|
|
207
|
-
],
|
|
166
|
+
dependsOn: ['build'],
|
|
208
167
|
executor: '@nx/vite:preview-server',
|
|
209
168
|
defaultConfiguration: 'development',
|
|
210
169
|
options: previewOptions,
|
|
211
170
|
configurations: {
|
|
212
171
|
development: {
|
|
213
|
-
buildTarget: `${options.project}:build:development
|
|
172
|
+
buildTarget: `${options.project}:build:development`,
|
|
214
173
|
},
|
|
215
174
|
production: {
|
|
216
|
-
buildTarget: `${options.project}:build:production
|
|
217
|
-
}
|
|
218
|
-
}
|
|
175
|
+
buildTarget: `${options.project}:build:production`,
|
|
176
|
+
},
|
|
177
|
+
},
|
|
219
178
|
};
|
|
220
|
-
(0,
|
|
179
|
+
(0, devkit_1.updateProjectConfiguration)(tree, options.project, project);
|
|
221
180
|
}
|
|
222
181
|
function editTsConfig(tree, options) {
|
|
223
|
-
const projectConfig = (0,
|
|
224
|
-
let tsconfigPath = (0,
|
|
225
|
-
const isTsSolutionSetup = (0,
|
|
182
|
+
const projectConfig = (0, devkit_1.readProjectConfiguration)(tree, options.project);
|
|
183
|
+
let tsconfigPath = (0, devkit_1.joinPathFragments)(projectConfig.root, 'tsconfig.json');
|
|
184
|
+
const isTsSolutionSetup = (0, ts_solution_setup_1.isUsingTsSolutionSetup)(tree);
|
|
226
185
|
if (isTsSolutionSetup) {
|
|
227
186
|
tsconfigPath = [
|
|
228
|
-
(0,
|
|
229
|
-
(0,
|
|
230
|
-
].find((p)=>tree.exists(p));
|
|
187
|
+
(0, devkit_1.joinPathFragments)(projectConfig.root, 'tsconfig.app.json'),
|
|
188
|
+
(0, devkit_1.joinPathFragments)(projectConfig.root, 'tsconfig.lib.json'),
|
|
189
|
+
].find((p) => tree.exists(p));
|
|
231
190
|
}
|
|
232
|
-
const config = (0,
|
|
233
|
-
switch(options.uiFramework){
|
|
191
|
+
const config = (0, devkit_1.readJson)(tree, tsconfigPath);
|
|
192
|
+
switch (options.uiFramework) {
|
|
234
193
|
case 'react':
|
|
235
194
|
config.compilerOptions = {
|
|
236
195
|
jsx: 'react-jsx',
|
|
237
196
|
allowJs: false,
|
|
238
197
|
esModuleInterop: false,
|
|
239
198
|
allowSyntheticDefaultImports: true,
|
|
240
|
-
strict: true
|
|
199
|
+
strict: true,
|
|
241
200
|
};
|
|
242
201
|
break;
|
|
243
202
|
case 'none':
|
|
@@ -249,29 +208,36 @@ function editTsConfig(tree, options) {
|
|
|
249
208
|
noImplicitOverride: true,
|
|
250
209
|
noPropertyAccessFromIndexSignature: true,
|
|
251
210
|
noImplicitReturns: true,
|
|
252
|
-
noFallthroughCasesInSwitch: true
|
|
211
|
+
noFallthroughCasesInSwitch: true,
|
|
253
212
|
};
|
|
254
213
|
}
|
|
255
214
|
break;
|
|
256
215
|
default:
|
|
257
216
|
break;
|
|
258
217
|
}
|
|
259
|
-
(0,
|
|
218
|
+
(0, devkit_1.writeJson)(tree, tsconfigPath, config);
|
|
260
219
|
}
|
|
261
220
|
function deleteWebpackConfig(tree, projectRoot, webpackConfigFilePath) {
|
|
262
|
-
const webpackConfigPath = webpackConfigFilePath && tree.exists(webpackConfigFilePath)
|
|
221
|
+
const webpackConfigPath = webpackConfigFilePath && tree.exists(webpackConfigFilePath)
|
|
222
|
+
? webpackConfigFilePath
|
|
223
|
+
: tree.exists(`${projectRoot}/webpack.config.js`)
|
|
224
|
+
? `${projectRoot}/webpack.config.js`
|
|
225
|
+
: tree.exists(`${projectRoot}/webpack.config.ts`)
|
|
226
|
+
? `${projectRoot}/webpack.config.ts`
|
|
227
|
+
: null;
|
|
263
228
|
if (webpackConfigPath) {
|
|
264
229
|
tree.delete(webpackConfigPath);
|
|
265
230
|
}
|
|
266
231
|
}
|
|
267
232
|
function moveAndEditIndexHtml(tree, options) {
|
|
268
|
-
const projectConfig = (0,
|
|
233
|
+
const projectConfig = (0, devkit_1.readProjectConfiguration)(tree, options.project);
|
|
269
234
|
let indexHtmlPath = `${projectConfig.root}/src/index.html`;
|
|
270
235
|
let mainPath = `${projectConfig.root}/src/main.ts${options.uiFramework === 'react' ? 'x' : ''}`;
|
|
271
236
|
if (projectConfig.root !== '.') {
|
|
272
237
|
mainPath = mainPath.replace(projectConfig.root, '');
|
|
273
238
|
}
|
|
274
|
-
if (!tree.exists(indexHtmlPath) &&
|
|
239
|
+
if (!tree.exists(indexHtmlPath) &&
|
|
240
|
+
tree.exists(`${projectConfig.root}/index.html`)) {
|
|
275
241
|
indexHtmlPath = `${projectConfig.root}/index.html`;
|
|
276
242
|
}
|
|
277
243
|
if (tree.exists(indexHtmlPath)) {
|
|
@@ -283,7 +249,8 @@ function moveAndEditIndexHtml(tree, options) {
|
|
|
283
249
|
tree.delete(`${projectConfig.root}/src/index.html`);
|
|
284
250
|
}
|
|
285
251
|
}
|
|
286
|
-
}
|
|
252
|
+
}
|
|
253
|
+
else {
|
|
287
254
|
tree.write(`${projectConfig.root}/index.html`, `<!DOCTYPE html>
|
|
288
255
|
<html lang='en'>
|
|
289
256
|
<head>
|
|
@@ -300,13 +267,21 @@ function moveAndEditIndexHtml(tree, options) {
|
|
|
300
267
|
}
|
|
301
268
|
}
|
|
302
269
|
function createOrEditViteConfig(tree, options, onlyVitest, projectAlreadyHasViteTargets, vitestFileName) {
|
|
303
|
-
const { root: projectRoot } = (0,
|
|
270
|
+
const { root: projectRoot } = (0, devkit_1.readProjectConfiguration)(tree, options.project);
|
|
304
271
|
const extension = options.useEsmExtension ? 'mts' : 'ts';
|
|
305
|
-
const viteConfigPath = vitestFileName
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
const
|
|
272
|
+
const viteConfigPath = vitestFileName
|
|
273
|
+
? `${projectRoot}/vitest.config.${extension}`
|
|
274
|
+
: `${projectRoot}/vite.config.${extension}`;
|
|
275
|
+
const isTsSolutionSetup = (0, ts_solution_setup_1.isUsingTsSolutionSetup)(tree);
|
|
276
|
+
const buildOutDir = isTsSolutionSetup
|
|
277
|
+
? './dist'
|
|
278
|
+
: projectRoot === '.'
|
|
279
|
+
? `./dist/${options.project}`
|
|
280
|
+
: `${(0, devkit_1.offsetFromRoot)(projectRoot)}dist/${projectRoot}`;
|
|
281
|
+
const buildOption = onlyVitest
|
|
282
|
+
? ''
|
|
283
|
+
: options.includeLib
|
|
284
|
+
? ` // Configuration for building your library.
|
|
310
285
|
// See: https://vitejs.dev/guide/build.html#library-mode
|
|
311
286
|
build: {
|
|
312
287
|
outDir: '${buildOutDir}',
|
|
@@ -326,9 +301,10 @@ function createOrEditViteConfig(tree, options, onlyVitest, projectAlreadyHasVite
|
|
|
326
301
|
},
|
|
327
302
|
rollupOptions: {
|
|
328
303
|
// External packages that should not be bundled into your library.
|
|
329
|
-
external: [${
|
|
304
|
+
external: [${options.rollupOptionsExternal ?? ''}]
|
|
330
305
|
},
|
|
331
|
-
},`
|
|
306
|
+
},`
|
|
307
|
+
: ` build: {
|
|
332
308
|
outDir: '${buildOutDir}',
|
|
333
309
|
emptyOutDir: true,
|
|
334
310
|
reportCompressedSize: true,
|
|
@@ -336,12 +312,8 @@ function createOrEditViteConfig(tree, options, onlyVitest, projectAlreadyHasVite
|
|
|
336
312
|
transformMixedEsModules: true,
|
|
337
313
|
},
|
|
338
314
|
},`;
|
|
339
|
-
const imports = options.imports ? [
|
|
340
|
-
|
|
341
|
-
] : [];
|
|
342
|
-
const plugins = options.plugins ? [
|
|
343
|
-
...options.plugins
|
|
344
|
-
] : [];
|
|
315
|
+
const imports = options.imports ? [...options.imports] : [];
|
|
316
|
+
const plugins = options.plugins ? [...options.plugins] : [];
|
|
345
317
|
if (!onlyVitest && options.includeLib) {
|
|
346
318
|
imports.push(`import dts from 'vite-plugin-dts'`, `import * as path from 'path'`);
|
|
347
319
|
}
|
|
@@ -352,41 +324,58 @@ function createOrEditViteConfig(tree, options, onlyVitest, projectAlreadyHasVite
|
|
|
352
324
|
if (!onlyVitest && options.includeLib) {
|
|
353
325
|
plugins.push(`dts({ entryRoot: 'src', tsconfigPath: path.join(__dirname, 'tsconfig.lib.json')${!isTsSolutionSetup ? ', pathsToAliases: false' : ''} })`);
|
|
354
326
|
}
|
|
355
|
-
const reportsDirectory = isTsSolutionSetup
|
|
356
|
-
|
|
357
|
-
|
|
327
|
+
const reportsDirectory = isTsSolutionSetup
|
|
328
|
+
? './test-output/vitest/coverage'
|
|
329
|
+
: projectRoot === '.'
|
|
330
|
+
? `./coverage/${options.project}`
|
|
331
|
+
: `${(0, devkit_1.offsetFromRoot)(projectRoot)}coverage/${projectRoot}`;
|
|
332
|
+
const testOption = options.includeVitest
|
|
333
|
+
? ` test: {
|
|
358
334
|
watch: false,
|
|
359
335
|
globals: true,
|
|
360
|
-
environment: '${
|
|
336
|
+
environment: '${options.testEnvironment ?? 'jsdom'}',
|
|
361
337
|
include: ['{src,tests}/**/*.{test,spec}.{js,mjs,cjs,ts,mts,cts,jsx,tsx}'],
|
|
362
338
|
${options.setupFile ? ` setupFiles: ['${options.setupFile}'],\n` : ''}\
|
|
363
|
-
${options.inSourceTests
|
|
339
|
+
${options.inSourceTests
|
|
340
|
+
? ` includeSource: ['src/**/*.{js,mjs,cjs,ts,mts,cts,jsx,tsx}'],\n`
|
|
341
|
+
: ''}\
|
|
364
342
|
reporters: ['default'],
|
|
365
343
|
coverage: {
|
|
366
344
|
reportsDirectory: '${reportsDirectory}',
|
|
367
|
-
provider: ${options.coverageProvider
|
|
345
|
+
provider: ${options.coverageProvider
|
|
346
|
+
? `'${options.coverageProvider}' as const`
|
|
347
|
+
: `'v8' as const`},
|
|
368
348
|
}
|
|
369
|
-
},`
|
|
370
|
-
|
|
349
|
+
},`
|
|
350
|
+
: '';
|
|
351
|
+
const defineOption = options.inSourceTests
|
|
352
|
+
? ` define: {
|
|
371
353
|
'import.meta.vitest': undefined
|
|
372
|
-
},`
|
|
373
|
-
|
|
374
|
-
const devServerOption = onlyVitest
|
|
375
|
-
|
|
354
|
+
},`
|
|
355
|
+
: '';
|
|
356
|
+
const devServerOption = onlyVitest
|
|
357
|
+
? ''
|
|
358
|
+
: options.includeLib
|
|
359
|
+
? ''
|
|
360
|
+
: ` server:{
|
|
361
|
+
port: ${options.port ?? 4200},
|
|
376
362
|
host: 'localhost',
|
|
377
363
|
},`;
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
364
|
+
const previewServerOption = onlyVitest
|
|
365
|
+
? ''
|
|
366
|
+
: options.includeLib
|
|
367
|
+
? ''
|
|
368
|
+
: ` preview:{
|
|
369
|
+
port: ${options.previewPort ?? 4300},
|
|
381
370
|
host: 'localhost',
|
|
382
371
|
},`;
|
|
383
372
|
const workerOption = ` // Uncomment this if you are using workers.
|
|
384
373
|
// worker: {
|
|
385
374
|
// plugins: [ nxViteTsPaths() ],
|
|
386
375
|
// },`;
|
|
387
|
-
const cacheDir = `cacheDir: '${normalizedJoinPaths((0,
|
|
376
|
+
const cacheDir = `cacheDir: '${normalizedJoinPaths((0, devkit_1.offsetFromRoot)(projectRoot), 'node_modules', '.vite', projectRoot === '.' ? options.project : projectRoot)}',`;
|
|
388
377
|
if (tree.exists(viteConfigPath)) {
|
|
389
|
-
handleViteConfigFileExists(tree, viteConfigPath, options, buildOption, buildOutDir, imports, plugins, testOption, reportsDirectory, cacheDir, projectRoot, (0,
|
|
378
|
+
handleViteConfigFileExists(tree, viteConfigPath, options, buildOption, buildOutDir, imports, plugins, testOption, reportsDirectory, cacheDir, projectRoot, (0, devkit_1.offsetFromRoot)(projectRoot), projectAlreadyHasViteTargets);
|
|
390
379
|
return;
|
|
391
380
|
}
|
|
392
381
|
const viteConfigContent = `/// <reference types='vitest' />
|
|
@@ -404,18 +393,24 @@ function printOptions(...options) {
|
|
|
404
393
|
return options.filter(Boolean).join('\n');
|
|
405
394
|
}
|
|
406
395
|
function normalizeViteConfigFilePathWithTree(tree, projectRoot, configFile) {
|
|
407
|
-
return configFile && tree.exists(configFile)
|
|
396
|
+
return configFile && tree.exists(configFile)
|
|
397
|
+
? configFile
|
|
398
|
+
: tree.exists((0, devkit_1.joinPathFragments)(`${projectRoot}/vite.config.ts`))
|
|
399
|
+
? (0, devkit_1.joinPathFragments)(`${projectRoot}/vite.config.ts`)
|
|
400
|
+
: tree.exists((0, devkit_1.joinPathFragments)(`${projectRoot}/vite.config.js`))
|
|
401
|
+
? (0, devkit_1.joinPathFragments)(`${projectRoot}/vite.config.js`)
|
|
402
|
+
: undefined;
|
|
408
403
|
}
|
|
409
404
|
function getViteConfigPathForProject(tree, projectName, target) {
|
|
410
405
|
let viteConfigPath;
|
|
411
|
-
const { targets, root } = (0,
|
|
406
|
+
const { targets, root } = (0, devkit_1.readProjectConfiguration)(tree, projectName);
|
|
412
407
|
if (target) {
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
viteConfigPath = config
|
|
408
|
+
viteConfigPath = targets?.[target]?.options?.configFile;
|
|
409
|
+
}
|
|
410
|
+
else {
|
|
411
|
+
const config = Object.values(targets).find((config) => config.executor === '@nrwl/nx:build' ||
|
|
412
|
+
config.executor === '@nrwl/vite:build');
|
|
413
|
+
viteConfigPath = config?.options?.configFile;
|
|
419
414
|
}
|
|
420
415
|
return normalizeViteConfigFilePathWithTree(tree, root, viteConfigPath);
|
|
421
416
|
}
|
|
@@ -431,7 +426,7 @@ async function handleUnsupportedUserProvidedTargets(userProvidedTargetIsUnsuppor
|
|
|
431
426
|
}
|
|
432
427
|
}
|
|
433
428
|
async function handleUnsupportedUserProvidedTargetsErrors(userProvidedTargetName, validFoundTargetName, target, executor) {
|
|
434
|
-
|
|
429
|
+
devkit_1.logger.warn(`The custom ${target} target you provided (${userProvidedTargetName}) cannot be converted to use the @nx/vite:${executor} executor.
|
|
435
430
|
However, we found the following ${target} target in your project that can be converted: ${validFoundTargetName}
|
|
436
431
|
|
|
437
432
|
Please note that converting a potentially non-compatible project to use Vite.js may result in unexpected behavior. Always commit
|
|
@@ -441,7 +436,7 @@ async function handleUnsupportedUserProvidedTargetsErrors(userProvidedTargetName
|
|
|
441
436
|
const prompt = new Confirm({
|
|
442
437
|
name: 'question',
|
|
443
438
|
message: `Should we convert the ${validFoundTargetName} target to use the @nx/vite:${executor} executor?`,
|
|
444
|
-
initial: true
|
|
439
|
+
initial: true,
|
|
445
440
|
});
|
|
446
441
|
const shouldConvert = await prompt.run();
|
|
447
442
|
if (!shouldConvert) {
|
|
@@ -458,7 +453,7 @@ async function handleUnknownConfiguration(projectName) {
|
|
|
458
453
|
if (process.env.NX_INTERACTIVE === 'false') {
|
|
459
454
|
return;
|
|
460
455
|
}
|
|
461
|
-
|
|
456
|
+
devkit_1.logger.warn(`
|
|
462
457
|
We could not find any configuration in project ${projectName} that
|
|
463
458
|
indicates whether we can definitely convert to Vite.
|
|
464
459
|
|
|
@@ -469,7 +464,7 @@ async function handleUnknownConfiguration(projectName) {
|
|
|
469
464
|
const prompt = new Confirm({
|
|
470
465
|
name: 'question',
|
|
471
466
|
message: `Should Nx convert your project to use Vite?`,
|
|
472
|
-
initial: true
|
|
467
|
+
initial: true,
|
|
473
468
|
});
|
|
474
469
|
const shouldConvert = await prompt.run();
|
|
475
470
|
if (!shouldConvert) {
|
|
@@ -480,55 +475,50 @@ async function handleUnknownConfiguration(projectName) {
|
|
|
480
475
|
}
|
|
481
476
|
}
|
|
482
477
|
function handleViteConfigFileExists(tree, viteConfigPath, options, buildOption, buildOutDir, imports, plugins, testOption, reportsDirectory, cacheDir, projectRoot, offsetFromRoot, projectAlreadyHasViteTargets) {
|
|
483
|
-
if (
|
|
478
|
+
if (projectAlreadyHasViteTargets?.build &&
|
|
479
|
+
projectAlreadyHasViteTargets?.test) {
|
|
484
480
|
return;
|
|
485
481
|
}
|
|
486
482
|
if (process.env.NX_VERBOSE_LOGGING === 'true') {
|
|
487
|
-
|
|
483
|
+
devkit_1.logger.info(`vite.config.ts already exists for project ${options.project}.`);
|
|
488
484
|
}
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
transformMixedEsModules: true
|
|
506
|
-
}
|
|
507
|
-
} : {
|
|
508
|
-
outDir: buildOutDir,
|
|
509
|
-
reportCompressedSize: true,
|
|
510
|
-
commonjsOptions: {
|
|
511
|
-
transformMixedEsModules: true
|
|
485
|
+
const buildOptionObject = options.includeLib
|
|
486
|
+
? {
|
|
487
|
+
lib: {
|
|
488
|
+
entry: 'src/index.ts',
|
|
489
|
+
name: options.project,
|
|
490
|
+
fileName: 'index',
|
|
491
|
+
formats: ['es'],
|
|
492
|
+
},
|
|
493
|
+
rollupOptions: {
|
|
494
|
+
external: options.rollupOptionsExternal ?? [],
|
|
495
|
+
},
|
|
496
|
+
outDir: buildOutDir,
|
|
497
|
+
reportCompressedSize: true,
|
|
498
|
+
commonjsOptions: {
|
|
499
|
+
transformMixedEsModules: true,
|
|
500
|
+
},
|
|
512
501
|
}
|
|
513
|
-
|
|
514
|
-
|
|
502
|
+
: {
|
|
503
|
+
outDir: buildOutDir,
|
|
504
|
+
reportCompressedSize: true,
|
|
505
|
+
commonjsOptions: {
|
|
506
|
+
transformMixedEsModules: true,
|
|
507
|
+
},
|
|
508
|
+
};
|
|
515
509
|
const testOptionObject = {
|
|
516
510
|
globals: true,
|
|
517
|
-
environment:
|
|
518
|
-
include: [
|
|
519
|
-
|
|
520
|
-
],
|
|
521
|
-
reporters: [
|
|
522
|
-
'default'
|
|
523
|
-
],
|
|
511
|
+
environment: options.testEnvironment ?? 'jsdom',
|
|
512
|
+
include: ['src/**/*.{test,spec}.{js,mjs,cjs,ts,mts,cts,jsx,tsx}'],
|
|
513
|
+
reporters: ['default'],
|
|
524
514
|
coverage: {
|
|
525
515
|
reportsDirectory: reportsDirectory,
|
|
526
|
-
provider: `'${
|
|
527
|
-
}
|
|
516
|
+
provider: `'${options.coverageProvider ?? 'v8'}'`,
|
|
517
|
+
},
|
|
528
518
|
};
|
|
529
|
-
const changed = (0,
|
|
519
|
+
const changed = (0, vite_config_edit_utils_1.ensureViteConfigIsCorrect)(tree, viteConfigPath, buildOption, buildOptionObject, imports, plugins, testOption, testOptionObject, cacheDir, projectAlreadyHasViteTargets ?? {});
|
|
530
520
|
if (!changed) {
|
|
531
|
-
|
|
521
|
+
devkit_1.logger.warn(`Make sure the following setting exists in your Vite configuration file (${viteConfigPath}):
|
|
532
522
|
|
|
533
523
|
${buildOption}
|
|
534
524
|
|
|
@@ -536,8 +526,6 @@ function handleViteConfigFileExists(tree, viteConfigPath, options, buildOption,
|
|
|
536
526
|
}
|
|
537
527
|
}
|
|
538
528
|
function normalizedJoinPaths(...paths) {
|
|
539
|
-
const path = (0,
|
|
529
|
+
const path = (0, devkit_1.joinPathFragments)(...paths);
|
|
540
530
|
return path.startsWith('.') ? path : `./${path}`;
|
|
541
531
|
}
|
|
542
|
-
|
|
543
|
-
//# sourceMappingURL=generator-utils.js.map
|