@nx/vite 17.0.2 → 17.0.4
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 +9 -4
- package/generators.json +3 -3
- package/migrations.json +90 -0
- package/package.json +9 -7
- package/plugin.d.ts +1 -0
- package/plugin.js +21 -0
- package/plugin.js.map +1 -0
- package/plugins/nx-tsconfig-paths.plugin.js +9 -5
- package/plugins/nx-tsconfig-paths.plugin.js.map +1 -1
- package/plugins/rollup-replace-files.plugin.d.ts +3 -3
- package/plugins/rollup-replace-files.plugin.js +2 -2
- package/plugins/rollup-replace-files.plugin.js.map +1 -1
- package/src/executors/build/build.impl.d.ts +5 -1
- package/src/executors/build/build.impl.js +90 -21
- package/src/executors/build/build.impl.js.map +1 -1
- package/src/executors/build/schema.d.ts +5 -18
- package/src/executors/build/schema.json +4 -106
- package/src/executors/dev-server/dev-server.impl.js +74 -9
- package/src/executors/dev-server/dev-server.impl.js.map +1 -1
- package/src/executors/dev-server/schema.d.ts +0 -10
- package/src/executors/dev-server/schema.json +0 -63
- package/src/executors/preview-server/preview-server.impl.d.ts +1 -1
- package/src/executors/preview-server/preview-server.impl.js +79 -15
- package/src/executors/preview-server/preview-server.impl.js.map +1 -1
- package/src/executors/preview-server/schema.d.ts +0 -7
- package/src/executors/preview-server/schema.json +1 -51
- package/src/executors/test/lib/nx-reporter.d.ts +14 -0
- package/src/executors/test/lib/nx-reporter.js +40 -0
- package/src/executors/test/lib/nx-reporter.js.map +1 -0
- package/src/executors/test/lib/utils.d.ts +4 -0
- package/src/executors/test/lib/utils.js +77 -0
- package/src/executors/test/lib/utils.js.map +1 -0
- package/src/executors/test/schema.d.ts +3 -8
- package/src/executors/test/schema.json +11 -43
- package/src/executors/test/vitest.impl.js +20 -112
- package/src/executors/test/vitest.impl.js.map +1 -1
- package/src/generators/configuration/configuration.d.ts +2 -1
- package/src/generators/configuration/configuration.js +49 -87
- package/src/generators/configuration/configuration.js.map +1 -1
- package/src/generators/configuration/lib/convert-non-vite.d.ts +5 -0
- package/src/generators/configuration/lib/convert-non-vite.js +62 -0
- package/src/generators/configuration/lib/convert-non-vite.js.map +1 -0
- package/src/generators/configuration/schema.d.ts +1 -3
- package/src/generators/configuration/schema.json +0 -12
- package/src/generators/init/init.d.ts +4 -3
- package/src/generators/init/init.js +50 -67
- package/src/generators/init/init.js.map +1 -1
- package/src/generators/init/lib/utils.d.ts +6 -0
- package/src/generators/init/lib/utils.js +80 -0
- package/src/generators/init/lib/utils.js.map +1 -0
- package/src/generators/init/schema.d.ts +5 -5
- package/src/generators/init/schema.json +17 -20
- package/src/generators/vitest/files/tsconfig.spec.json__tmpl__ +2 -1
- package/src/generators/vitest/schema.d.ts +2 -1
- package/src/generators/vitest/schema.json +2 -2
- package/src/generators/vitest/vitest-generator.d.ts +2 -1
- package/src/generators/vitest/vitest-generator.js +34 -10
- package/src/generators/vitest/vitest-generator.js.map +1 -1
- package/src/migrations/update-15-3-1/update-vite-tsconfig-paths.js.map +1 -1
- package/src/migrations/update-16-6-0-change-ts-paths-plugin/change-ts-paths-plugin.js +3 -17
- 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.d.ts +2 -0
- package/src/migrations/update-17-1-0/move-target-defaults.js +77 -0
- package/src/migrations/update-17-1-0/move-target-defaults.js.map +1 -0
- package/src/migrations/update-17-2-0/lib/add-file-replacements.d.ts +2 -0
- package/src/migrations/update-17-2-0/lib/add-file-replacements.js +67 -0
- package/src/migrations/update-17-2-0/lib/add-file-replacements.js.map +1 -0
- package/src/migrations/update-17-2-0/lib/edit-build-config.d.ts +2 -0
- package/src/migrations/update-17-2-0/lib/edit-build-config.js +121 -0
- package/src/migrations/update-17-2-0/lib/edit-build-config.js.map +1 -0
- package/src/migrations/update-17-2-0/lib/edit-test-config.d.ts +2 -0
- package/src/migrations/update-17-2-0/lib/edit-test-config.js +83 -0
- package/src/migrations/update-17-2-0/lib/edit-test-config.js.map +1 -0
- package/src/migrations/update-17-2-0/update-vite-config.d.ts +5 -0
- package/src/migrations/update-17-2-0/update-vite-config.js +68 -0
- package/src/migrations/update-17-2-0/update-vite-config.js.map +1 -0
- package/src/migrations/update-17-3-0/lib/fix-coverage-and-reporters.d.ts +3 -0
- package/src/migrations/update-17-3-0/lib/fix-coverage-and-reporters.js +117 -0
- package/src/migrations/update-17-3-0/lib/fix-coverage-and-reporters.js.map +1 -0
- package/src/migrations/update-17-3-0/vitest-coverage-and-reporters.d.ts +2 -0
- package/src/migrations/update-17-3-0/vitest-coverage-and-reporters.js +45 -0
- package/src/migrations/update-17-3-0/vitest-coverage-and-reporters.js.map +1 -0
- package/src/plugins/plugin.d.ts +10 -0
- package/src/plugins/plugin.js +226 -0
- package/src/plugins/plugin.js.map +1 -0
- package/src/utils/ensure-dependencies.d.ts +8 -0
- package/src/utils/ensure-dependencies.js +34 -0
- package/src/utils/ensure-dependencies.js.map +1 -0
- package/src/utils/executor-utils.d.ts +2 -0
- package/src/utils/executor-utils.js +22 -7
- package/src/utils/executor-utils.js.map +1 -1
- package/src/utils/find-vite-config.d.ts +3 -0
- package/src/utils/find-vite-config.js +46 -0
- package/src/utils/find-vite-config.js.map +1 -0
- package/src/utils/generator-utils.d.ts +10 -12
- package/src/utils/generator-utils.js +135 -213
- package/src/utils/generator-utils.js.map +1 -1
- package/src/utils/options-utils.d.ts +3 -19
- package/src/utils/options-utils.js +25 -68
- package/src/utils/options-utils.js.map +1 -1
- package/src/utils/test-files/react-lib-non-buildable-jest.json +1 -4
- package/src/utils/test-files/react-lib-non-buildable-vitest.json +1 -4
- package/src/utils/test-files/react-mixed-project.config.json +1 -6
- package/src/utils/test-files/react-vite-project.config.json +1 -4
- package/src/utils/test-files/unknown-project.config.json +1 -4
- package/src/utils/test-utils.d.ts +1 -1
- package/src/utils/test-utils.js +10 -18
- package/src/utils/test-utils.js.map +1 -1
- package/src/utils/versions.d.ts +7 -9
- package/src/utils/versions.js +7 -15
- package/src/utils/versions.js.map +1 -1
- package/src/utils/vite-config-edit-utils.js +1 -1
- package/src/utils/vite-config-edit-utils.js.map +1 -1
- package/src/utils/test-files/react-project.config.json +0 -85
- package/src/utils/test-files/web-project.config.json +0 -72
|
@@ -9,24 +9,36 @@ _export(exports, {
|
|
|
9
9
|
viteConfigurationGenerator: function() {
|
|
10
10
|
return viteConfigurationGenerator;
|
|
11
11
|
},
|
|
12
|
+
viteConfigurationGeneratorInternal: function() {
|
|
13
|
+
return viteConfigurationGeneratorInternal;
|
|
14
|
+
},
|
|
12
15
|
default: function() {
|
|
13
16
|
return _default;
|
|
14
17
|
}
|
|
15
18
|
});
|
|
16
19
|
const _extends = require("@swc/helpers/_/_extends");
|
|
17
20
|
const _devkit = require("@nx/devkit");
|
|
21
|
+
const _js = require("@nx/js");
|
|
18
22
|
const _generatorutils = require("../../utils/generator-utils");
|
|
19
23
|
const _init = require("../init/init");
|
|
20
24
|
const _vitestgenerator = require("../vitest/vitest-generator");
|
|
21
|
-
|
|
25
|
+
const _ensuredependencies = require("../../utils/ensure-dependencies");
|
|
26
|
+
const _convertnonvite = require("./lib/convert-non-vite");
|
|
27
|
+
function viteConfigurationGenerator(host, schema) {
|
|
28
|
+
return viteConfigurationGeneratorInternal(host, _extends._({
|
|
29
|
+
addPlugin: false
|
|
30
|
+
}, schema));
|
|
31
|
+
}
|
|
32
|
+
async function viteConfigurationGeneratorInternal(tree, schema) {
|
|
33
|
+
var _nxJson_plugins;
|
|
22
34
|
var _schema, // Setting default to jsdom since it is the most common use case (React, Web).
|
|
23
35
|
// The @nx/js:lib generator specifically sets this to node to be more generic.
|
|
24
|
-
_schema1;
|
|
36
|
+
_schema1, _schema2;
|
|
25
37
|
const tasks = [];
|
|
26
|
-
const
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
38
|
+
const projectConfig = (0, _devkit.readProjectConfiguration)(tree, schema.project);
|
|
39
|
+
const { targets, root: projectRoot } = projectConfig;
|
|
40
|
+
var _projectConfig_projectType;
|
|
41
|
+
const projectType = (_projectConfig_projectType = projectConfig.projectType) != null ? _projectConfig_projectType : 'library';
|
|
30
42
|
var _includeLib;
|
|
31
43
|
(_includeLib = (_schema = schema).includeLib) != null ? _includeLib : _schema.includeLib = projectType === 'library';
|
|
32
44
|
var _testEnvironment;
|
|
@@ -36,90 +48,39 @@ async function viteConfigurationGenerator(tree, schema) {
|
|
|
36
48
|
* to use the vite executors.
|
|
37
49
|
*/ let projectAlreadyHasViteTargets = {};
|
|
38
50
|
if (!schema.newProject) {
|
|
39
|
-
|
|
40
|
-
const userProvidedTargetName = {
|
|
41
|
-
build: schema.buildTarget,
|
|
42
|
-
serve: schema.serveTarget,
|
|
43
|
-
test: schema.testTarget
|
|
44
|
-
};
|
|
45
|
-
const { validFoundTargetName, projectContainsUnsupportedExecutor, userProvidedTargetIsUnsupported, alreadyHasNxViteTargets } = (0, _generatorutils.findExistingTargetsInProject)(targets, userProvidedTargetName);
|
|
46
|
-
projectAlreadyHasViteTargets = alreadyHasNxViteTargets;
|
|
47
|
-
/**
|
|
48
|
-
* This means that we only found unsupported build targets in that project.
|
|
49
|
-
* The only way that buildTarget is defined, means that it is supported.
|
|
50
|
-
*
|
|
51
|
-
* If the `unsupported` flag was false, it would mean that we did not find
|
|
52
|
-
* a build target at all, so we can create a new one.
|
|
53
|
-
*
|
|
54
|
-
* So we only throw if we found a target, but it is unsupported.
|
|
55
|
-
*/ if (!validFoundTargetName.build && projectContainsUnsupportedExecutor) {
|
|
56
|
-
throw new Error(`The project ${schema.project} cannot be converted to use the @nx/vite executors.`);
|
|
57
|
-
}
|
|
58
|
-
if (alreadyHasNxViteTargets.build && (alreadyHasNxViteTargets.serve || projectType === 'library') && alreadyHasNxViteTargets.test) {
|
|
59
|
-
throw new Error(`The project ${schema.project} is already configured to use the @nx/vite executors.
|
|
60
|
-
Please try a different project, or remove the existing targets
|
|
61
|
-
and re-run this generator to reset the existing Vite Configuration.
|
|
62
|
-
`);
|
|
63
|
-
}
|
|
64
|
-
/**
|
|
65
|
-
* This means that we did not find any supported executors
|
|
66
|
-
* so we don't have any valid target names.
|
|
67
|
-
*
|
|
68
|
-
* However, the executors that we may have found are not in the
|
|
69
|
-
* list of the specifically unsupported executors either.
|
|
70
|
-
*
|
|
71
|
-
* So, we should warn the user about it.
|
|
72
|
-
*/ if (!projectContainsUnsupportedExecutor && !validFoundTargetName.build && !validFoundTargetName.serve && !validFoundTargetName.test) {
|
|
73
|
-
await (0, _generatorutils.handleUnknownExecutors)(schema.project);
|
|
74
|
-
}
|
|
75
|
-
/**
|
|
76
|
-
* There is a possibility at this stage that the user has provided
|
|
77
|
-
* targets with unsupported executors.
|
|
78
|
-
* We keep track here of which of the targets that the user provided
|
|
79
|
-
* are unsupported.
|
|
80
|
-
* We do this with the `userProvidedTargetIsUnsupported` object,
|
|
81
|
-
* which contains flags for each target (whether it is supported or not).
|
|
82
|
-
*
|
|
83
|
-
* We also keep track of the targets that we found in the project,
|
|
84
|
-
* through the findExistingTargetsInProject function, which returns
|
|
85
|
-
* targets for build/serve/test that use supported executors, and
|
|
86
|
-
* can be converted to use the vite executors. These are the
|
|
87
|
-
* kept in the validFoundTargetName object.
|
|
88
|
-
*/ await (0, _generatorutils.handleUnsupportedUserProvidedTargets)(userProvidedTargetIsUnsupported, userProvidedTargetName, validFoundTargetName);
|
|
89
|
-
var _validFoundTargetName_build;
|
|
90
|
-
/**
|
|
91
|
-
* Once the user is at this stage, then they can go ahead and convert.
|
|
92
|
-
*/ buildTargetName = (_validFoundTargetName_build = validFoundTargetName.build) != null ? _validFoundTargetName_build : buildTargetName;
|
|
93
|
-
var _validFoundTargetName_serve;
|
|
94
|
-
serveTargetName = (_validFoundTargetName_serve = validFoundTargetName.serve) != null ? _validFoundTargetName_serve : serveTargetName;
|
|
95
|
-
if (projectType === 'application') {
|
|
96
|
-
(0, _generatorutils.moveAndEditIndexHtml)(tree, schema, buildTargetName);
|
|
97
|
-
}
|
|
98
|
-
(0, _generatorutils.deleteWebpackConfig)(tree, root, targets == null ? void 0 : (_targets_buildTargetName = targets[buildTargetName]) == null ? void 0 : (_targets_buildTargetName_options = _targets_buildTargetName.options) == null ? void 0 : _targets_buildTargetName_options.webpackConfig);
|
|
99
|
-
(0, _generatorutils.editTsConfig)(tree, schema);
|
|
51
|
+
await (0, _convertnonvite.convertNonVite)(tree, schema, projectRoot, projectType, targets);
|
|
100
52
|
}
|
|
101
|
-
const
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
53
|
+
const jsInitTask = await (0, _js.initGenerator)(tree, _extends._({}, schema, {
|
|
54
|
+
skipFormat: true,
|
|
55
|
+
tsConfigName: projectRoot === '.' ? 'tsconfig.json' : 'tsconfig.base.json'
|
|
56
|
+
}));
|
|
57
|
+
tasks.push(jsInitTask);
|
|
58
|
+
const initTask = await (0, _init.default)(tree, _extends._({}, schema, {
|
|
59
|
+
skipFormat: true
|
|
60
|
+
}));
|
|
108
61
|
tasks.push(initTask);
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
62
|
+
tasks.push((0, _ensuredependencies.ensureDependencies)(tree, schema));
|
|
63
|
+
const nxJson = (0, _devkit.readNxJson)(tree);
|
|
64
|
+
const addPluginDefault = process.env.NX_ADD_PLUGINS !== 'false' && nxJson.useInferencePlugins !== false;
|
|
65
|
+
var _addPlugin;
|
|
66
|
+
(_addPlugin = (_schema2 = schema).addPlugin) != null ? _addPlugin : _schema2.addPlugin = addPluginDefault;
|
|
67
|
+
const hasPlugin = (_nxJson_plugins = nxJson.plugins) == null ? void 0 : _nxJson_plugins.some((p)=>typeof p === 'string' ? p === '@nx/vite/plugin' : p.plugin === '@nx/vite/plugin');
|
|
68
|
+
if (!hasPlugin) {
|
|
69
|
+
if (!projectAlreadyHasViteTargets.build) {
|
|
70
|
+
(0, _generatorutils.addBuildTarget)(tree, schema, 'build');
|
|
115
71
|
}
|
|
116
|
-
if (!
|
|
117
|
-
(
|
|
72
|
+
if (!schema.includeLib) {
|
|
73
|
+
if (!projectAlreadyHasViteTargets.serve) {
|
|
74
|
+
(0, _generatorutils.addServeTarget)(tree, schema, 'serve');
|
|
75
|
+
}
|
|
76
|
+
if (!projectAlreadyHasViteTargets.preview) {
|
|
77
|
+
(0, _generatorutils.addPreviewTarget)(tree, schema, 'preview');
|
|
78
|
+
}
|
|
118
79
|
}
|
|
119
80
|
}
|
|
120
81
|
if (projectType === 'library') {
|
|
121
82
|
// update tsconfig.lib.json to include vite/client
|
|
122
|
-
(0, _devkit.updateJson)(tree, (0, _devkit.joinPathFragments)(
|
|
83
|
+
(0, _devkit.updateJson)(tree, (0, _devkit.joinPathFragments)(projectRoot, 'tsconfig.lib.json'), (json)=>{
|
|
123
84
|
if (!json.compilerOptions) {
|
|
124
85
|
json.compilerOptions = {};
|
|
125
86
|
}
|
|
@@ -158,7 +119,7 @@ async function viteConfigurationGenerator(tree, schema) {
|
|
|
158
119
|
plugins: [
|
|
159
120
|
'react()'
|
|
160
121
|
]
|
|
161
|
-
}, false);
|
|
122
|
+
}, false, undefined);
|
|
162
123
|
} else {
|
|
163
124
|
(0, _generatorutils.createOrEditViteConfig)(tree, schema, false, projectAlreadyHasViteTargets);
|
|
164
125
|
}
|
|
@@ -168,10 +129,11 @@ async function viteConfigurationGenerator(tree, schema) {
|
|
|
168
129
|
project: schema.project,
|
|
169
130
|
uiFramework: schema.uiFramework,
|
|
170
131
|
inSourceTests: schema.inSourceTests,
|
|
171
|
-
coverageProvider: '
|
|
132
|
+
coverageProvider: 'v8',
|
|
172
133
|
skipViteConfig: true,
|
|
173
|
-
testTarget:
|
|
174
|
-
skipFormat: true
|
|
134
|
+
testTarget: 'test',
|
|
135
|
+
skipFormat: true,
|
|
136
|
+
addPlugin: schema.addPlugin
|
|
175
137
|
});
|
|
176
138
|
tasks.push(vitestTask);
|
|
177
139
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../../../packages/vite/src/generators/configuration/configuration.ts"],"sourcesContent":["import {\n formatFiles,\n GeneratorCallback,\n joinPathFragments,\n readProjectConfiguration,\n runTasksInSerial,\n Tree,\n updateJson,\n} from '@nx/devkit';\n\nimport {\n addOrChangeBuildTarget,\n addOrChangeServeTarget,\n addPreviewTarget,\n createOrEditViteConfig,\n deleteWebpackConfig,\n editTsConfig,\n findExistingTargetsInProject,\n handleUnknownExecutors,\n handleUnsupportedUserProvidedTargets,\n moveAndEditIndexHtml,\n TargetFlags,\n UserProvidedTargetName,\n} from '../../utils/generator-utils';\n\nimport initGenerator from '../init/init';\nimport vitestGenerator from '../vitest/vitest-generator';\nimport { ViteConfigurationGeneratorSchema } from './schema';\n\nexport async function viteConfigurationGenerator(\n tree: Tree,\n schema: ViteConfigurationGeneratorSchema\n) {\n const tasks: GeneratorCallback[] = [];\n\n const { targets, projectType, root } = readProjectConfiguration(\n tree,\n schema.project\n );\n let buildTargetName = 'build';\n let serveTargetName = 'serve';\n let testTargetName = 'test';\n\n schema.includeLib ??= projectType === 'library';\n\n // Setting default to jsdom since it is the most common use case (React, Web).\n // The @nx/js:lib generator specifically sets this to node to be more generic.\n schema.testEnvironment ??= 'jsdom';\n\n /**\n * This is for when we are converting an existing project\n * to use the vite executors.\n */\n let projectAlreadyHasViteTargets: TargetFlags = {};\n\n if (!schema.newProject) {\n const userProvidedTargetName: UserProvidedTargetName = {\n build: schema.buildTarget,\n serve: schema.serveTarget,\n test: schema.testTarget,\n };\n\n const {\n validFoundTargetName,\n projectContainsUnsupportedExecutor,\n userProvidedTargetIsUnsupported,\n alreadyHasNxViteTargets,\n } = findExistingTargetsInProject(targets, userProvidedTargetName);\n projectAlreadyHasViteTargets = alreadyHasNxViteTargets;\n /**\n * This means that we only found unsupported build targets in that project.\n * The only way that buildTarget is defined, means that it is supported.\n *\n * If the `unsupported` flag was false, it would mean that we did not find\n * a build target at all, so we can create a new one.\n *\n * So we only throw if we found a target, but it is unsupported.\n */\n if (!validFoundTargetName.build && projectContainsUnsupportedExecutor) {\n throw new Error(\n `The project ${schema.project} cannot be converted to use the @nx/vite executors.`\n );\n }\n\n if (\n alreadyHasNxViteTargets.build &&\n (alreadyHasNxViteTargets.serve || projectType === 'library') &&\n alreadyHasNxViteTargets.test\n ) {\n throw new Error(\n `The project ${schema.project} is already configured to use the @nx/vite executors.\n Please try a different project, or remove the existing targets \n and re-run this generator to reset the existing Vite Configuration.\n `\n );\n }\n\n /**\n * This means that we did not find any supported executors\n * so we don't have any valid target names.\n *\n * However, the executors that we may have found are not in the\n * list of the specifically unsupported executors either.\n *\n * So, we should warn the user about it.\n */\n\n if (\n !projectContainsUnsupportedExecutor &&\n !validFoundTargetName.build &&\n !validFoundTargetName.serve &&\n !validFoundTargetName.test\n ) {\n await handleUnknownExecutors(schema.project);\n }\n\n /**\n * There is a possibility at this stage that the user has provided\n * targets with unsupported executors.\n * We keep track here of which of the targets that the user provided\n * are unsupported.\n * We do this with the `userProvidedTargetIsUnsupported` object,\n * which contains flags for each target (whether it is supported or not).\n *\n * We also keep track of the targets that we found in the project,\n * through the findExistingTargetsInProject function, which returns\n * targets for build/serve/test that use supported executors, and\n * can be converted to use the vite executors. These are the\n * kept in the validFoundTargetName object.\n */\n await handleUnsupportedUserProvidedTargets(\n userProvidedTargetIsUnsupported,\n userProvidedTargetName,\n validFoundTargetName\n );\n\n /**\n * Once the user is at this stage, then they can go ahead and convert.\n */\n\n buildTargetName = validFoundTargetName.build ?? buildTargetName;\n serveTargetName = validFoundTargetName.serve ?? serveTargetName;\n\n if (projectType === 'application') {\n moveAndEditIndexHtml(tree, schema, buildTargetName);\n }\n\n deleteWebpackConfig(\n tree,\n root,\n targets?.[buildTargetName]?.options?.webpackConfig\n );\n\n editTsConfig(tree, schema);\n }\n\n const initTask = await initGenerator(tree, {\n uiFramework: schema.uiFramework,\n includeLib: schema.includeLib,\n compiler: schema.compiler,\n testEnvironment: schema.testEnvironment,\n rootProject: root === '.',\n });\n tasks.push(initTask);\n\n if (!projectAlreadyHasViteTargets.build) {\n addOrChangeBuildTarget(tree, schema, buildTargetName);\n }\n\n if (!schema.includeLib) {\n if (!projectAlreadyHasViteTargets.serve) {\n addOrChangeServeTarget(tree, schema, serveTargetName);\n }\n if (!projectAlreadyHasViteTargets.preview) {\n addPreviewTarget(tree, schema, serveTargetName);\n }\n }\n\n if (projectType === 'library') {\n // update tsconfig.lib.json to include vite/client\n updateJson(tree, joinPathFragments(root, 'tsconfig.lib.json'), (json) => {\n if (!json.compilerOptions) {\n json.compilerOptions = {};\n }\n if (!json.compilerOptions.types) {\n json.compilerOptions.types = [];\n }\n if (!json.compilerOptions.types.includes('vite/client')) {\n return {\n ...json,\n compilerOptions: {\n ...json.compilerOptions,\n types: [...json.compilerOptions.types, 'vite/client'],\n },\n };\n }\n return json;\n });\n }\n\n if (!schema.newProject) {\n // We are converting existing project to use Vite\n if (schema.uiFramework === 'react') {\n createOrEditViteConfig(\n tree,\n {\n project: schema.project,\n includeLib: schema.includeLib,\n includeVitest: schema.includeVitest,\n inSourceTests: schema.inSourceTests,\n rollupOptionsExternal: [\n \"'react'\",\n \"'react-dom'\",\n \"'react/jsx-runtime'\",\n ],\n imports: [\n schema.compiler === 'swc'\n ? `import react from '@vitejs/plugin-react-swc'`\n : `import react from '@vitejs/plugin-react'`,\n ],\n plugins: ['react()'],\n },\n false\n );\n } else {\n createOrEditViteConfig(tree, schema, false, projectAlreadyHasViteTargets);\n }\n }\n\n if (schema.includeVitest) {\n const vitestTask = await vitestGenerator(tree, {\n project: schema.project,\n uiFramework: schema.uiFramework,\n inSourceTests: schema.inSourceTests,\n coverageProvider: 'c8',\n skipViteConfig: true,\n testTarget: testTargetName,\n skipFormat: true,\n });\n tasks.push(vitestTask);\n }\n\n if (!schema.skipFormat) {\n await formatFiles(tree);\n }\n\n return runTasksInSerial(...tasks);\n}\n\nexport default viteConfigurationGenerator;\n"],"names":["viteConfigurationGenerator","tree","schema","tasks","targets","projectType","root","readProjectConfiguration","project","buildTargetName","serveTargetName","testTargetName","includeLib","testEnvironment","projectAlreadyHasViteTargets","newProject","userProvidedTargetName","build","buildTarget","serve","serveTarget","test","testTarget","validFoundTargetName","projectContainsUnsupportedExecutor","userProvidedTargetIsUnsupported","alreadyHasNxViteTargets","findExistingTargetsInProject","Error","handleUnknownExecutors","handleUnsupportedUserProvidedTargets","moveAndEditIndexHtml","deleteWebpackConfig","options","webpackConfig","editTsConfig","initTask","initGenerator","uiFramework","compiler","rootProject","push","addOrChangeBuildTarget","addOrChangeServeTarget","preview","addPreviewTarget","updateJson","joinPathFragments","json","compilerOptions","types","includes","createOrEditViteConfig","includeVitest","inSourceTests","rollupOptionsExternal","imports","plugins","vitestTask","vitestGenerator","coverageProvider","skipViteConfig","skipFormat","formatFiles","runTasksInSerial"],"mappings":";;;;;;;;IA6BsBA,0BAA0B;eAA1BA;;IA4NtB,OAA0C;eAA1C;;;;wBAjPO;gCAeA;sBAEmB;iCACE;AAGrB,eAAeA,2BACpBC,IAAU,EACVC,MAAwC;QAYxCA,SAEA,8EAA8E;IAC9E,8EAA8E;IAC9EA;IAdA,MAAMC,QAA6B,EAAE;IAErC,MAAM,EAAEC,OAAO,EAAEC,WAAW,EAAEC,IAAI,EAAE,GAAGC,IAAAA,gCAAwB,EAC7DN,MACAC,OAAOM,OAAO;IAEhB,IAAIC,kBAAkB;IACtB,IAAIC,kBAAkB;IACtB,IAAIC,iBAAiB;;IAErBT,gBAAAA,UAAAA,QAAOU,oCAAPV,QAAOU,aAAeP,gBAAgB;;IAItCH,qBAAAA,WAAAA,QAAOW,8CAAPX,SAAOW,kBAAoB;IAE3B;;;GAGC,GACD,IAAIC,+BAA4C,CAAC;IAEjD,IAAI,CAACZ,OAAOa,UAAU,EAAE;YA+FpBX,kCAAAA;QA9FF,MAAMY,yBAAiD;YACrDC,OAAOf,OAAOgB,WAAW;YACzBC,OAAOjB,OAAOkB,WAAW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AO;gBACvBI,YAAYV,OAAOU,UAAU;gBAC7ByC,eAAenD,OAAOmD,aAAa;gBACnCC,eAAepD,OAAOoD,aAAa;gBACnCC,uBAAuB;oBACrB;oBACA;oBACA;iBACD;gBACDC,SAAS;oBACPtD,OAAOqC,QAAQ,KAAK,QAChB,CAAC,4CAA4C,CAAC,GAC9C,CAAC,wCAAwC,CAAC;iBAC/C;gBACDkB,SAAS;oBAAC;iBAAU;YACtB,GACA;QAEJ,OAAO;YACLL,IAAAA,sCAAsB,EAACnD,MAAMC,QAAQ,OAAOY;QAC9C;IACF;IAEA,IAAIZ,OAAOmD,aAAa,EAAE;QACxB,MAAMK,aAAa,MAAMC,IAAAA,wBAAe,EAAC1D,MAAM;YAC7CO,SAASN,OAAOM,OAAO;YACvB8B,aAAapC,OAAOoC,WAAW;YAC/BgB,eAAepD,OAAOoD,aAAa;YACnCM,kBAAkB;YAClBC,gBAAgB;YAChBvC,YAAYX;YACZmD,YAAY;QACd;QACA3D,MAAMsC,IAAI,CAACiB;IACb;IAEA,IAAI,CAACxD,OAAO4D,UAAU,EAAE;QACtB,MAAMC,IAAAA,mBAAW,EAAC9D;IACpB;IAEA,OAAO+D,IAAAA,wBAAgB,KAAI7D;AAC7B;MAEA,WAAeH"}
|
|
1
|
+
{"version":3,"sources":["../../../../../../packages/vite/src/generators/configuration/configuration.ts"],"sourcesContent":["import {\n formatFiles,\n GeneratorCallback,\n joinPathFragments,\n readNxJson,\n readProjectConfiguration,\n runTasksInSerial,\n Tree,\n updateJson,\n} from '@nx/devkit';\nimport { initGenerator as jsInitGenerator } from '@nx/js';\n\nimport {\n addBuildTarget,\n addServeTarget,\n addPreviewTarget,\n createOrEditViteConfig,\n TargetFlags,\n} from '../../utils/generator-utils';\n\nimport initGenerator from '../init/init';\nimport vitestGenerator from '../vitest/vitest-generator';\nimport { ViteConfigurationGeneratorSchema } from './schema';\nimport { ensureDependencies } from '../../utils/ensure-dependencies';\nimport { convertNonVite } from './lib/convert-non-vite';\n\nexport function viteConfigurationGenerator(\n host: Tree,\n schema: ViteConfigurationGeneratorSchema\n) {\n return viteConfigurationGeneratorInternal(host, {\n addPlugin: false,\n ...schema,\n });\n}\n\nexport async function viteConfigurationGeneratorInternal(\n tree: Tree,\n schema: ViteConfigurationGeneratorSchema\n) {\n const tasks: GeneratorCallback[] = [];\n\n const projectConfig = readProjectConfiguration(tree, schema.project);\n const { targets, root: projectRoot } = projectConfig;\n\n const projectType = projectConfig.projectType ?? 'library';\n\n schema.includeLib ??= projectType === 'library';\n\n // Setting default to jsdom since it is the most common use case (React, Web).\n // The @nx/js:lib generator specifically sets this to node to be more generic.\n schema.testEnvironment ??= 'jsdom';\n\n /**\n * This is for when we are converting an existing project\n * to use the vite executors.\n */\n let projectAlreadyHasViteTargets: TargetFlags = {};\n\n if (!schema.newProject) {\n await convertNonVite(tree, schema, projectRoot, projectType, targets);\n }\n\n const jsInitTask = await jsInitGenerator(tree, {\n ...schema,\n skipFormat: true,\n tsConfigName: projectRoot === '.' ? 'tsconfig.json' : 'tsconfig.base.json',\n });\n tasks.push(jsInitTask);\n const initTask = await initGenerator(tree, { ...schema, skipFormat: true });\n tasks.push(initTask);\n tasks.push(ensureDependencies(tree, schema));\n\n const nxJson = readNxJson(tree);\n const addPluginDefault =\n process.env.NX_ADD_PLUGINS !== 'false' &&\n nxJson.useInferencePlugins !== false;\n schema.addPlugin ??= addPluginDefault;\n\n const hasPlugin = nxJson.plugins?.some((p) =>\n typeof p === 'string'\n ? p === '@nx/vite/plugin'\n : p.plugin === '@nx/vite/plugin'\n );\n\n if (!hasPlugin) {\n if (!projectAlreadyHasViteTargets.build) {\n addBuildTarget(tree, schema, 'build');\n }\n\n if (!schema.includeLib) {\n if (!projectAlreadyHasViteTargets.serve) {\n addServeTarget(tree, schema, 'serve');\n }\n if (!projectAlreadyHasViteTargets.preview) {\n addPreviewTarget(tree, schema, 'preview');\n }\n }\n }\n if (projectType === 'library') {\n // update tsconfig.lib.json to include vite/client\n updateJson(\n tree,\n joinPathFragments(projectRoot, 'tsconfig.lib.json'),\n (json) => {\n if (!json.compilerOptions) {\n json.compilerOptions = {};\n }\n if (!json.compilerOptions.types) {\n json.compilerOptions.types = [];\n }\n if (!json.compilerOptions.types.includes('vite/client')) {\n return {\n ...json,\n compilerOptions: {\n ...json.compilerOptions,\n types: [...json.compilerOptions.types, 'vite/client'],\n },\n };\n }\n return json;\n }\n );\n }\n\n if (!schema.newProject) {\n // We are converting existing project to use Vite\n if (schema.uiFramework === 'react') {\n createOrEditViteConfig(\n tree,\n {\n project: schema.project,\n includeLib: schema.includeLib,\n includeVitest: schema.includeVitest,\n inSourceTests: schema.inSourceTests,\n rollupOptionsExternal: [\n \"'react'\",\n \"'react-dom'\",\n \"'react/jsx-runtime'\",\n ],\n imports: [\n schema.compiler === 'swc'\n ? `import react from '@vitejs/plugin-react-swc'`\n : `import react from '@vitejs/plugin-react'`,\n ],\n plugins: ['react()'],\n },\n false,\n undefined\n );\n } else {\n createOrEditViteConfig(tree, schema, false, projectAlreadyHasViteTargets);\n }\n }\n\n if (schema.includeVitest) {\n const vitestTask = await vitestGenerator(tree, {\n project: schema.project,\n uiFramework: schema.uiFramework,\n inSourceTests: schema.inSourceTests,\n coverageProvider: 'v8',\n skipViteConfig: true,\n testTarget: 'test',\n skipFormat: true,\n addPlugin: schema.addPlugin,\n });\n tasks.push(vitestTask);\n }\n\n if (!schema.skipFormat) {\n await formatFiles(tree);\n }\n\n return runTasksInSerial(...tasks);\n}\n\nexport default viteConfigurationGenerator;\n"],"names":["viteConfigurationGenerator","viteConfigurationGeneratorInternal","host","schema","addPlugin","tree","nxJson","tasks","projectConfig","readProjectConfiguration","project","targets","root","projectRoot","projectType","includeLib","testEnvironment","projectAlreadyHasViteTargets","newProject","convertNonVite","jsInitTask","jsInitGenerator","skipFormat","tsConfigName","push","initTask","initGenerator","ensureDependencies","readNxJson","addPluginDefault","process","env","NX_ADD_PLUGINS","useInferencePlugins","hasPlugin","plugins","some","p","plugin","build","addBuildTarget","serve","addServeTarget","preview","addPreviewTarget","updateJson","joinPathFragments","json","compilerOptions","types","includes","uiFramework","createOrEditViteConfig","includeVitest","inSourceTests","rollupOptionsExternal","imports","compiler","undefined","vitestTask","vitestGenerator","coverageProvider","skipViteConfig","testTarget","formatFiles","runTasksInSerial"],"mappings":";;;;;;;;IA0BgBA,0BAA0B;eAA1BA;;IAUMC,kCAAkC;eAAlCA;;IA4ItB,OAA0C;eAA1C;;;;wBAvKO;oBAC0C;gCAQ1C;sBAEmB;iCACE;oCAEO;gCACJ;AAExB,SAASD,2BACdE,IAAU,EACVC,MAAwC;IAExC,OAAOF,mCAAmCC,MAAM;QAC9CE,WAAW;OACRD;AAEP;AAEO,eAAeF,mCACpBI,IAAU,EACVF,MAAwC;QAyCtBG;QAhClBH,SAEA,8EAA8E;IAC9E,8EAA8E;IAC9EA,UA0BAA;IArCA,MAAMI,QAA6B,EAAE;IAErC,MAAMC,gBAAgBC,IAAAA,gCAAwB,EAACJ,MAAMF,OAAOO,OAAO;IACnE,MAAM,EAAEC,OAAO,EAAEC,MAAMC,WAAW,EAAE,GAAGL;QAEnBA;IAApB,MAAMM,cAAcN,CAAAA,6BAAAA,cAAcM,WAAW,YAAzBN,6BAA6B;;IAEjDL,gBAAAA,UAAAA,QAAOY,oCAAPZ,QAAOY,aAAeD,gBAAgB;;IAItCX,qBAAAA,WAAAA,QAAOa,8CAAPb,SAAOa,kBAAoB;IAE3B;;;GAGC,GACD,IAAIC,+BAA4C,CAAC;IAEjD,IAAI,CAACd,OAAOe,UAAU,EAAE;QACtB,MAAMC,IAAAA,8BAAc,EAACd,MAAMF,QAAQU,aAAaC,aAAaH;IAC/D;IAEA,MAAMS,aAAa,MAAMC,IAAAA,iBAAe,EAAChB,MAAM,eAC1CF;QACHmB,YAAY;QACZC,cAAcV,gBAAgB,MAAM,kBAAkB;;IAExDN,MAAMiB,IAAI,CAACJ;IACX,MAAMK,WAAW,MAAMC,IAAAA,aAAa,EAACrB,MAAM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,KAAKC,eAAe,CAACC,KAAK;4BAAE;yBAAc;;;YAG3D;YACA,OAAOF;QACT;IAEJ;IAEA,IAAI,CAAC5C,OAAOe,UAAU,EAAE;QACtB,iDAAiD;QACjD,IAAIf,OAAOgD,WAAW,KAAK,SAAS;YAClCC,IAAAA,sCAAsB,EACpB/C,MACA;gBACEK,SAASP,OAAOO,OAAO;gBACvBK,YAAYZ,OAAOY,UAAU;gBAC7BsC,eAAelD,OAAOkD,aAAa;gBACnCC,eAAenD,OAAOmD,aAAa;gBACnCC,uBAAuB;oBACrB;oBACA;oBACA;iBACD;gBACDC,SAAS;oBACPrD,OAAOsD,QAAQ,KAAK,QAChB,CAAC,4CAA4C,CAAC,GAC9C,CAAC,wCAAwC,CAAC;iBAC/C;gBACDtB,SAAS;oBAAC;iBAAU;YACtB,GACA,OACAuB;QAEJ,OAAO;YACLN,IAAAA,sCAAsB,EAAC/C,MAAMF,QAAQ,OAAOc;QAC9C;IACF;IAEA,IAAId,OAAOkD,aAAa,EAAE;QACxB,MAAMM,aAAa,MAAMC,IAAAA,wBAAe,EAACvD,MAAM;YAC7CK,SAASP,OAAOO,OAAO;YACvByC,aAAahD,OAAOgD,WAAW;YAC/BG,eAAenD,OAAOmD,aAAa;YACnCO,kBAAkB;YAClBC,gBAAgB;YAChBC,YAAY;YACZzC,YAAY;YACZlB,WAAWD,OAAOC,SAAS;QAC7B;QACAG,MAAMiB,IAAI,CAACmC;IACb;IAEA,IAAI,CAACxD,OAAOmB,UAAU,EAAE;QACtB,MAAM0C,IAAAA,mBAAW,EAAC3D;IACpB;IAEA,OAAO4D,IAAAA,wBAAgB,KAAI1D;AAC7B;MAEA,WAAeP"}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import { TargetConfiguration, Tree } from '@nx/devkit';
|
|
2
|
+
import { ViteConfigurationGeneratorSchema } from '../schema';
|
|
3
|
+
export declare function convertNonVite(tree: Tree, schema: ViteConfigurationGeneratorSchema, projectRoot: string, projectType: string, targets: {
|
|
4
|
+
[targetName: string]: TargetConfiguration<any>;
|
|
5
|
+
}): Promise<void>;
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "convertNonVite", {
|
|
3
|
+
enumerable: true,
|
|
4
|
+
get: function() {
|
|
5
|
+
return convertNonVite;
|
|
6
|
+
}
|
|
7
|
+
});
|
|
8
|
+
const _devkit = require("@nx/devkit");
|
|
9
|
+
const _findviteconfig = require("../../../utils/find-vite-config");
|
|
10
|
+
const _generatorutils = require("../../../utils/generator-utils");
|
|
11
|
+
async function convertNonVite(tree, schema, projectRoot, projectType, targets) {
|
|
12
|
+
// Check if it has vite
|
|
13
|
+
const hasViteConfig = (0, _findviteconfig.findViteConfig)(tree, projectRoot);
|
|
14
|
+
const hasIndexHtmlAtRoot = tree.exists((0, _devkit.joinPathFragments)(projectRoot, 'index.html'));
|
|
15
|
+
// Check if it has webpack
|
|
16
|
+
const hasWebpackConfig = (0, _findviteconfig.findWebpackConfig)(tree, projectRoot);
|
|
17
|
+
if (hasWebpackConfig) {
|
|
18
|
+
if (projectType === 'application') {
|
|
19
|
+
(0, _generatorutils.moveAndEditIndexHtml)(tree, schema);
|
|
20
|
+
}
|
|
21
|
+
(0, _generatorutils.deleteWebpackConfig)(tree, projectRoot, hasWebpackConfig);
|
|
22
|
+
(0, _generatorutils.editTsConfig)(tree, schema);
|
|
23
|
+
return;
|
|
24
|
+
}
|
|
25
|
+
if (projectType === 'application' && hasViteConfig && hasIndexHtmlAtRoot && !hasWebpackConfig) {
|
|
26
|
+
throw new Error(`The project ${schema.project} is already configured to use Vite.`);
|
|
27
|
+
return;
|
|
28
|
+
}
|
|
29
|
+
if (projectType === 'library' && hasViteConfig) {
|
|
30
|
+
// continue anyway - it could need to be updated - only update vite.config.ts in any case
|
|
31
|
+
(0, _generatorutils.editTsConfig)(tree, schema);
|
|
32
|
+
return;
|
|
33
|
+
}
|
|
34
|
+
// Does the project have js executors?
|
|
35
|
+
const { supported: jsTargetName, unsupported } = (0, _generatorutils.findExistingJsBuildTargetInProject)(targets);
|
|
36
|
+
if (jsTargetName) {
|
|
37
|
+
(0, _generatorutils.editTsConfig)(tree, schema);
|
|
38
|
+
return;
|
|
39
|
+
}
|
|
40
|
+
if (unsupported) {
|
|
41
|
+
throw new Error(`
|
|
42
|
+
Nx cannot convert your project to use vite.
|
|
43
|
+
Please try again with a different project.
|
|
44
|
+
`);
|
|
45
|
+
}
|
|
46
|
+
// If it's a library, it's most possible it's non-buildable
|
|
47
|
+
// So fix the tsconfig and return, to continue with the rest of the setup
|
|
48
|
+
if (projectType === 'library' && !hasViteConfig && !hasWebpackConfig && !jsTargetName) {
|
|
49
|
+
(0, _generatorutils.editTsConfig)(tree, schema);
|
|
50
|
+
return;
|
|
51
|
+
}
|
|
52
|
+
/**
|
|
53
|
+
* The project is an app.
|
|
54
|
+
* The project has no js executors, no webpack config, no vite config.
|
|
55
|
+
* We did not find any configuration that hints the project can
|
|
56
|
+
* definitely be converted.
|
|
57
|
+
* So, we should warn the user about it.
|
|
58
|
+
* They can choose whether to convert it or not
|
|
59
|
+
*/ await (0, _generatorutils.handleUnknownConfiguration)(schema.project);
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
//# sourceMappingURL=convert-non-vite.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../../../../../packages/vite/src/generators/configuration/lib/convert-non-vite.ts"],"sourcesContent":["import {\n TargetConfiguration,\n Tree,\n joinPathFragments,\n logger,\n} from '@nx/devkit';\nimport {\n findViteConfig,\n findWebpackConfig,\n} from '../../../utils/find-vite-config';\nimport { ViteConfigurationGeneratorSchema } from '../schema';\nimport {\n deleteWebpackConfig,\n editTsConfig,\n findExistingJsBuildTargetInProject,\n handleUnknownConfiguration,\n moveAndEditIndexHtml,\n} from '../../../utils/generator-utils';\n\nexport async function convertNonVite(\n tree: Tree,\n schema: ViteConfigurationGeneratorSchema,\n projectRoot: string,\n projectType: string,\n targets: {\n [targetName: string]: TargetConfiguration<any>;\n }\n) {\n // Check if it has vite\n const hasViteConfig = findViteConfig(tree, projectRoot);\n const hasIndexHtmlAtRoot = tree.exists(\n joinPathFragments(projectRoot, 'index.html')\n );\n\n // Check if it has webpack\n const hasWebpackConfig = findWebpackConfig(tree, projectRoot);\n if (hasWebpackConfig) {\n if (projectType === 'application') {\n moveAndEditIndexHtml(tree, schema);\n }\n deleteWebpackConfig(tree, projectRoot, hasWebpackConfig);\n editTsConfig(tree, schema);\n return;\n }\n\n if (\n projectType === 'application' &&\n hasViteConfig &&\n hasIndexHtmlAtRoot &&\n !hasWebpackConfig\n ) {\n throw new Error(\n `The project ${schema.project} is already configured to use Vite.`\n );\n return;\n }\n\n if (projectType === 'library' && hasViteConfig) {\n // continue anyway - it could need to be updated - only update vite.config.ts in any case\n editTsConfig(tree, schema);\n return;\n }\n\n // Does the project have js executors?\n const { supported: jsTargetName, unsupported } =\n findExistingJsBuildTargetInProject(targets);\n if (jsTargetName) {\n editTsConfig(tree, schema);\n return;\n }\n\n if (unsupported) {\n throw new Error(`\n Nx cannot convert your project to use vite.\n Please try again with a different project.\n `);\n }\n\n // If it's a library, it's most possible it's non-buildable\n // So fix the tsconfig and return, to continue with the rest of the setup\n if (\n projectType === 'library' &&\n !hasViteConfig &&\n !hasWebpackConfig &&\n !jsTargetName\n ) {\n editTsConfig(tree, schema);\n return;\n }\n\n /**\n * The project is an app.\n * The project has no js executors, no webpack config, no vite config.\n * We did not find any configuration that hints the project can\n * definitely be converted.\n * So, we should warn the user about it.\n * They can choose whether to convert it or not\n */\n await handleUnknownConfiguration(schema.project);\n}\n"],"names":["convertNonVite","tree","schema","projectRoot","projectType","targets","hasViteConfig","findViteConfig","hasIndexHtmlAtRoot","exists","joinPathFragments","hasWebpackConfig","findWebpackConfig","moveAndEditIndexHtml","deleteWebpackConfig","editTsConfig","Error","project","supported","jsTargetName","unsupported","findExistingJsBuildTargetInProject","handleUnknownConfiguration"],"mappings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export interface ViteConfigurationGeneratorSchema {
|
|
|
6
6
|
includeVitest?: boolean;
|
|
7
7
|
inSourceTests?: boolean;
|
|
8
8
|
includeLib?: boolean;
|
|
9
|
-
buildTarget?: string;
|
|
10
|
-
serveTarget?: string;
|
|
11
|
-
testTarget?: string;
|
|
12
9
|
skipFormat?: boolean;
|
|
13
10
|
testEnvironment?: 'node' | 'jsdom' | 'happy-dom' | 'edge-runtime' | string;
|
|
11
|
+
addPlugin?: boolean;
|
|
14
12
|
}
|
|
@@ -44,18 +44,6 @@
|
|
|
44
44
|
"default": false,
|
|
45
45
|
"hidden": true
|
|
46
46
|
},
|
|
47
|
-
"buildTarget": {
|
|
48
|
-
"type": "string",
|
|
49
|
-
"description": "The build target of the project to be transformed to use the @nx/vite:build executor."
|
|
50
|
-
},
|
|
51
|
-
"serveTarget": {
|
|
52
|
-
"type": "string",
|
|
53
|
-
"description": "The serve target of the project to be transformed to use the @nx/vite:dev-server and @nx/vite:preview-server executors."
|
|
54
|
-
},
|
|
55
|
-
"testTarget": {
|
|
56
|
-
"type": "string",
|
|
57
|
-
"description": "The test target of the project to be transformed to use the @nx/vite:test executor."
|
|
58
|
-
},
|
|
59
47
|
"skipFormat": {
|
|
60
48
|
"description": "Skip formatting files.",
|
|
61
49
|
"type": "boolean",
|
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
import { Tree } from '@nx/devkit';
|
|
1
|
+
import { GeneratorCallback, Tree } from '@nx/devkit';
|
|
2
2
|
import { InitGeneratorSchema } from './schema';
|
|
3
|
-
export declare function
|
|
4
|
-
export declare function initGenerator(tree: Tree, schema: InitGeneratorSchema): Promise<
|
|
3
|
+
export declare function updateNxJsonSettings(tree: Tree): void;
|
|
4
|
+
export declare function initGenerator(tree: Tree, schema: InitGeneratorSchema): Promise<GeneratorCallback>;
|
|
5
|
+
export declare function initGeneratorInternal(tree: Tree, schema: InitGeneratorSchema): Promise<GeneratorCallback>;
|
|
5
6
|
export default initGenerator;
|
|
@@ -6,92 +6,75 @@ function _export(target, all) {
|
|
|
6
6
|
});
|
|
7
7
|
}
|
|
8
8
|
_export(exports, {
|
|
9
|
-
|
|
10
|
-
return
|
|
9
|
+
updateNxJsonSettings: function() {
|
|
10
|
+
return updateNxJsonSettings;
|
|
11
11
|
},
|
|
12
12
|
initGenerator: function() {
|
|
13
13
|
return initGenerator;
|
|
14
14
|
},
|
|
15
|
+
initGeneratorInternal: function() {
|
|
16
|
+
return initGeneratorInternal;
|
|
17
|
+
},
|
|
15
18
|
default: function() {
|
|
16
19
|
return _default;
|
|
17
20
|
}
|
|
18
21
|
});
|
|
19
22
|
const _extends = require("@swc/helpers/_/_extends");
|
|
20
23
|
const _devkit = require("@nx/devkit");
|
|
21
|
-
const
|
|
22
|
-
const
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
const dependencies = {};
|
|
27
|
-
packageJson.dependencies = packageJson.dependencies || {};
|
|
28
|
-
packageJson.devDependencies = packageJson.devDependencies || {};
|
|
29
|
-
// base deps
|
|
30
|
-
devDependencies['@nx/vite'] = _versions.nxVersion;
|
|
31
|
-
devDependencies['vite'] = _versions.viteVersion;
|
|
32
|
-
devDependencies['vitest'] = _versions.vitestVersion;
|
|
33
|
-
devDependencies['@vitest/ui'] = _versions.vitestUiVersion;
|
|
34
|
-
if (schema.testEnvironment === 'jsdom') {
|
|
35
|
-
devDependencies['jsdom'] = _versions.jsdomVersion;
|
|
36
|
-
} else if (schema.testEnvironment === 'happy-dom') {
|
|
37
|
-
devDependencies['happy-dom'] = _versions.happyDomVersion;
|
|
38
|
-
} else if (schema.testEnvironment === 'edge-runtime') {
|
|
39
|
-
devDependencies['@edge-runtime/vm'] = _versions.edgeRuntimeVmVersion;
|
|
40
|
-
} else if (schema.testEnvironment !== 'node' && schema.testEnvironment) {
|
|
41
|
-
_devkit.logger.info(`A custom environment was provided: ${schema.testEnvironment}. You need to install it manually.`);
|
|
42
|
-
}
|
|
43
|
-
if (schema.uiFramework === 'react') {
|
|
44
|
-
if (schema.compiler === 'swc') {
|
|
45
|
-
devDependencies['@vitejs/plugin-react-swc'] = _versions.vitePluginReactSwcVersion;
|
|
46
|
-
} else {
|
|
47
|
-
devDependencies['@vitejs/plugin-react'] = _versions.vitePluginReactVersion;
|
|
48
|
-
}
|
|
49
|
-
}
|
|
50
|
-
if (schema.includeLib) {
|
|
51
|
-
devDependencies['vite-plugin-dts'] = _versions.vitePluginDtsVersion;
|
|
52
|
-
}
|
|
53
|
-
return (0, _devkit.addDependenciesToPackageJson)(host, dependencies, devDependencies);
|
|
54
|
-
}
|
|
55
|
-
function moveToDevDependencies(tree) {
|
|
56
|
-
(0, _devkit.updateJson)(tree, 'package.json', (packageJson)=>{
|
|
57
|
-
packageJson.dependencies = packageJson.dependencies || {};
|
|
58
|
-
packageJson.devDependencies = packageJson.devDependencies || {};
|
|
59
|
-
if (packageJson.dependencies['@nx/vite']) {
|
|
60
|
-
packageJson.devDependencies['@nx/vite'] = packageJson.dependencies['@nx/vite'];
|
|
61
|
-
delete packageJson.dependencies['@nx/vite'];
|
|
62
|
-
}
|
|
63
|
-
return packageJson;
|
|
64
|
-
});
|
|
65
|
-
}
|
|
66
|
-
function createVitestConfig(tree) {
|
|
67
|
-
var _nxJson_namedInputs;
|
|
68
|
-
var _nxJson, _nxJson_targetDefaults, _nxJson_targetDefaults_test;
|
|
24
|
+
const _updatepackagescripts = require("@nx/devkit/src/utils/update-package-scripts");
|
|
25
|
+
const _plugin = require("../../plugins/plugin");
|
|
26
|
+
const _utils = require("./lib/utils");
|
|
27
|
+
function updateNxJsonSettings(tree) {
|
|
28
|
+
var _nxJson_namedInputs, _nxJson_plugins;
|
|
69
29
|
const nxJson = (0, _devkit.readNxJson)(tree);
|
|
70
30
|
const productionFileSet = (_nxJson_namedInputs = nxJson.namedInputs) == null ? void 0 : _nxJson_namedInputs.production;
|
|
71
31
|
if (productionFileSet) {
|
|
72
32
|
productionFileSet.push('!{projectRoot}/**/?(*.)+(spec|test).[jt]s?(x)?(.snap)', '!{projectRoot}/tsconfig.spec.json');
|
|
73
33
|
nxJson.namedInputs.production = Array.from(new Set(productionFileSet));
|
|
74
34
|
}
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
'
|
|
82
|
-
|
|
83
|
-
|
|
35
|
+
const hasPlugin = (_nxJson_plugins = nxJson.plugins) == null ? void 0 : _nxJson_plugins.some((p)=>typeof p === 'string' ? p === '@nx/vite/plugin' : p.plugin === '@nx/vite/plugin');
|
|
36
|
+
if (!hasPlugin) {
|
|
37
|
+
var _nxJson, _nxJson_targetDefaults, _nxvitetest, _nxJson_targetDefaults_nxvitetest, _nxJson_targetDefaults_nxvitetest1;
|
|
38
|
+
var _targetDefaults;
|
|
39
|
+
(_targetDefaults = (_nxJson = nxJson).targetDefaults) != null ? _targetDefaults : _nxJson.targetDefaults = {};
|
|
40
|
+
var _;
|
|
41
|
+
(_ = (_nxJson_targetDefaults = nxJson.targetDefaults)[_nxvitetest = '@nx/vite:test']) != null ? _ : _nxJson_targetDefaults[_nxvitetest] = {};
|
|
42
|
+
var _cache;
|
|
43
|
+
(_cache = (_nxJson_targetDefaults_nxvitetest = nxJson.targetDefaults['@nx/vite:test']).cache) != null ? _cache : _nxJson_targetDefaults_nxvitetest.cache = true;
|
|
44
|
+
var _inputs;
|
|
45
|
+
(_inputs = (_nxJson_targetDefaults_nxvitetest1 = nxJson.targetDefaults['@nx/vite:test']).inputs) != null ? _inputs : _nxJson_targetDefaults_nxvitetest1.inputs = [
|
|
46
|
+
'default',
|
|
47
|
+
productionFileSet ? '^production' : '^default'
|
|
48
|
+
];
|
|
49
|
+
}
|
|
84
50
|
(0, _devkit.updateNxJson)(tree, nxJson);
|
|
85
51
|
}
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
52
|
+
function initGenerator(tree, schema) {
|
|
53
|
+
return initGeneratorInternal(tree, _extends._({
|
|
54
|
+
addPlugin: false
|
|
55
|
+
}, schema));
|
|
56
|
+
}
|
|
57
|
+
async function initGeneratorInternal(tree, schema) {
|
|
58
|
+
var _schema;
|
|
59
|
+
const nxJson = (0, _devkit.readNxJson)(tree);
|
|
60
|
+
const addPluginDefault = process.env.NX_ADD_PLUGINS !== 'false' && nxJson.useInferencePlugins !== false;
|
|
61
|
+
var _addPlugin;
|
|
62
|
+
(_addPlugin = (_schema = schema).addPlugin) != null ? _addPlugin : _schema.addPlugin = addPluginDefault;
|
|
63
|
+
if (schema.addPlugin) {
|
|
64
|
+
(0, _utils.addPlugin)(tree);
|
|
65
|
+
}
|
|
66
|
+
updateNxJsonSettings(tree);
|
|
89
67
|
const tasks = [];
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
}
|
|
94
|
-
|
|
68
|
+
if (!schema.skipPackageJson) {
|
|
69
|
+
tasks.push((0, _utils.moveToDevDependencies)(tree));
|
|
70
|
+
tasks.push((0, _utils.checkDependenciesInstalled)(tree, schema));
|
|
71
|
+
}
|
|
72
|
+
if (schema.updatePackageScripts) {
|
|
73
|
+
await (0, _updatepackagescripts.updatePackageScripts)(tree, _plugin.createNodes);
|
|
74
|
+
}
|
|
75
|
+
if (!schema.skipFormat) {
|
|
76
|
+
await (0, _devkit.formatFiles)(tree);
|
|
77
|
+
}
|
|
95
78
|
return (0, _devkit.runTasksInSerial)(...tasks);
|
|
96
79
|
}
|
|
97
80
|
const _default = initGenerator;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../../../packages/vite/src/generators/init/init.ts"],"sourcesContent":["import {\n
|
|
1
|
+
{"version":3,"sources":["../../../../../../packages/vite/src/generators/init/init.ts"],"sourcesContent":["import {\n formatFiles,\n GeneratorCallback,\n readNxJson,\n runTasksInSerial,\n Tree,\n updateNxJson,\n} from '@nx/devkit';\nimport { updatePackageScripts } from '@nx/devkit/src/utils/update-package-scripts';\n\nimport { createNodes } from '../../plugins/plugin';\nimport { InitGeneratorSchema } from './schema';\nimport {\n addPlugin,\n checkDependenciesInstalled,\n moveToDevDependencies,\n} from './lib/utils';\n\nexport function updateNxJsonSettings(tree: Tree) {\n const nxJson = readNxJson(tree);\n\n const productionFileSet = nxJson.namedInputs?.production;\n if (productionFileSet) {\n productionFileSet.push(\n '!{projectRoot}/**/?(*.)+(spec|test).[jt]s?(x)?(.snap)',\n '!{projectRoot}/tsconfig.spec.json'\n );\n\n nxJson.namedInputs.production = Array.from(new Set(productionFileSet));\n }\n\n const hasPlugin = nxJson.plugins?.some((p) =>\n typeof p === 'string'\n ? p === '@nx/vite/plugin'\n : p.plugin === '@nx/vite/plugin'\n );\n\n if (!hasPlugin) {\n nxJson.targetDefaults ??= {};\n nxJson.targetDefaults['@nx/vite:test'] ??= {};\n nxJson.targetDefaults['@nx/vite:test'].cache ??= true;\n nxJson.targetDefaults['@nx/vite:test'].inputs ??= [\n 'default',\n productionFileSet ? '^production' : '^default',\n ];\n }\n\n updateNxJson(tree, nxJson);\n}\n\nexport function initGenerator(tree: Tree, schema: InitGeneratorSchema) {\n return initGeneratorInternal(tree, { addPlugin: false, ...schema });\n}\n\nexport async function initGeneratorInternal(\n tree: Tree,\n schema: InitGeneratorSchema\n) {\n const nxJson = readNxJson(tree);\n const addPluginDefault =\n process.env.NX_ADD_PLUGINS !== 'false' &&\n nxJson.useInferencePlugins !== false;\n schema.addPlugin ??= addPluginDefault;\n if (schema.addPlugin) {\n addPlugin(tree);\n }\n\n updateNxJsonSettings(tree);\n\n const tasks: GeneratorCallback[] = [];\n if (!schema.skipPackageJson) {\n tasks.push(moveToDevDependencies(tree));\n tasks.push(checkDependenciesInstalled(tree, schema));\n }\n\n if (schema.updatePackageScripts) {\n await updatePackageScripts(tree, createNodes);\n }\n\n if (!schema.skipFormat) {\n await formatFiles(tree);\n }\n\n return runTasksInSerial(...tasks);\n}\n\nexport default initGenerator;\n"],"names":["updateNxJsonSettings","initGenerator","initGeneratorInternal","tree","nxJson","readNxJson","productionFileSet","namedInputs","production","push","Array","from","Set","hasPlugin","plugins","some","p","plugin","targetDefaults","cache","inputs","updateNxJson","schema","addPlugin","addPluginDefault","process","env","NX_ADD_PLUGINS","useInferencePlugins","tasks","skipPackageJson","moveToDevDependencies","checkDependenciesInstalled","updatePackageScripts","createNodes","skipFormat","formatFiles","runTasksInSerial"],"mappings":";;;;;;;;IAkBgBA,oBAAoB;eAApBA;;IAgCAC,aAAa;eAAbA;;IAIMC,qBAAqB;eAArBA;;IAgCtB,OAA6B;eAA7B;;;;wBA/EO;sCAC8B;wBAET;uBAMrB;AAEA,SAASF,qBAAqBG,IAAU;QAGnBC,qBAURA;IAZlB,MAAMA,SAASC,IAAAA,kBAAU,EAACF;IAE1B,MAAMG,qBAAoBF,sBAAAA,OAAOG,WAAW,qBAAlBH,oBAAoBI,UAAU;IACxD,IAAIF,mBAAmB;QACrBA,kBAAkBG,IAAI,CACpB,yDACA;QAGFL,OAAOG,WAAW,CAACC,UAAU,GAAGE,MAAMC,IAAI,CAAC,IAAIC,IAAIN;IACrD;IAEA,MAAMO,aAAYT,kBAAAA,OAAOU,OAAO,qBAAdV,gBAAgBW,IAAI,CAAC,CAACC,IACtC,OAAOA,MAAM,WACTA,MAAM,oBACNA,EAAEC,MAAM,KAAK;IAGnB,IAAI,CAACJ,WAAW;YACdT,SACAA,wBAAsB,aACtBA,mCACAA;;QAHAA,oBAAAA,UAAAA,QAAOc,4CAAPd,QAAOc,iBAAmB,CAAC;;QAC3Bd,MAAAA,yBAAAA,OAAOc,cAAc,CAAA,CAAC,cAAA,gBAAgB,gBAAtCd,sBAAqB,CAAC,YAAgB,GAAK,CAAC;;QAC5CA,WAAAA,oCAAAA,OAAOc,cAAc,CAAC,gBAAgB,EAACC,0BAAvCf,kCAAuCe,QAAU;;QACjDf,YAAAA,qCAAAA,OAAOc,cAAc,CAAC,gBAAgB,EAACE,4BAAvChB,mCAAuCgB,SAAW;YAChD;YACAd,oBAAoB,gBAAgB;SACrC;IACH;IAEAe,IAAAA,oBAAY,EAAClB,MAAMC;AACrB;AAEO,SAASH,cAAcE,IAAU,EAAEmB,MAA2B;IACnE,OAAOpB,sBAAsBC,MAAM;QAAEoB,WAAW;OAAUD;AAC5D;AAEO,eAAepB,sBACpBC,IAAU,EACVmB,MAA2B;QAM3BA;IAJA,MAAMlB,SAASC,IAAAA,kBAAU,EAACF;IAC1B,MAAMqB,mBACJC,QAAQC,GAAG,CAACC,cAAc,KAAK,WAC/BvB,OAAOwB,mBAAmB,KAAK;;IACjCN,eAAAA,UAAAA,QAAOC,kCAAPD,QAAOC,YAAcC;IACrB,IAAIF,OAAOC,SAAS,EAAE;QACpBA,IAAAA,gBAAS,EAACpB;IACZ;IAEAH,qBAAqBG;IAErB,MAAM0B,QAA6B,EAAE;IACrC,IAAI,CAACP,OAAOQ,eAAe,EAAE;QAC3BD,MAAMpB,IAAI,CAACsB,IAAAA,4BAAqB,EAAC5B;QACjC0B,MAAMpB,IAAI,CAACuB,IAAAA,iCAA0B,EAAC7B,MAAMmB;IAC9C;IAEA,IAAIA,OAAOW,oBAAoB,EAAE;QAC/B,MAAMA,IAAAA,0CAAoB,EAAC9B,MAAM+B,mBAAW;IAC9C;IAEA,IAAI,CAACZ,OAAOa,UAAU,EAAE;QACtB,MAAMC,IAAAA,mBAAW,EAACjC;IACpB;IAEA,OAAOkC,IAAAA,wBAAgB,KAAIR;AAC7B;MAEA,WAAe5B"}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { Tree } from '@nx/devkit';
|
|
2
|
+
import { InitGeneratorSchema } from '../schema';
|
|
3
|
+
export declare function checkDependenciesInstalled(host: Tree, schema: InitGeneratorSchema): import("@nx/devkit").GeneratorCallback;
|
|
4
|
+
export declare function moveToDevDependencies(tree: Tree): () => void;
|
|
5
|
+
export declare function createVitestConfig(tree: Tree): void;
|
|
6
|
+
export declare function addPlugin(tree: Tree): void;
|