@nx/vite 18.2.0-beta.0 → 18.2.0-beta.2
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
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@nx/vite",
|
|
3
|
-
"version": "18.2.0-beta.
|
|
3
|
+
"version": "18.2.0-beta.2",
|
|
4
4
|
"private": false,
|
|
5
5
|
"description": "The Nx Plugin for building and testing applications using Vite",
|
|
6
6
|
"repository": {
|
|
@@ -29,13 +29,13 @@
|
|
|
29
29
|
"migrations": "./migrations.json"
|
|
30
30
|
},
|
|
31
31
|
"dependencies": {
|
|
32
|
-
"@nx/devkit": "18.2.0-beta.
|
|
32
|
+
"@nx/devkit": "18.2.0-beta.2",
|
|
33
33
|
"@phenomnomnominal/tsquery": "~5.0.1",
|
|
34
34
|
"@swc/helpers": "~0.5.0",
|
|
35
35
|
"enquirer": "~2.3.6",
|
|
36
|
-
"@nx/js": "18.2.0-beta.
|
|
36
|
+
"@nx/js": "18.2.0-beta.2",
|
|
37
37
|
"tsconfig-paths": "^4.1.2",
|
|
38
|
-
"@nrwl/vite": "18.2.0-beta.
|
|
38
|
+
"@nrwl/vite": "18.2.0-beta.2"
|
|
39
39
|
},
|
|
40
40
|
"peerDependencies": {
|
|
41
41
|
"vite": "^5.0.0",
|
|
@@ -126,7 +126,7 @@ function closeServer(server) {
|
|
|
126
126
|
const { httpServer } = server;
|
|
127
127
|
if (httpServer['closeAllConnections']) {
|
|
128
128
|
// https://github.com/vitejs/vite/pull/14834
|
|
129
|
-
// closeAllConnections was added in Node
|
|
129
|
+
// closeAllConnections was added in Node v18.2.0
|
|
130
130
|
// typically is "as http.Server" but no reason
|
|
131
131
|
// to import http just for this
|
|
132
132
|
httpServer.closeAllConnections();
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../../../packages/vite/src/executors/preview-server/preview-server.impl.ts"],"sourcesContent":["import {\n ExecutorContext,\n joinPathFragments,\n offsetFromRoot,\n parseTargetString,\n runExecutor,\n} from '@nx/devkit';\nimport {\n getNxTargetOptions,\n getProxyConfig,\n normalizeViteConfigFilePath,\n} from '../../utils/options-utils';\nimport { ViteBuildExecutorOptions } from '../build/schema';\nimport { VitePreviewServerExecutorOptions } from './schema';\nimport { relative } from 'path';\nimport { getBuildExtraArgs } from '../build/build.impl';\nimport { loadViteDynamicImport } from '../../utils/executor-utils';\n\nexport async function* vitePreviewServerExecutor(\n options: VitePreviewServerExecutorOptions,\n context: ExecutorContext\n) {\n process.env.VITE_CJS_IGNORE_WARNING = 'true';\n // Allows ESM to be required in CJS modules. Vite will be published as ESM in the future.\n const { mergeConfig, preview, loadConfigFromFile } =\n await loadViteDynamicImport();\n const projectRoot =\n context.projectsConfigurations.projects[context.projectName].root;\n const target = parseTargetString(options.buildTarget, context);\n const targetConfiguration =\n context.projectsConfigurations.projects[target.project]?.targets[\n target.target\n ];\n if (!targetConfiguration) {\n throw new Error(`Invalid buildTarget: ${options.buildTarget}`);\n }\n\n const isCustomBuildTarget =\n targetConfiguration.executor !== '@nx/vite:build' &&\n targetConfiguration.executor !== '@nrwl/vite:build';\n\n // Retrieve the option for the configured buildTarget.\n const buildTargetOptions: ViteBuildExecutorOptions = getNxTargetOptions(\n options.buildTarget,\n context\n );\n\n const { configuration } = parseTargetString(options.buildTarget, context);\n\n const viteConfigPath = normalizeViteConfigFilePath(\n context.root,\n projectRoot,\n buildTargetOptions.configFile\n );\n\n const { buildOptions, otherOptions: otherOptionsFromBuild } =\n await getBuildExtraArgs(buildTargetOptions);\n\n const { previewOptions, otherOptions } = await getExtraArgs(\n options,\n configuration,\n otherOptionsFromBuild\n );\n const resolved = await loadConfigFromFile(\n {\n mode: otherOptions?.mode ?? otherOptionsFromBuild?.mode ?? 'production',\n command: 'build',\n },\n viteConfigPath\n );\n\n const outDir =\n options.staticFilePath ??\n joinPathFragments(\n offsetFromRoot(projectRoot),\n buildTargetOptions.outputPath\n ) ??\n resolved?.config?.build?.outDir;\n\n if (!outDir) {\n throw new Error(\n `Could not infer the \"outputPath\" or \"outDir\". It should be set in your vite.config.ts, or as a property of the \"${options.buildTarget}\" buildTarget or provided explicitly as a \"staticFilePath\" option.`\n );\n }\n const root =\n projectRoot === '.'\n ? process.cwd()\n : relative(context.cwd, joinPathFragments(context.root, projectRoot));\n\n // Merge the options from the build and preview-serve targets.\n // The latter takes precedence.\n const mergedOptions = {\n ...{ watch: {} },\n build: {\n outDir,\n ...(isCustomBuildTarget ? {} : buildOptions),\n },\n ...(isCustomBuildTarget ? {} : otherOptionsFromBuild),\n ...otherOptions,\n preview: {\n ...getProxyConfig(context, otherOptions.proxyConfig),\n ...previewOptions,\n },\n };\n\n // vite InlineConfig\n const serverConfig = mergeConfig(\n {\n // This should not be needed as it's going to be set in vite.config.ts\n // but leaving it here in case someone did not migrate correctly\n root: resolved.config.root ?? root,\n configFile: viteConfigPath,\n },\n {\n ...mergedOptions,\n }\n );\n\n if (serverConfig.mode === 'production') {\n console.warn('WARNING: preview is not meant to be run in production!');\n }\n\n // vite PreviewServer\n let server: Record<string, any> | undefined;\n\n const processOnExit = async () => {\n await closeServer(server);\n };\n\n process.once('SIGINT', processOnExit);\n process.once('SIGTERM', processOnExit);\n process.once('exit', processOnExit);\n\n // Launch the build target.\n // If customBuildTarget is set to true, do not provide any overrides to it\n const buildTargetOverrides = isCustomBuildTarget ? {} : mergedOptions;\n const build = await runExecutor(target, buildTargetOverrides, context);\n\n for await (const result of build) {\n if (result.success) {\n try {\n if (!server) {\n server = await preview(serverConfig);\n }\n server.printUrls();\n\n const resolvedUrls = [\n ...server.resolvedUrls.local,\n ...server.resolvedUrls.network,\n ];\n\n yield {\n success: true,\n baseUrl: resolvedUrls[0] ?? '',\n };\n } catch (e) {\n console.error(e);\n yield {\n success: false,\n baseUrl: '',\n };\n }\n } else {\n yield {\n success: false,\n baseUrl: '',\n };\n }\n }\n\n await new Promise<void>((resolve) => {\n process.once('SIGINT', () => resolve());\n process.once('SIGTERM', () => resolve());\n process.once('exit', () => resolve());\n });\n}\n\nfunction closeServer(server?: Record<string, any>): Promise<void> {\n return new Promise((resolve) => {\n if (!server) {\n resolve();\n } else {\n const { httpServer } = server;\n if (httpServer['closeAllConnections']) {\n // https://github.com/vitejs/vite/pull/14834\n // closeAllConnections was added in Node v19.2.0\n // typically is \"as http.Server\" but no reason\n // to import http just for this\n (httpServer as any).closeAllConnections();\n }\n httpServer.close(() => resolve());\n }\n });\n}\n\nexport default vitePreviewServerExecutor;\n\nasync function getExtraArgs(\n options: VitePreviewServerExecutorOptions,\n configuration: string | undefined,\n otherOptionsFromBuildTarget: Record<string, unknown> | undefined\n): Promise<{\n // vite PreviewOptions\n previewOptions: Record<string, any>;\n otherOptions: Record<string, any>;\n}> {\n // support passing extra args to vite cli\n const schema = await import('./schema.json');\n const extraArgs = {};\n for (const key of Object.keys(options)) {\n if (!schema.properties[key]) {\n extraArgs[key] = options[key];\n }\n }\n\n const previewOptions = {};\n const previewSchemaKeys = [\n 'port',\n 'strictPort',\n 'host',\n 'https',\n 'open',\n 'proxy',\n 'cors',\n 'headers',\n ];\n\n let otherOptions = {};\n for (const key of Object.keys(extraArgs)) {\n if (previewSchemaKeys.includes(key)) {\n previewOptions[key] = extraArgs[key];\n } else {\n otherOptions[key] = extraArgs[key];\n }\n }\n\n if (configuration) {\n otherOptions = {\n ...otherOptions,\n ...(otherOptionsFromBuildTarget ?? {}),\n };\n }\n\n return {\n previewOptions,\n otherOptions,\n };\n}\n"],"names":["vitePreviewServerExecutor","options","context","resolved","process","env","VITE_CJS_IGNORE_WARNING","mergeConfig","preview","loadConfigFromFile","loadViteDynamicImport","projectRoot","projectsConfigurations","projects","projectName","root","target","parseTargetString","buildTarget","targetConfiguration","project","targets","Error","isCustomBuildTarget","executor","buildTargetOptions","getNxTargetOptions","configuration","viteConfigPath","normalizeViteConfigFilePath","configFile","buildOptions","otherOptions","otherOptionsFromBuild","getBuildExtraArgs","previewOptions","getExtraArgs","mode","command","outDir","staticFilePath","joinPathFragments","offsetFromRoot","outputPath","config","build","cwd","relative","mergedOptions","watch","getProxyConfig","proxyConfig","serverConfig","console","warn","server","processOnExit","closeServer","once","buildTargetOverrides","runExecutor","result","success","printUrls","resolvedUrls","local","network","baseUrl","e","error","Promise","resolve","httpServer","closeAllConnections","close","otherOptionsFromBuildTarget","schema","extraArgs","key","Object","keys","properties","previewSchemaKeys","includes"],"mappings":";;;;;;;;IAkBuBA,yBAAyB;eAAzBA;;IAiLvB,OAAyC;eAAzC;;;;wBA7LO;8BAKA;sBAGkB;2BACS;+BACI;AAE/B,gBAAgBA,0BACrBC,OAAyC,EACzCC,OAAwB;QAUtBA,yDA+CAC,wBAAAA;IAvDFC,QAAQC,GAAG,CAACC,uBAAuB,GAAG;IACtC,yFAAyF;IACzF,MAAM,EAAEC,WAAW,EAAEC,OAAO,EAAEC,kBAAkB,EAAE,GAChD,MAAMC,IAAAA,oCAAqB;IAC7B,MAAMC,cACJT,QAAQU,sBAAsB,CAACC,QAAQ,CAACX,QAAQY,WAAW,CAAC,CAACC,IAAI;IACnE,MAAMC,SAASC,IAAAA,yBAAiB,EAAChB,QAAQiB,WAAW,EAAEhB;IACtD,MAAMiB,uBACJjB,0DAAAA,QAAQU,sBAAsB,CAACC,QAAQ,CAACG,OAAOI,OAAO,CAAC,qBAAvDlB,wDAAyDmB,OAAO,CAC9DL,OAAOA,MAAM,CACd;IACH,IAAI,CAACG,qBAAqB;QACxB,MAAM,IAAIG,MAAM,CAAC,qBAAqB,EAAErB,QAAQiB,WAAW,CAAC,CAAC;IAC/D;IAEA,MAAMK,sBACJJ,oBAAoBK,QAAQ,KAAK,oBACjCL,oBAAoBK,QAAQ,KAAK;IAEnC,sDAAsD;IACtD,MAAMC,qBAA+CC,IAAAA,gCAAkB,EACrEzB,QAAQiB,WAAW,EACnBhB;IAGF,MAAM,EAAEyB,aAAa,EAAE,GAAGV,I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AH;IACF;AACF"}
|
|
1
|
+
{"version":3,"sources":["../../../../../../packages/vite/src/executors/preview-server/preview-server.impl.ts"],"sourcesContent":["import {\n ExecutorContext,\n joinPathFragments,\n offsetFromRoot,\n parseTargetString,\n runExecutor,\n} from '@nx/devkit';\nimport {\n getNxTargetOptions,\n getProxyConfig,\n normalizeViteConfigFilePath,\n} from '../../utils/options-utils';\nimport { ViteBuildExecutorOptions } from '../build/schema';\nimport { VitePreviewServerExecutorOptions } from './schema';\nimport { relative } from 'path';\nimport { getBuildExtraArgs } from '../build/build.impl';\nimport { loadViteDynamicImport } from '../../utils/executor-utils';\n\nexport async function* vitePreviewServerExecutor(\n options: VitePreviewServerExecutorOptions,\n context: ExecutorContext\n) {\n process.env.VITE_CJS_IGNORE_WARNING = 'true';\n // Allows ESM to be required in CJS modules. Vite will be published as ESM in the future.\n const { mergeConfig, preview, loadConfigFromFile } =\n await loadViteDynamicImport();\n const projectRoot =\n context.projectsConfigurations.projects[context.projectName].root;\n const target = parseTargetString(options.buildTarget, context);\n const targetConfiguration =\n context.projectsConfigurations.projects[target.project]?.targets[\n target.target\n ];\n if (!targetConfiguration) {\n throw new Error(`Invalid buildTarget: ${options.buildTarget}`);\n }\n\n const isCustomBuildTarget =\n targetConfiguration.executor !== '@nx/vite:build' &&\n targetConfiguration.executor !== '@nrwl/vite:build';\n\n // Retrieve the option for the configured buildTarget.\n const buildTargetOptions: ViteBuildExecutorOptions = getNxTargetOptions(\n options.buildTarget,\n context\n );\n\n const { configuration } = parseTargetString(options.buildTarget, context);\n\n const viteConfigPath = normalizeViteConfigFilePath(\n context.root,\n projectRoot,\n buildTargetOptions.configFile\n );\n\n const { buildOptions, otherOptions: otherOptionsFromBuild } =\n await getBuildExtraArgs(buildTargetOptions);\n\n const { previewOptions, otherOptions } = await getExtraArgs(\n options,\n configuration,\n otherOptionsFromBuild\n );\n const resolved = await loadConfigFromFile(\n {\n mode: otherOptions?.mode ?? otherOptionsFromBuild?.mode ?? 'production',\n command: 'build',\n },\n viteConfigPath\n );\n\n const outDir =\n options.staticFilePath ??\n joinPathFragments(\n offsetFromRoot(projectRoot),\n buildTargetOptions.outputPath\n ) ??\n resolved?.config?.build?.outDir;\n\n if (!outDir) {\n throw new Error(\n `Could not infer the \"outputPath\" or \"outDir\". It should be set in your vite.config.ts, or as a property of the \"${options.buildTarget}\" buildTarget or provided explicitly as a \"staticFilePath\" option.`\n );\n }\n const root =\n projectRoot === '.'\n ? process.cwd()\n : relative(context.cwd, joinPathFragments(context.root, projectRoot));\n\n // Merge the options from the build and preview-serve targets.\n // The latter takes precedence.\n const mergedOptions = {\n ...{ watch: {} },\n build: {\n outDir,\n ...(isCustomBuildTarget ? {} : buildOptions),\n },\n ...(isCustomBuildTarget ? {} : otherOptionsFromBuild),\n ...otherOptions,\n preview: {\n ...getProxyConfig(context, otherOptions.proxyConfig),\n ...previewOptions,\n },\n };\n\n // vite InlineConfig\n const serverConfig = mergeConfig(\n {\n // This should not be needed as it's going to be set in vite.config.ts\n // but leaving it here in case someone did not migrate correctly\n root: resolved.config.root ?? root,\n configFile: viteConfigPath,\n },\n {\n ...mergedOptions,\n }\n );\n\n if (serverConfig.mode === 'production') {\n console.warn('WARNING: preview is not meant to be run in production!');\n }\n\n // vite PreviewServer\n let server: Record<string, any> | undefined;\n\n const processOnExit = async () => {\n await closeServer(server);\n };\n\n process.once('SIGINT', processOnExit);\n process.once('SIGTERM', processOnExit);\n process.once('exit', processOnExit);\n\n // Launch the build target.\n // If customBuildTarget is set to true, do not provide any overrides to it\n const buildTargetOverrides = isCustomBuildTarget ? {} : mergedOptions;\n const build = await runExecutor(target, buildTargetOverrides, context);\n\n for await (const result of build) {\n if (result.success) {\n try {\n if (!server) {\n server = await preview(serverConfig);\n }\n server.printUrls();\n\n const resolvedUrls = [\n ...server.resolvedUrls.local,\n ...server.resolvedUrls.network,\n ];\n\n yield {\n success: true,\n baseUrl: resolvedUrls[0] ?? '',\n };\n } catch (e) {\n console.error(e);\n yield {\n success: false,\n baseUrl: '',\n };\n }\n } else {\n yield {\n success: false,\n baseUrl: '',\n };\n }\n }\n\n await new Promise<void>((resolve) => {\n process.once('SIGINT', () => resolve());\n process.once('SIGTERM', () => resolve());\n process.once('exit', () => resolve());\n });\n}\n\nfunction closeServer(server?: Record<string, any>): Promise<void> {\n return new Promise((resolve) => {\n if (!server) {\n resolve();\n } else {\n const { httpServer } = server;\n if (httpServer['closeAllConnections']) {\n // https://github.com/vitejs/vite/pull/14834\n // closeAllConnections was added in Node v18.2.0\n // typically is \"as http.Server\" but no reason\n // to import http just for this\n (httpServer as any).closeAllConnections();\n }\n httpServer.close(() => resolve());\n }\n });\n}\n\nexport default vitePreviewServerExecutor;\n\nasync function getExtraArgs(\n options: VitePreviewServerExecutorOptions,\n configuration: string | undefined,\n otherOptionsFromBuildTarget: Record<string, unknown> | undefined\n): Promise<{\n // vite PreviewOptions\n previewOptions: Record<string, any>;\n otherOptions: Record<string, any>;\n}> {\n // support passing extra args to vite cli\n const schema = await import('./schema.json');\n const extraArgs = {};\n for (const key of Object.keys(options)) {\n if (!schema.properties[key]) {\n extraArgs[key] = options[key];\n }\n }\n\n const previewOptions = {};\n const previewSchemaKeys = [\n 'port',\n 'strictPort',\n 'host',\n 'https',\n 'open',\n 'proxy',\n 'cors',\n 'headers',\n ];\n\n let otherOptions = {};\n for (const key of Object.keys(extraArgs)) {\n if (previewSchemaKeys.includes(key)) {\n previewOptions[key] = extraArgs[key];\n } else {\n otherOptions[key] = extraArgs[key];\n }\n }\n\n if (configuration) {\n otherOptions = {\n ...otherOptions,\n ...(otherOptionsFromBuildTarget ?? {}),\n };\n }\n\n return {\n previewOptions,\n otherOptions,\n };\n}\n"],"names":["vitePreviewServerExecutor","options","context","resolved","process","env","VITE_CJS_IGNORE_WARNING","mergeConfig","preview","loadConfigFromFile","loadViteDynamicImport","projectRoot","projectsConfigurations","projects","projectName","root","target","parseTargetString","buildTarget","targetConfiguration","project","targets","Error","isCustomBuildTarget","executor","buildTargetOptions","getNxTargetOptions","configuration","viteConfigPath","normalizeViteConfigFilePath","configFile","buildOptions","otherOptions","otherOptionsFromBuild","getBuildExtraArgs","previewOptions","getExtraArgs","mode","command","outDir","staticFilePath","joinPathFragments","offsetFromRoot","outputPath","config","build","cwd","relative","mergedOptions","watch","getProxyConfig","proxyConfig","serverConfig","console","warn","server","processOnExit","closeServer","once","buildTargetOverrides","runExecutor","result","success","printUrls","resolvedUrls","local","network","baseUrl","e","error","Promise","resolve","httpServer","closeAllConnections","close","otherOptionsFromBuildTarget","schema","extraArgs","key","Object","keys","properties","previewSchemaKeys","includes"],"mappings":";;;;;;;;IAkBuBA,yBAAyB;eAAzBA;;IAiLvB,OAAyC;eAAzC;;;;wBA7LO;8BAKA;sBAGkB;2BACS;+BACI;AAE/B,gBAAgBA,0BACrBC,OAAyC,EACzCC,OAAwB;QAUtBA,yDA+CAC,wBAAAA;IAvDFC,QAAQC,GAAG,CAACC,uBAAuB,GAAG;IACtC,yFAAyF;IACzF,MAAM,EAAEC,WAAW,EAAEC,OAAO,EAAEC,kBAAkB,EAAE,GAChD,MAAMC,IAAAA,oCAAqB;IAC7B,MAAMC,cACJT,QAAQU,sBAAsB,CAACC,QAAQ,CAACX,QAAQY,WAAW,CAAC,CAACC,IAAI;IACnE,MAAMC,SAASC,IAAAA,yBAAiB,EAAChB,QAAQiB,WAAW,EAAEhB;IACtD,MAAMiB,uBACJjB,0DAAAA,QAAQU,sBAAsB,CAACC,QAAQ,CAACG,OAAOI,OAAO,CAAC,qBAAvDlB,wDAAyDmB,OAAO,CAC9DL,OAAOA,MAAM,CACd;IACH,IAAI,CAACG,qBAAqB;QACxB,MAAM,IAAIG,MAAM,CAAC,qBAAqB,EAAErB,QAAQiB,WAAW,CAAC,CAAC;IAC/D;IAEA,MAAMK,sBACJJ,oBAAoBK,QAAQ,KAAK,oBACjCL,oBAAoBK,QAAQ,KAAK;IAEnC,sDAAsD;IACtD,MAAMC,qBAA+CC,IAAAA,gCAAkB,EACrE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Ae,eACVA,cACC2C,sCAAAA,8BAA+B,CAAC;IAExC;IAEA,OAAO;QACLxC;QACAH;IACF;AACF"}
|
package/src/plugins/plugin.js
CHANGED
|
@@ -163,7 +163,8 @@ function serveStaticTarget(options) {
|
|
|
163
163
|
const targetConfig = {
|
|
164
164
|
executor: '@nx/web:file-server',
|
|
165
165
|
options: {
|
|
166
|
-
buildTarget: `${options.buildTargetName}
|
|
166
|
+
buildTarget: `${options.buildTargetName}`,
|
|
167
|
+
spa: true
|
|
167
168
|
}
|
|
168
169
|
};
|
|
169
170
|
return targetConfig;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../../packages/vite/src/plugins/plugin.ts"],"sourcesContent":["import {\n CreateDependencies,\n CreateNodes,\n CreateNodesContext,\n detectPackageManager,\n joinPathFragments,\n readJsonFile,\n TargetConfiguration,\n workspaceRoot,\n writeJsonFile,\n} from '@nx/devkit';\nimport { dirname, isAbsolute, join, relative } from 'path';\nimport { getNamedInputs } from '@nx/devkit/src/utils/get-named-inputs';\nimport { existsSync, readdirSync } from 'fs';\nimport { calculateHashForCreateNodes } from '@nx/devkit/src/utils/calculate-hash-for-create-nodes';\nimport { projectGraphCacheDirectory } from 'nx/src/utils/cache-directory';\nimport { getLockFileName } from '@nx/js';\nimport { loadViteDynamicImport } from '../utils/executor-utils';\n\nexport interface VitePluginOptions {\n buildTargetName?: string;\n testTargetName?: string;\n serveTargetName?: string;\n previewTargetName?: string;\n serveStaticTargetName?: string;\n}\n\nconst cachePath = join(projectGraphCacheDirectory, 'vite.hash');\nconst targetsCache = existsSync(cachePath) ? readTargetsCache() : {};\n\nconst calculatedTargets: Record<\n string,\n Record<string, TargetConfiguration>\n> = {};\n\nfunction readTargetsCache(): Record<\n string,\n Record<string, TargetConfiguration>\n> {\n return readJsonFile(cachePath);\n}\n\nfunction writeTargetsToCache(\n targets: Record<string, Record<string, TargetConfiguration>>\n) {\n writeJsonFile(cachePath, targets);\n}\n\nexport const createDependencies: CreateDependencies = () => {\n writeTargetsToCache(calculatedTargets);\n return [];\n};\n\nexport const createNodes: CreateNodes<VitePluginOptions> = [\n '**/{vite,vitest}.config.{js,ts,mjs,mts,cjs,cts}',\n async (configFilePath, options, context) => {\n const projectRoot = dirname(configFilePath);\n // Do not create a project if package.json and project.json isn't there.\n const siblingFiles = readdirSync(join(context.workspaceRoot, projectRoot));\n if (\n !siblingFiles.includes('package.json') &&\n !siblingFiles.includes('project.json')\n ) {\n return {};\n }\n\n options = normalizeOptions(options);\n\n const hash = calculateHashForCreateNodes(projectRoot, options, context, [\n getLockFileName(detectPackageManager(context.workspaceRoot)),\n ]);\n const targets = targetsCache[hash]\n ? targetsCache[hash]\n : await buildViteTargets(configFilePath, projectRoot, options, context);\n\n calculatedTargets[hash] = targets;\n\n return {\n projects: {\n [projectRoot]: {\n root: projectRoot,\n targets,\n },\n },\n };\n },\n];\n\nasync function buildViteTargets(\n configFilePath: string,\n projectRoot: string,\n options: VitePluginOptions,\n context: CreateNodesContext\n) {\n const absoluteConfigFilePath = joinPathFragments(\n context.workspaceRoot,\n configFilePath\n );\n\n // Workaround for the `build$3 is not a function` error that we sometimes see in agents.\n // This should be removed later once we address the issue properly\n try {\n const importEsbuild = () => new Function('return import(\"esbuild\")')();\n await importEsbuild();\n } catch {\n // do nothing\n }\n const { resolveConfig } = await loadViteDynamicImport();\n const viteConfig = await resolveConfig(\n {\n configFile: absoluteConfigFilePath,\n mode: 'development',\n },\n 'build'\n );\n\n const { buildOutputs, testOutputs, hasTest, isBuildable } = getOutputs(\n viteConfig,\n projectRoot\n );\n\n const namedInputs = getNamedInputs(projectRoot, context);\n\n const targets: Record<string, TargetConfiguration> = {};\n\n // If file is not vitest.config and buildable, create targets for build, serve, preview and serve-static\n if (!configFilePath.includes('vitest.config') && isBuildable) {\n targets[options.buildTargetName] = await buildTarget(\n options.buildTargetName,\n namedInputs,\n buildOutputs,\n projectRoot\n );\n\n targets[options.serveTargetName] = serveTarget(projectRoot);\n\n targets[options.previewTargetName] = previewTarget(projectRoot);\n\n targets[options.serveStaticTargetName] = serveStaticTarget(options) as {};\n }\n\n // if file is vitest.config or vite.config has definition for test, create target for test\n if (configFilePath.includes('vitest.config') || hasTest) {\n targets[options.testTargetName] = await testTarget(\n namedInputs,\n testOutputs,\n projectRoot\n );\n }\n\n return targets;\n}\n\nasync function buildTarget(\n buildTargetName: string,\n namedInputs: {\n [inputName: string]: any[];\n },\n outputs: string[],\n projectRoot: string\n) {\n return {\n command: `vite build`,\n options: { cwd: joinPathFragments(projectRoot) },\n cache: true,\n dependsOn: [`^${buildTargetName}`],\n inputs: [\n ...('production' in namedInputs\n ? ['production', '^production']\n : ['default', '^default']),\n {\n externalDependencies: ['vite'],\n },\n ],\n outputs,\n };\n}\n\nfunction serveTarget(projectRoot: string) {\n const targetConfig: TargetConfiguration = {\n command: `vite serve`,\n options: {\n cwd: joinPathFragments(projectRoot),\n },\n };\n\n return targetConfig;\n}\n\nfunction previewTarget(projectRoot: string) {\n const targetConfig: TargetConfiguration = {\n command: `vite preview`,\n options: {\n cwd: joinPathFragments(projectRoot),\n },\n };\n\n return targetConfig;\n}\n\nasync function testTarget(\n namedInputs: {\n [inputName: string]: any[];\n },\n outputs: string[],\n projectRoot: string\n) {\n return {\n command: `vitest run`,\n options: { cwd: joinPathFragments(projectRoot) },\n cache: true,\n inputs: [\n ...('production' in namedInputs\n ? ['default', '^production']\n : ['default', '^default']),\n {\n externalDependencies: ['vitest'],\n },\n ],\n outputs,\n };\n}\n\nfunction serveStaticTarget(options: VitePluginOptions) {\n const targetConfig: TargetConfiguration = {\n executor: '@nx/web:file-server',\n options: {\n buildTarget: `${options.buildTargetName}`,\n },\n };\n\n return targetConfig;\n}\n\nfunction getOutputs(\n viteConfig: Record<string, any> | undefined,\n projectRoot: string\n): {\n buildOutputs: string[];\n testOutputs: string[];\n hasTest: boolean;\n isBuildable: boolean;\n} {\n const { build, test } = viteConfig;\n\n const buildOutputPath = normalizeOutputPath(\n build?.outDir,\n projectRoot,\n 'dist'\n );\n\n const isBuildable =\n build?.lib ||\n build?.rollupOptions?.inputs ||\n existsSync(join(workspaceRoot, projectRoot, 'index.html'));\n\n const reportsDirectoryPath = normalizeOutputPath(\n test?.coverage?.reportsDirectory,\n projectRoot,\n 'coverage'\n );\n\n return {\n buildOutputs: [buildOutputPath],\n testOutputs: [reportsDirectoryPath],\n hasTest: !!test,\n isBuildable,\n };\n}\n\nfunction normalizeOutputPath(\n outputPath: string | undefined,\n projectRoot: string,\n path: 'coverage' | 'dist'\n): string | undefined {\n if (!outputPath) {\n if (projectRoot === '.') {\n return `{projectRoot}/${path}`;\n } else {\n return `{workspaceRoot}/${path}/{projectRoot}`;\n }\n } else {\n if (isAbsolute(outputPath)) {\n return `{workspaceRoot}/${relative(workspaceRoot, outputPath)}`;\n } else {\n if (outputPath.startsWith('..')) {\n return join('{workspaceRoot}', join(projectRoot, outputPath));\n } else {\n return join('{projectRoot}', outputPath);\n }\n }\n }\n}\n\nfunction normalizeOptions(options: VitePluginOptions): VitePluginOptions {\n options ??= {};\n options.buildTargetName ??= 'build';\n options.serveTargetName ??= 'serve';\n options.previewTargetName ??= 'preview';\n options.testTargetName ??= 'test';\n options.serveStaticTargetName ??= 'serve-static';\n return options;\n}\n"],"names":["createDependencies","createNodes","cachePath","join","projectGraphCacheDirectory","targetsCache","existsSync","readTargetsCache","calculatedTargets","readJsonFile","writeTargetsToCache","targets","writeJsonFile","configFilePath","options","context","projectRoot","dirname","siblingFiles","readdirSync","workspaceRoot","includes","normalizeOptions","hash","calculateHashForCreateNodes","getLockFileName","detectPackageManager","buildViteTargets","projects","root","absoluteConfigFilePath","joinPathFragments","importEsbuild","Function","resolveConfig","loadViteDynamicImport","viteConfig","configFile","mode","buildOutputs","testOutputs","hasTest","isBuildable","getOutputs","namedInputs","getNamedInputs","buildTargetName","buildTarget","serveTargetName","serveTarget","previewTargetName","previewTarget","serveStaticTargetName","serveStaticTarget","testTargetName","testTarget","outputs","command","cwd","cache","dependsOn","inputs","externalDependencies","targetConfig","executor","build","test","buildOutputPath","normalizeOutputPath","outDir","lib","rollupOptions","reportsDirectoryPath","coverage","reportsDirectory","outputPath","path","isAbsolute","relative","startsWith"],"mappings":";;;;;;;;IAgDaA,kBAAkB;eAAlBA;;IAKAC,WAAW;eAAXA;;;wBA3CN;sBAC6C;gCACrB;oBACS;6CACI;gCACD;oBACX;+BACM;AAUtC,MAAMC,YAAYC,IAAAA,UAAI,EAACC,0CAA0B,EAAE;AACnD,MAAMC,eAAeC,IAAAA,cAAU,EAACJ,aAAaK,qBAAqB,CAAC;AAEnE,MAAMC,oBAGF,CAAC;AAEL,SAASD;IAIP,OAAOE,IAAAA,oBAAY,EAACP;AACtB;AAEA,SAASQ,oBACPC,OAA4D;IAE5DC,IAAAA,qBAAa,EAACV,WAAWS;AAC3B;AAEO,MAAMX,qBAAyC;IACpDU,oBAAoBF;IACpB,OAAO,EAAE;AACX;AAEO,MAAMP,cAA8C;IACzD;IACA,OAAOY,gBAAgBC,SAASC;QAC9B,MAAMC,cAAcC,IAAAA,aAAO,EAACJ;QAC5B,wEAAwE;QACxE,MAAMK,eAAeC,IAAAA,eAAW,EAAChB,IAAAA,UAAI,EAACY,QAAQK,aAAa,EAAEJ;QAC7D,IACE,CAACE,aAAaG,QAAQ,CAAC,mBACvB,CAACH,aAAaG,QAAQ,CAAC,iBACvB;YACA,OAAO,CAAC;QACV;QAEAP,UAAUQ,iBAAiBR;QAE3B,MAAMS,OAAOC,IAAAA,wDAA2B,EAACR,aAAaF,SAASC,SAAS;YACtEU,IAAAA,mBAAe,EAACC,IAAAA,4BAAoB,EAACX,QAAQK,aAAa;SAC3D;QACD,MAAMT,UAAUN,YAAY,CAACkB,KAAK,GAC9BlB,YAAY,CAACkB,KAAK,GAClB,MAAMI,iBAAiBd,gBAAgBG,aAAaF,SAASC;QAEjEP,iBAAiB,CAACe,KAAK,GAAGZ;QAE1B,OAAO;YACLiB,UAAU;gBACR,CAACZ,YAAY,EAA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,kBAAoB;;IAC5BlC,uBAAAA,YAAAA,SAAQoC,kDAARpC,UAAQoC,oBAAsB;;IAC9BpC,oBAAAA,YAAAA,SAAQwC,4CAARxC,UAAQwC,iBAAmB;;IAC3BxC,2BAAAA,YAAAA,SAAQsC,0DAARtC,UAAQsC,wBAA0B;IAClC,OAAOtC;AACT"}
|
|
1
|
+
{"version":3,"sources":["../../../../../packages/vite/src/plugins/plugin.ts"],"sourcesContent":["import {\n CreateDependencies,\n CreateNodes,\n CreateNodesContext,\n detectPackageManager,\n joinPathFragments,\n readJsonFile,\n TargetConfiguration,\n workspaceRoot,\n writeJsonFile,\n} from '@nx/devkit';\nimport { dirname, isAbsolute, join, relative } from 'path';\nimport { getNamedInputs } from '@nx/devkit/src/utils/get-named-inputs';\nimport { existsSync, readdirSync } from 'fs';\nimport { calculateHashForCreateNodes } from '@nx/devkit/src/utils/calculate-hash-for-create-nodes';\nimport { projectGraphCacheDirectory } from 'nx/src/utils/cache-directory';\nimport { getLockFileName } from '@nx/js';\nimport { loadViteDynamicImport } from '../utils/executor-utils';\n\nexport interface VitePluginOptions {\n buildTargetName?: string;\n testTargetName?: string;\n serveTargetName?: string;\n previewTargetName?: string;\n serveStaticTargetName?: string;\n}\n\nconst cachePath = join(projectGraphCacheDirectory, 'vite.hash');\nconst targetsCache = existsSync(cachePath) ? readTargetsCache() : {};\n\nconst calculatedTargets: Record<\n string,\n Record<string, TargetConfiguration>\n> = {};\n\nfunction readTargetsCache(): Record<\n string,\n Record<string, TargetConfiguration>\n> {\n return readJsonFile(cachePath);\n}\n\nfunction writeTargetsToCache(\n targets: Record<string, Record<string, TargetConfiguration>>\n) {\n writeJsonFile(cachePath, targets);\n}\n\nexport const createDependencies: CreateDependencies = () => {\n writeTargetsToCache(calculatedTargets);\n return [];\n};\n\nexport const createNodes: CreateNodes<VitePluginOptions> = [\n '**/{vite,vitest}.config.{js,ts,mjs,mts,cjs,cts}',\n async (configFilePath, options, context) => {\n const projectRoot = dirname(configFilePath);\n // Do not create a project if package.json and project.json isn't there.\n const siblingFiles = readdirSync(join(context.workspaceRoot, projectRoot));\n if (\n !siblingFiles.includes('package.json') &&\n !siblingFiles.includes('project.json')\n ) {\n return {};\n }\n\n options = normalizeOptions(options);\n\n const hash = calculateHashForCreateNodes(projectRoot, options, context, [\n getLockFileName(detectPackageManager(context.workspaceRoot)),\n ]);\n const targets = targetsCache[hash]\n ? targetsCache[hash]\n : await buildViteTargets(configFilePath, projectRoot, options, context);\n\n calculatedTargets[hash] = targets;\n\n return {\n projects: {\n [projectRoot]: {\n root: projectRoot,\n targets,\n },\n },\n };\n },\n];\n\nasync function buildViteTargets(\n configFilePath: string,\n projectRoot: string,\n options: VitePluginOptions,\n context: CreateNodesContext\n) {\n const absoluteConfigFilePath = joinPathFragments(\n context.workspaceRoot,\n configFilePath\n );\n\n // Workaround for the `build$3 is not a function` error that we sometimes see in agents.\n // This should be removed later once we address the issue properly\n try {\n const importEsbuild = () => new Function('return import(\"esbuild\")')();\n await importEsbuild();\n } catch {\n // do nothing\n }\n const { resolveConfig } = await loadViteDynamicImport();\n const viteConfig = await resolveConfig(\n {\n configFile: absoluteConfigFilePath,\n mode: 'development',\n },\n 'build'\n );\n\n const { buildOutputs, testOutputs, hasTest, isBuildable } = getOutputs(\n viteConfig,\n projectRoot\n );\n\n const namedInputs = getNamedInputs(projectRoot, context);\n\n const targets: Record<string, TargetConfiguration> = {};\n\n // If file is not vitest.config and buildable, create targets for build, serve, preview and serve-static\n if (!configFilePath.includes('vitest.config') && isBuildable) {\n targets[options.buildTargetName] = await buildTarget(\n options.buildTargetName,\n namedInputs,\n buildOutputs,\n projectRoot\n );\n\n targets[options.serveTargetName] = serveTarget(projectRoot);\n\n targets[options.previewTargetName] = previewTarget(projectRoot);\n\n targets[options.serveStaticTargetName] = serveStaticTarget(options) as {};\n }\n\n // if file is vitest.config or vite.config has definition for test, create target for test\n if (configFilePath.includes('vitest.config') || hasTest) {\n targets[options.testTargetName] = await testTarget(\n namedInputs,\n testOutputs,\n projectRoot\n );\n }\n\n return targets;\n}\n\nasync function buildTarget(\n buildTargetName: string,\n namedInputs: {\n [inputName: string]: any[];\n },\n outputs: string[],\n projectRoot: string\n) {\n return {\n command: `vite build`,\n options: { cwd: joinPathFragments(projectRoot) },\n cache: true,\n dependsOn: [`^${buildTargetName}`],\n inputs: [\n ...('production' in namedInputs\n ? ['production', '^production']\n : ['default', '^default']),\n {\n externalDependencies: ['vite'],\n },\n ],\n outputs,\n };\n}\n\nfunction serveTarget(projectRoot: string) {\n const targetConfig: TargetConfiguration = {\n command: `vite serve`,\n options: {\n cwd: joinPathFragments(projectRoot),\n },\n };\n\n return targetConfig;\n}\n\nfunction previewTarget(projectRoot: string) {\n const targetConfig: TargetConfiguration = {\n command: `vite preview`,\n options: {\n cwd: joinPathFragments(projectRoot),\n },\n };\n\n return targetConfig;\n}\n\nasync function testTarget(\n namedInputs: {\n [inputName: string]: any[];\n },\n outputs: string[],\n projectRoot: string\n) {\n return {\n command: `vitest run`,\n options: { cwd: joinPathFragments(projectRoot) },\n cache: true,\n inputs: [\n ...('production' in namedInputs\n ? ['default', '^production']\n : ['default', '^default']),\n {\n externalDependencies: ['vitest'],\n },\n ],\n outputs,\n };\n}\n\nfunction serveStaticTarget(options: VitePluginOptions) {\n const targetConfig: TargetConfiguration = {\n executor: '@nx/web:file-server',\n options: {\n buildTarget: `${options.buildTargetName}`,\n spa: true,\n },\n };\n\n return targetConfig;\n}\n\nfunction getOutputs(\n viteConfig: Record<string, any> | undefined,\n projectRoot: string\n): {\n buildOutputs: string[];\n testOutputs: string[];\n hasTest: boolean;\n isBuildable: boolean;\n} {\n const { build, test } = viteConfig;\n\n const buildOutputPath = normalizeOutputPath(\n build?.outDir,\n projectRoot,\n 'dist'\n );\n\n const isBuildable =\n build?.lib ||\n build?.rollupOptions?.inputs ||\n existsSync(join(workspaceRoot, projectRoot, 'index.html'));\n\n const reportsDirectoryPath = normalizeOutputPath(\n test?.coverage?.reportsDirectory,\n projectRoot,\n 'coverage'\n );\n\n return {\n buildOutputs: [buildOutputPath],\n testOutputs: [reportsDirectoryPath],\n hasTest: !!test,\n isBuildable,\n };\n}\n\nfunction normalizeOutputPath(\n outputPath: string | undefined,\n projectRoot: string,\n path: 'coverage' | 'dist'\n): string | undefined {\n if (!outputPath) {\n if (projectRoot === '.') {\n return `{projectRoot}/${path}`;\n } else {\n return `{workspaceRoot}/${path}/{projectRoot}`;\n }\n } else {\n if (isAbsolute(outputPath)) {\n return `{workspaceRoot}/${relative(workspaceRoot, outputPath)}`;\n } else {\n if (outputPath.startsWith('..')) {\n return join('{workspaceRoot}', join(projectRoot, outputPath));\n } else {\n return join('{projectRoot}', outputPath);\n }\n }\n }\n}\n\nfunction normalizeOptions(options: VitePluginOptions): VitePluginOptions {\n options ??= {};\n options.buildTargetName ??= 'build';\n options.serveTargetName ??= 'serve';\n options.previewTargetName ??= 'preview';\n options.testTargetName ??= 'test';\n options.serveStaticTargetName ??= 'serve-static';\n return options;\n}\n"],"names":["createDependencies","createNodes","cachePath","join","projectGraphCacheDirectory","targetsCache","existsSync","readTargetsCache","calculatedTargets","readJsonFile","writeTargetsToCache","targets","writeJsonFile","configFilePath","options","context","projectRoot","dirname","siblingFiles","readdirSync","workspaceRoot","includes","normalizeOptions","hash","calculateHashForCreateNodes","getLockFileName","detectPackageManager","buildViteTargets","projects","root","absoluteConfigFilePath","joinPathFragments","importEsbuild","Function","resolveConfig","loadViteDynamicImport","viteConfig","configFile","mode","buildOutputs","testOutputs","hasTest","isBuildable","getOutputs","namedInputs","getNamedInputs","buildTargetName","buildTarget","serveTargetName","serveTarget","previewTargetName","previewTarget","serveStaticTargetName","serveStaticTarget","testTargetName","testTarget","outputs","command","cwd","cache","dependsOn","inputs","externalDependencies","targetConfig","executor","spa","build","test","buildOutputPath","normalizeOutputPath","outDir","lib","rollupOptions","reportsDirectoryPath","coverage","reportsDirectory","outputPath","path","isAbsolute","relative","startsWith"],"mappings":";;;;;;;;IAgDaA,k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