vike 0.4.223-commit-62ca594 → 0.4.223-commit-33cc798
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/dist/cjs/node/plugin/plugins/build/{pluginAssetsManifest/fixServerAssets.js → handleAssetsManifest.js} +69 -28
- package/dist/cjs/node/plugin/plugins/build/pluginAutoFullBuild.js +38 -29
- package/dist/cjs/node/plugin/plugins/build/pluginBuildApp.js +4 -31
- package/dist/cjs/node/plugin/plugins/build/pluginBuildConfig.js +9 -5
- package/dist/cjs/node/plugin/plugins/build/pluginBuildEntry.js +1 -1
- package/dist/cjs/node/plugin/plugins/build/pluginDistFileNames.js +1 -1
- package/dist/cjs/node/plugin/plugins/build/pluginDistPackageJsonFile.js +2 -2
- package/dist/cjs/node/plugin/plugins/build.js +0 -2
- package/dist/cjs/node/plugin/plugins/commonConfig.js +1 -0
- package/dist/cjs/node/plugin/plugins/envVars.js +2 -2
- package/dist/cjs/node/plugin/plugins/extractAssetsPlugin.js +9 -9
- package/dist/cjs/node/plugin/plugins/extractExportNamesPlugin.js +2 -2
- package/dist/cjs/node/plugin/plugins/importUserCode/getVirtualFileImportUserCode.js +3 -3
- package/dist/cjs/node/plugin/plugins/importUserCode/index.js +2 -5
- package/dist/cjs/node/plugin/plugins/importUserCode/v1-design/getVikeConfig.js +3 -2
- package/dist/cjs/node/plugin/plugins/importUserCode/v1-design/virtual-files/getVirtualFilePageConfigValuesAll.js +4 -4
- package/dist/cjs/node/plugin/shared/getFullBuildInlineConfig.js +1 -0
- package/dist/cjs/node/plugin/shared/getOutDirs.js +8 -7
- package/dist/cjs/node/plugin/shared/isViteServerBuild.js +47 -0
- package/dist/cjs/node/prerender/runPrerender.js +1 -0
- package/dist/cjs/utils/PROJECT_VERSION.js +1 -1
- package/dist/cjs/utils/requireResolve.js +7 -0
- package/dist/esm/node/plugin/plugins/build/handleAssetsManifest.d.ts +18 -0
- package/dist/esm/node/plugin/plugins/build/{pluginAssetsManifest/fixServerAssets.js → handleAssetsManifest.js} +69 -28
- package/dist/esm/node/plugin/plugins/build/pluginAutoFullBuild.d.ts +2 -0
- package/dist/esm/node/plugin/plugins/build/pluginAutoFullBuild.js +39 -30
- package/dist/esm/node/plugin/plugins/build/pluginBuildApp.js +5 -32
- package/dist/esm/node/plugin/plugins/build/pluginBuildConfig.js +9 -5
- package/dist/esm/node/plugin/plugins/build/pluginBuildEntry.d.ts +0 -1
- package/dist/esm/node/plugin/plugins/build/pluginBuildEntry.js +1 -1
- package/dist/esm/node/plugin/plugins/build/pluginDistFileNames.js +1 -1
- package/dist/esm/node/plugin/plugins/build/pluginDistPackageJsonFile.js +2 -2
- package/dist/esm/node/plugin/plugins/build.js +0 -2
- package/dist/esm/node/plugin/plugins/commonConfig.d.ts +1 -0
- package/dist/esm/node/plugin/plugins/commonConfig.js +1 -0
- package/dist/esm/node/plugin/plugins/envVars.js +2 -2
- package/dist/esm/node/plugin/plugins/extractAssetsPlugin.js +10 -10
- package/dist/esm/node/plugin/plugins/extractExportNamesPlugin.js +2 -2
- package/dist/esm/node/plugin/plugins/importUserCode/getVirtualFileImportUserCode.js +3 -3
- package/dist/esm/node/plugin/plugins/importUserCode/index.js +2 -5
- package/dist/esm/node/plugin/plugins/importUserCode/v1-design/getVikeConfig.d.ts +2 -2
- package/dist/esm/node/plugin/plugins/importUserCode/v1-design/getVikeConfig.js +3 -2
- package/dist/esm/node/plugin/plugins/importUserCode/v1-design/virtual-files/getVirtualFilePageConfigValuesAll.js +4 -4
- package/dist/esm/node/plugin/shared/getFullBuildInlineConfig.js +1 -0
- package/dist/esm/node/plugin/shared/getOutDirs.d.ts +2 -2
- package/dist/esm/node/plugin/shared/getOutDirs.js +8 -7
- package/dist/esm/node/plugin/shared/isViteServerBuild.d.ts +15 -0
- package/dist/esm/node/plugin/shared/isViteServerBuild.js +45 -0
- package/dist/esm/node/prerender/runPrerender.js +1 -0
- package/dist/esm/utils/PROJECT_VERSION.d.ts +1 -1
- package/dist/esm/utils/PROJECT_VERSION.js +1 -1
- package/dist/esm/utils/projectInfo.d.ts +1 -1
- package/dist/esm/utils/requireResolve.js +7 -0
- package/package.json +1 -1
- package/dist/cjs/node/plugin/plugins/build/pluginAssetsManifest.js +0 -115
- package/dist/cjs/node/plugin/shared/viteIsSSR.js +0 -31
- package/dist/esm/node/plugin/plugins/build/pluginAssetsManifest/fixServerAssets.d.ts +0 -22
- package/dist/esm/node/plugin/plugins/build/pluginAssetsManifest.d.ts +0 -3
- package/dist/esm/node/plugin/plugins/build/pluginAssetsManifest.js +0 -110
- package/dist/esm/node/plugin/shared/viteIsSSR.d.ts +0 -11
- package/dist/esm/node/plugin/shared/viteIsSSR.js +0 -29
|
@@ -13,11 +13,11 @@ import { isAsset } from '../shared/isAsset.js';
|
|
|
13
13
|
import { getImportStatements } from '../shared/parseEsModule.js';
|
|
14
14
|
import { sourceMapRemove } from '../shared/rollupSourceMap.js';
|
|
15
15
|
import pc from '@brillout/picocolors';
|
|
16
|
-
import {
|
|
17
|
-
import { getVikeConfig
|
|
16
|
+
import { handleAssetsManifest_isFixEnabled } from './build/handleAssetsManifest.js';
|
|
17
|
+
import { getVikeConfig } from './importUserCode/v1-design/getVikeConfig.js';
|
|
18
18
|
import { assertV1Design } from '../../shared/assertV1Design.js';
|
|
19
19
|
import { normalizeId } from '../shared/normalizeId.js';
|
|
20
|
-
import {
|
|
20
|
+
import { isViteServerBuild_safe } from '../shared/isViteServerBuild.js';
|
|
21
21
|
const extractAssetsRE = /(\?|&)extractAssets(?:&|$)/;
|
|
22
22
|
const rawRE = /(\?|&)raw(?:&|$)/;
|
|
23
23
|
const urlRE = /(\?|&)url(?:&|$)/;
|
|
@@ -26,7 +26,7 @@ const debug = createDebugger('vike:extractAssets');
|
|
|
26
26
|
function extractAssetsPlugin() {
|
|
27
27
|
let config;
|
|
28
28
|
let vikeConfig;
|
|
29
|
-
let
|
|
29
|
+
let isFixEnabled;
|
|
30
30
|
return [
|
|
31
31
|
// This plugin removes all JavaScript from server-side only code, so that only CSS imports remains. (And also satic files imports e.g. `import logoURL from './logo.svg.js'`).
|
|
32
32
|
{
|
|
@@ -39,14 +39,14 @@ function extractAssetsPlugin() {
|
|
|
39
39
|
if (!extractAssetsRE.test(id)) {
|
|
40
40
|
return;
|
|
41
41
|
}
|
|
42
|
-
if (
|
|
43
|
-
// I'm guessing
|
|
42
|
+
if (isFixEnabled) {
|
|
43
|
+
// I'm guessing isFixEnabled can only be true when mixing both designs: https://github.com/vikejs/vike/issues/1480
|
|
44
44
|
assertV1Design(vikeConfig.pageConfigs, true);
|
|
45
45
|
assert(false);
|
|
46
46
|
}
|
|
47
47
|
// TODO/now: add meta.default
|
|
48
48
|
assert(vikeConfig.global.config.includeAssetsImportedByServer ?? true);
|
|
49
|
-
assert(!
|
|
49
|
+
assert(!isViteServerBuild_safe(config, options));
|
|
50
50
|
const importStatements = await getImportStatements(src);
|
|
51
51
|
const moduleNames = getImportedModules(importStatements);
|
|
52
52
|
const code = moduleNames.map((moduleName) => `import '${moduleName}';`).join('\n');
|
|
@@ -63,7 +63,7 @@ function extractAssetsPlugin() {
|
|
|
63
63
|
// - Vite's `vite:resolve` plugin; https://github.com/vitejs/vite/blob/d649daba7682791178b711d9a3e44a6b5d00990c/packages/vite/src/node/plugins/resolve.ts#L105
|
|
64
64
|
enforce: 'pre',
|
|
65
65
|
async resolveId(source, importer, options) {
|
|
66
|
-
if (
|
|
66
|
+
if (isViteServerBuild_safe(config, options)) {
|
|
67
67
|
// When building for the server, there should never be a `?extractAssets` query
|
|
68
68
|
assert(!extractAssetsRE.test(source));
|
|
69
69
|
assert(importer === undefined || !extractAssetsRE.test(importer));
|
|
@@ -140,8 +140,8 @@ function extractAssetsPlugin() {
|
|
|
140
140
|
async configResolved(config_) {
|
|
141
141
|
config = config_;
|
|
142
142
|
vikeConfig = await getVikeConfig(config);
|
|
143
|
-
|
|
144
|
-
if (!
|
|
143
|
+
isFixEnabled = handleAssetsManifest_isFixEnabled(config);
|
|
144
|
+
if (!isFixEnabled) {
|
|
145
145
|
// https://github.com/vikejs/vike/issues/1060
|
|
146
146
|
assertUsage(!config.plugins.find((p) => p.name === 'vite-tsconfig-paths'), 'vite-tsconfig-paths not supported, remove it and use vite.config.js#resolve.alias instead');
|
|
147
147
|
}
|
|
@@ -5,7 +5,7 @@ import { assert, getFileExtension, createDebugger, getGlobalObject, assertUsage
|
|
|
5
5
|
import { getExportNames } from '../shared/parseEsModule.js';
|
|
6
6
|
import { sourceMapRemove } from '../shared/rollupSourceMap.js';
|
|
7
7
|
import { normalizeId } from '../shared/normalizeId.js';
|
|
8
|
-
import {
|
|
8
|
+
import { isViteServerBuild_options } from '../shared/isViteServerBuild.js';
|
|
9
9
|
const extractExportNamesRE = /(\?|&)extractExportNames(?:&|$)/;
|
|
10
10
|
const debug = createDebugger('vike:extractExportNames');
|
|
11
11
|
const globalObject = getGlobalObject('plugins/extractExportNamesPlugin.ts', {});
|
|
@@ -16,7 +16,7 @@ function extractExportNamesPlugin() {
|
|
|
16
16
|
enforce: 'post',
|
|
17
17
|
async transform(src, id, options) {
|
|
18
18
|
id = normalizeId(id);
|
|
19
|
-
const isClientSide = !
|
|
19
|
+
const isClientSide = !isViteServerBuild_options(options);
|
|
20
20
|
if (extractExportNamesRE.test(id)) {
|
|
21
21
|
const code = await getExtractExportNamesCode(src, isClientSide, !isDev, id);
|
|
22
22
|
debug('id ' + id, ['result:\n' + code.code.trim(), 'src:\n' + src.trim()]);
|
|
@@ -7,12 +7,12 @@ import path from 'path';
|
|
|
7
7
|
import { getVirtualFilePageConfigs } from './v1-design/virtual-files/getVirtualFilePageConfigs.js';
|
|
8
8
|
import { isV1Design as isV1Design_ } from './v1-design/getVikeConfig.js';
|
|
9
9
|
import { getOutDirs } from '../../shared/getOutDirs.js';
|
|
10
|
-
import {
|
|
10
|
+
import { isViteServerBuild_options } from '../../shared/isViteServerBuild.js';
|
|
11
11
|
async function getVirtualFileImportUserCode(id, options, vikeConfig, config, isDev) {
|
|
12
12
|
const idParsed = isVirtualFileIdImportUserCode(id);
|
|
13
13
|
assert(idParsed);
|
|
14
14
|
const { isForClientSide, isClientRouting } = idParsed;
|
|
15
|
-
assert(isForClientSide === !
|
|
15
|
+
assert(isForClientSide === !isViteServerBuild_options(options));
|
|
16
16
|
const code = await getCode(config, vikeConfig, isForClientSide, isClientRouting, isDev, id);
|
|
17
17
|
return code;
|
|
18
18
|
}
|
|
@@ -69,7 +69,7 @@ ${await getVirtualFilePageConfigs(isForClientSide, isDev, id, isClientRouting, c
|
|
|
69
69
|
|
|
70
70
|
`;
|
|
71
71
|
// We still use import.meta.glob() when using th V1 design in order to not break the V1 design deprecation warning
|
|
72
|
-
const isV1Design =
|
|
72
|
+
const isV1Design = isV1Design_(config);
|
|
73
73
|
// Old design => no + files => only to enable pre-rendering is setting `vike({prerender})` in vite.config.js
|
|
74
74
|
const isPrerendering = !!vikeConfig.global.config.prerender;
|
|
75
75
|
fileTypes
|
|
@@ -21,11 +21,8 @@ function importUserCode() {
|
|
|
21
21
|
vikeConfig = await getVikeConfig(config_);
|
|
22
22
|
config = config_;
|
|
23
23
|
// TODO/v1-release: remove
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
if (!isV1)
|
|
27
|
-
config.experimental.importGlobRestoreExtension = true;
|
|
28
|
-
}
|
|
24
|
+
if (!isV1Design(config))
|
|
25
|
+
config.experimental.importGlobRestoreExtension = true;
|
|
29
26
|
},
|
|
30
27
|
resolveId(id) {
|
|
31
28
|
if (isVirtualFileId(id)) {
|
|
@@ -8,7 +8,7 @@ export { getConfigDefinitionOptional };
|
|
|
8
8
|
export type { VikeConfigObject };
|
|
9
9
|
import type { PageConfigGlobalBuildTime, PageConfigBuildTime } from '../../../../../shared/page-configs/PageConfig.js';
|
|
10
10
|
import { type ConfigDefinitions, type ConfigDefinitionInternal } from './getVikeConfig/configDefinitionsBuiltIn.js';
|
|
11
|
-
import type { ResolvedConfig } from 'vite';
|
|
11
|
+
import type { ResolvedConfig, UserConfig } from 'vite';
|
|
12
12
|
import { type PageConfigUserFriendly, type PageConfigsUserFriendly } from '../../../../../shared/page-configs/getPageConfigUserFriendly.js';
|
|
13
13
|
import { type PlusFile } from './getVikeConfig/getPlusFilesAll.js';
|
|
14
14
|
type VikeConfigObject = {
|
|
@@ -23,7 +23,7 @@ declare function getVikeConfig(config: ResolvedConfig, { doNotRestartViteOnError
|
|
|
23
23
|
doNotRestartViteOnError?: true;
|
|
24
24
|
}): Promise<VikeConfigObject>;
|
|
25
25
|
declare function getVikeConfig2(userRootDir: string, isDev: boolean, vikeVitePluginOptions: unknown): Promise<VikeConfigObject>;
|
|
26
|
-
declare function isV1Design(config: ResolvedConfig):
|
|
26
|
+
declare function isV1Design(config: ResolvedConfig | UserConfig): boolean;
|
|
27
27
|
declare function getConfigDefinitionOptional(configDefinitions: ConfigDefinitions, configName: string): ConfigDefinitionInternal | null;
|
|
28
28
|
declare function getConfVal(plusFile: PlusFile, configName: string): null | {
|
|
29
29
|
value: unknown;
|
|
@@ -85,8 +85,9 @@ async function getVikeConfigEntry(userRootDir, isDev, vikeVitePluginOptions, doN
|
|
|
85
85
|
}
|
|
86
86
|
return await vikeConfigPromise;
|
|
87
87
|
}
|
|
88
|
-
|
|
89
|
-
const vikeConfig =
|
|
88
|
+
function isV1Design(config) {
|
|
89
|
+
const vikeConfig = config._vikeConfigObject;
|
|
90
|
+
assert(vikeConfig);
|
|
90
91
|
const { pageConfigs } = vikeConfig;
|
|
91
92
|
const isV1Design = pageConfigs.length > 0;
|
|
92
93
|
return isV1Design;
|
|
@@ -6,7 +6,7 @@ import { extractAssetsAddQuery } from '../../../../../shared/extractAssetsQuery.
|
|
|
6
6
|
import { debug } from './debug.js';
|
|
7
7
|
import { isRuntimeEnvMatch } from './isRuntimeEnvMatch.js';
|
|
8
8
|
import { serializeConfigValues } from '../../../../../../shared/page-configs/serialize/serializeConfigValues.js';
|
|
9
|
-
import {
|
|
9
|
+
import { handleAssetsManifest_isFixEnabled } from '../../../build/handleAssetsManifest.js';
|
|
10
10
|
import { getConfigValueBuildTime } from '../../../../../../shared/page-configs/getConfigValueBuildTime.js';
|
|
11
11
|
async function getVirtualFilePageConfigValuesAll(id, isDev, config) {
|
|
12
12
|
const result = isVirtualFileIdPageConfigValuesAll(id);
|
|
@@ -24,11 +24,11 @@ async function getVirtualFilePageConfigValuesAll(id, isDev, config) {
|
|
|
24
24
|
assert(pageConfig, { id, pageId });
|
|
25
25
|
const code = getLoadConfigValuesAll(pageConfig, isForClientSide, pageId,
|
|
26
26
|
// TODO/now: add meta.default
|
|
27
|
-
vikeConfig.global.config.includeAssetsImportedByServer ?? true, isDev);
|
|
27
|
+
vikeConfig.global.config.includeAssetsImportedByServer ?? true, config, isDev);
|
|
28
28
|
debug(id, isForClientSide ? 'CLIENT-SIDE' : 'SERVER-SIDE', code);
|
|
29
29
|
return code;
|
|
30
30
|
}
|
|
31
|
-
function getLoadConfigValuesAll(pageConfig, isForClientSide, pageId, includeAssetsImportedByServer, isDev) {
|
|
31
|
+
function getLoadConfigValuesAll(pageConfig, isForClientSide, pageId, includeAssetsImportedByServer, config, isDev) {
|
|
32
32
|
const lines = [];
|
|
33
33
|
const importStatements = [];
|
|
34
34
|
const filesEnv = new Map();
|
|
@@ -36,7 +36,7 @@ function getLoadConfigValuesAll(pageConfig, isForClientSide, pageId, includeAsse
|
|
|
36
36
|
lines.push('export const configValuesSerialized = {');
|
|
37
37
|
lines.push(...serializeConfigValues(pageConfig, importStatements, filesEnv, (configEnv) => isRuntimeEnvMatch(configEnv, { isForClientSide, isClientRouting, isDev }), '', false));
|
|
38
38
|
lines.push('};');
|
|
39
|
-
if (!
|
|
39
|
+
if (!handleAssetsManifest_isFixEnabled(config) && includeAssetsImportedByServer && isForClientSide && !isDev) {
|
|
40
40
|
importStatements.push(`import '${extractAssetsAddQuery(getVirtualFileIdPageConfigValuesAll(pageId, false))}'`);
|
|
41
41
|
}
|
|
42
42
|
const code = [...importStatements, ...lines].join('\n');
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
export { getOutDirs };
|
|
2
2
|
export { resolveOutDir };
|
|
3
3
|
export type { OutDirs };
|
|
4
|
-
import type { UserConfig, ResolvedConfig } from 'vite';
|
|
4
|
+
import type { UserConfig, ResolvedConfig, Environment } from 'vite';
|
|
5
5
|
type OutDirs = {
|
|
6
6
|
/** Absolute path to `outDir` */
|
|
7
7
|
outDirRoot: string;
|
|
@@ -10,6 +10,6 @@ type OutDirs = {
|
|
|
10
10
|
/** Absolute path to `${outDir}/server` */
|
|
11
11
|
outDirServer: string;
|
|
12
12
|
};
|
|
13
|
-
declare function getOutDirs(
|
|
13
|
+
declare function getOutDirs(configGlobal: ResolvedConfig, viteEnv?: Environment): OutDirs;
|
|
14
14
|
/** Appends `client/` or `server/` to `config.build.outDir` */
|
|
15
15
|
declare function resolveOutDir(config: UserConfig, isSSR?: true): string;
|
|
@@ -2,20 +2,21 @@ export { getOutDirs };
|
|
|
2
2
|
export { resolveOutDir };
|
|
3
3
|
import pc from '@brillout/picocolors';
|
|
4
4
|
import { assert, assertPosixPath, assertUsage, createDebugger, pathJoin, toPosixPath } from '../utils.js';
|
|
5
|
-
import {
|
|
5
|
+
import { isViteServerBuild } from './isViteServerBuild.js';
|
|
6
6
|
const debug = createDebugger('vike:outDir');
|
|
7
|
-
function getOutDirs(
|
|
7
|
+
function getOutDirs(configGlobal, viteEnv) {
|
|
8
|
+
const configEnv = viteEnv?.config ?? configGlobal;
|
|
8
9
|
debug('getOutDirs()', new Error().stack);
|
|
9
|
-
const outDir = getOutDirFromViteResolvedConfig(
|
|
10
|
+
const outDir = getOutDirFromViteResolvedConfig(configEnv);
|
|
10
11
|
if (!isOutDirRoot(outDir))
|
|
11
|
-
assertOutDirResolved(outDir,
|
|
12
|
-
const outDirs = getOutDirsAll(outDir,
|
|
12
|
+
assertOutDirResolved(outDir, configEnv);
|
|
13
|
+
const outDirs = getOutDirsAll(outDir, configEnv.root);
|
|
13
14
|
return outDirs;
|
|
14
15
|
}
|
|
15
16
|
/** Appends `client/` or `server/` to `config.build.outDir` */
|
|
16
17
|
function resolveOutDir(config, isSSR) {
|
|
17
18
|
debug('resolveOutDir()', new Error().stack);
|
|
18
|
-
const isServerSide =
|
|
19
|
+
const isServerSide = isViteServerBuild(config) || isSSR;
|
|
19
20
|
debug('isServerSide', isServerSide);
|
|
20
21
|
const outDir = getOutDirFromViteUserConfig(config) || 'dist';
|
|
21
22
|
debug('outDir', outDir);
|
|
@@ -104,7 +105,7 @@ function assertOutDirResolved(outDir, config) {
|
|
|
104
105
|
assert('/client'.length === '/server'.length);
|
|
105
106
|
const outDirCorrected = outDir.slice(0, -1 * '/client'.length);
|
|
106
107
|
const wrongUsage = `You've set Vite's config.build.outDir to ${pc.cyan(outDir)} but you should set it to ${pc.cyan(outDirCorrected)} instead.`;
|
|
107
|
-
if (
|
|
108
|
+
if (isViteServerBuild(config)) {
|
|
108
109
|
assertUsage(outDir.endsWith('/server'), wrongUsage);
|
|
109
110
|
}
|
|
110
111
|
else {
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
export { isViteServerBuild };
|
|
2
|
+
export { isViteClientBuild };
|
|
3
|
+
export { isViteServerBuild_options };
|
|
4
|
+
export { isViteServerBuild_safe };
|
|
5
|
+
export { isViteServerBuild_onlySsrEnv };
|
|
6
|
+
import type { Environment, ResolvedConfig, UserConfig } from 'vite';
|
|
7
|
+
declare function isViteServerBuild(configGlobal: ResolvedConfig | UserConfig, viteEnv?: Environment): boolean;
|
|
8
|
+
declare function isViteServerBuild_onlySsrEnv(configGlobal: ResolvedConfig, viteEnv: Environment | undefined): boolean;
|
|
9
|
+
declare function isViteClientBuild(configGlobal: ResolvedConfig, viteEnv: Environment): boolean;
|
|
10
|
+
declare function isViteServerBuild_options(options: {
|
|
11
|
+
ssr?: boolean;
|
|
12
|
+
} | undefined): boolean;
|
|
13
|
+
declare function isViteServerBuild_safe(config: ResolvedConfig, options: {
|
|
14
|
+
ssr?: boolean;
|
|
15
|
+
} | undefined): boolean;
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
export { isViteServerBuild };
|
|
2
|
+
export { isViteClientBuild };
|
|
3
|
+
export { isViteServerBuild_options };
|
|
4
|
+
export { isViteServerBuild_safe };
|
|
5
|
+
export { isViteServerBuild_onlySsrEnv };
|
|
6
|
+
import { assert } from '../../../utils/assert.js';
|
|
7
|
+
function isViteServerBuild(configGlobal, viteEnv) {
|
|
8
|
+
const configEnv = viteEnv?.config ?? configGlobal;
|
|
9
|
+
return !!configEnv?.build?.ssr;
|
|
10
|
+
}
|
|
11
|
+
// Only `ssr` env: for example don't include `vercel_edge` nor `vercel_node`.
|
|
12
|
+
function isViteServerBuild_onlySsrEnv(configGlobal, viteEnv) {
|
|
13
|
+
return viteEnv ? viteEnv.name === 'ssr' : isViteServerBuild(configGlobal);
|
|
14
|
+
}
|
|
15
|
+
function isViteClientBuild(configGlobal, viteEnv) {
|
|
16
|
+
const yes = !isViteServerBuild(configGlobal, viteEnv);
|
|
17
|
+
const isVite5 = viteEnv === undefined;
|
|
18
|
+
if (!isVite5) {
|
|
19
|
+
const yes2 = viteEnv.name === 'client';
|
|
20
|
+
assert(yes === yes2);
|
|
21
|
+
}
|
|
22
|
+
return yes;
|
|
23
|
+
}
|
|
24
|
+
function isViteServerBuild_options(options) {
|
|
25
|
+
return !!options?.ssr;
|
|
26
|
+
}
|
|
27
|
+
// Vite is quite messy about setting `ssr: boolean`, thus we use an extra safe implemention for security purposes.
|
|
28
|
+
// It's used for .client.js and .server.js guarantee thus we use agressive assert() calls for added safety.
|
|
29
|
+
function isViteServerBuild_safe(config, options) {
|
|
30
|
+
if (config.command === 'build') {
|
|
31
|
+
assert(typeof config.build.ssr === 'boolean');
|
|
32
|
+
const val = config.build.ssr;
|
|
33
|
+
if (options?.ssr !== undefined)
|
|
34
|
+
assert(val === options.ssr);
|
|
35
|
+
return val;
|
|
36
|
+
}
|
|
37
|
+
else {
|
|
38
|
+
assert(typeof options?.ssr === 'boolean');
|
|
39
|
+
const val = options.ssr;
|
|
40
|
+
/* This assert() fails (which is very unexpected).
|
|
41
|
+
if (typeof config.build.ssr === 'boolean') assert(val === config.build.ssr)
|
|
42
|
+
//*/
|
|
43
|
+
return val;
|
|
44
|
+
}
|
|
45
|
+
}
|
|
@@ -57,6 +57,7 @@ async function runPrerenderFromAutoRun(viteConfig, config) {
|
|
|
57
57
|
prerenderContextPublic = ret.prerenderContextPublic;
|
|
58
58
|
}
|
|
59
59
|
catch (err) {
|
|
60
|
+
// Avoid Rollup prefixing the error with [vike:build:pluginAutoFullBuild], see for example https://github.com/vikejs/vike/issues/472#issuecomment-1276274203
|
|
60
61
|
console.error(err);
|
|
61
62
|
logErrorHint(err);
|
|
62
63
|
process.exit(1);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const PROJECT_VERSION: "0.4.223-commit-
|
|
1
|
+
export declare const PROJECT_VERSION: "0.4.223-commit-33cc798";
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
// Automatically updated by @brillout/release-me
|
|
2
|
-
export const PROJECT_VERSION = '0.4.223-commit-
|
|
2
|
+
export const PROJECT_VERSION = '0.4.223-commit-33cc798';
|
|
@@ -32,6 +32,13 @@ function requireResolve(importPath, cwd) {
|
|
|
32
32
|
return importedFile;
|
|
33
33
|
}
|
|
34
34
|
function removeFileExtention(importPath) {
|
|
35
|
+
// Skip for Bun: https://github.com/vikejs/vike/issues/2204
|
|
36
|
+
//@ts-ignore
|
|
37
|
+
if (typeof Bun !== 'undefined') {
|
|
38
|
+
// https://bun.sh/guides/util/detect-bun
|
|
39
|
+
assert(process.versions.bun);
|
|
40
|
+
return importPath;
|
|
41
|
+
}
|
|
35
42
|
for (const ext of scriptFileExtensionList) {
|
|
36
43
|
const suffix = `.${ext}`;
|
|
37
44
|
if (importPath.endsWith(suffix)) {
|
package/package.json
CHANGED
|
@@ -1,115 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
-
};
|
|
5
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.pluginAssetsManifest = pluginAssetsManifest;
|
|
7
|
-
const getVikeConfig_js_1 = require("../importUserCode/v1-design/getVikeConfig.js");
|
|
8
|
-
const promises_1 = __importDefault(require("fs/promises"));
|
|
9
|
-
const path_1 = __importDefault(require("path"));
|
|
10
|
-
const fixServerAssets_js_1 = require("../build/pluginAssetsManifest/fixServerAssets.js");
|
|
11
|
-
const pluginBuildEntry_js_1 = require("./pluginBuildEntry.js");
|
|
12
|
-
const getOutDirs_js_1 = require("../../shared/getOutDirs.js");
|
|
13
|
-
const viteIsSSR_js_1 = require("../../shared/viteIsSSR.js");
|
|
14
|
-
const commonConfig_js_1 = require("../commonConfig.js");
|
|
15
|
-
const manifestTempFile = '_temp_manifest.json';
|
|
16
|
-
function pluginAssetsManifest() {
|
|
17
|
-
let isServerAssetsFixEnabled;
|
|
18
|
-
let config;
|
|
19
|
-
let assetsJsonFilePath;
|
|
20
|
-
return [
|
|
21
|
-
{
|
|
22
|
-
name: 'vike:build:pluginAssetsManifest:post',
|
|
23
|
-
apply: 'build',
|
|
24
|
-
enforce: 'post',
|
|
25
|
-
configResolved: {
|
|
26
|
-
order: 'post',
|
|
27
|
-
async handler(config_) {
|
|
28
|
-
config = config_;
|
|
29
|
-
isServerAssetsFixEnabled = (0, fixServerAssets_js_1.fixServerAssets_isEnabled)() && (await (0, getVikeConfig_js_1.isV1Design)(config));
|
|
30
|
-
if (isServerAssetsFixEnabled) {
|
|
31
|
-
// https://github.com/vikejs/vike/issues/1339
|
|
32
|
-
config.build.ssrEmitAssets = true;
|
|
33
|
-
// Required if `ssrEmitAssets: true`, see https://github.com/vitejs/vite/pull/11430#issuecomment-1454800934
|
|
34
|
-
config.build.cssMinify = 'esbuild';
|
|
35
|
-
(0, fixServerAssets_js_1.fixServerAssets_assertUsageCssCodeSplit)(config);
|
|
36
|
-
}
|
|
37
|
-
}
|
|
38
|
-
},
|
|
39
|
-
config: {
|
|
40
|
-
order: 'post',
|
|
41
|
-
handler(config) {
|
|
42
|
-
const vike = (0, commonConfig_js_1.getVikeConfigPublic)(config);
|
|
43
|
-
return {
|
|
44
|
-
build: {
|
|
45
|
-
manifest: manifestTempFile,
|
|
46
|
-
copyPublicDir: vike.config.viteEnvironmentAPI
|
|
47
|
-
? // Already set by vike:build:pluginBuildApp
|
|
48
|
-
undefined
|
|
49
|
-
: !(0, viteIsSSR_js_1.viteIsSSR)(config)
|
|
50
|
-
}
|
|
51
|
-
};
|
|
52
|
-
}
|
|
53
|
-
},
|
|
54
|
-
async closeBundle() {
|
|
55
|
-
await (0, fixServerAssets_js_1.fixServerAssets_assertUsageCssTarget)(config);
|
|
56
|
-
}
|
|
57
|
-
},
|
|
58
|
-
{
|
|
59
|
-
name: 'vike:build:pluginAssetsManifest:pre',
|
|
60
|
-
apply: 'build',
|
|
61
|
-
// Compatiblity with Environment API. It replaces `vike:build:pluginAssetsManifest:pre` when compatible
|
|
62
|
-
// See https://vite.dev/guide/api-environment-plugins.html#per-environment-plugins
|
|
63
|
-
applyToEnvironment() {
|
|
64
|
-
return {
|
|
65
|
-
name: 'vike:build:pluginAssetsManifest:pre:env-api-compat',
|
|
66
|
-
apply: 'build',
|
|
67
|
-
enforce: 'pre',
|
|
68
|
-
writeBundle: {
|
|
69
|
-
order: 'pre',
|
|
70
|
-
sequential: true,
|
|
71
|
-
async handler(options, bundle) {
|
|
72
|
-
if (this.environment.name === 'ssr') {
|
|
73
|
-
await writeAssetsManifestFile((0, getOutDirs_js_1.getOutDirs)(this.environment.config));
|
|
74
|
-
}
|
|
75
|
-
if ((0, viteIsSSR_js_1.viteIsSSR)(this.environment.config)) {
|
|
76
|
-
// Replace __VITE_ASSETS_MANIFEST__ in all server-side bundles
|
|
77
|
-
await (0, pluginBuildEntry_js_1.set_macro_ASSETS_MANIFEST)(options, bundle, assetsJsonFilePath);
|
|
78
|
-
}
|
|
79
|
-
}
|
|
80
|
-
}
|
|
81
|
-
};
|
|
82
|
-
},
|
|
83
|
-
// Ensures that we can reuse `assetsJsonFilePath`
|
|
84
|
-
sharedDuringBuild: true,
|
|
85
|
-
// Make sure other writeBundle() hooks are called after this writeBundle() hook.
|
|
86
|
-
// - set_macro_ASSETS_MANIFEST() needs to be called before dist/server/ code is executed.
|
|
87
|
-
// - For example, the writeBundle() hook of vite-plugin-vercel needs to be called after this writeBundle() hook, otherwise: https://github.com/vikejs/vike/issues/1527
|
|
88
|
-
enforce: 'pre',
|
|
89
|
-
writeBundle: {
|
|
90
|
-
order: 'pre',
|
|
91
|
-
sequential: true,
|
|
92
|
-
async handler(options, bundle) {
|
|
93
|
-
if ((0, viteIsSSR_js_1.viteIsSSR)(config)) {
|
|
94
|
-
await writeAssetsManifestFile((0, getOutDirs_js_1.getOutDirs)(config));
|
|
95
|
-
await (0, pluginBuildEntry_js_1.set_macro_ASSETS_MANIFEST)(options, bundle, assetsJsonFilePath);
|
|
96
|
-
}
|
|
97
|
-
}
|
|
98
|
-
}
|
|
99
|
-
}
|
|
100
|
-
];
|
|
101
|
-
async function writeAssetsManifestFile(outDirs) {
|
|
102
|
-
assetsJsonFilePath = path_1.default.posix.join(outDirs.outDirRoot, 'assets.json');
|
|
103
|
-
const clientManifestFilePath = path_1.default.posix.join(outDirs.outDirClient, manifestTempFile);
|
|
104
|
-
const serverManifestFilePath = path_1.default.posix.join(outDirs.outDirServer, manifestTempFile);
|
|
105
|
-
if (!isServerAssetsFixEnabled) {
|
|
106
|
-
await promises_1.default.copyFile(clientManifestFilePath, assetsJsonFilePath);
|
|
107
|
-
}
|
|
108
|
-
else {
|
|
109
|
-
const { clientManifestMod } = await (0, fixServerAssets_js_1.fixServerAssets)(config);
|
|
110
|
-
await (0, fixServerAssets_js_1.writeManifestFile)(clientManifestMod, assetsJsonFilePath);
|
|
111
|
-
}
|
|
112
|
-
await promises_1.default.rm(clientManifestFilePath);
|
|
113
|
-
await promises_1.default.rm(serverManifestFilePath);
|
|
114
|
-
}
|
|
115
|
-
}
|
|
@@ -1,31 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.viteIsSSR = viteIsSSR;
|
|
4
|
-
exports.viteIsSSR_options = viteIsSSR_options;
|
|
5
|
-
exports.viteIsSSR_safe = viteIsSSR_safe;
|
|
6
|
-
const assert_js_1 = require("../../../utils/assert.js");
|
|
7
|
-
function viteIsSSR(config) {
|
|
8
|
-
return !!config?.build?.ssr;
|
|
9
|
-
}
|
|
10
|
-
function viteIsSSR_options(options) {
|
|
11
|
-
return !!options?.ssr;
|
|
12
|
-
}
|
|
13
|
-
// Vite is quite messy about setting `ssr: boolean`, thus we use an extra safe implemention for security purposes.
|
|
14
|
-
// It's used for .client.js and .server.js guarantee thus we use agressive assert() calls for added safety.
|
|
15
|
-
function viteIsSSR_safe(config, options) {
|
|
16
|
-
if (config.command === 'build') {
|
|
17
|
-
(0, assert_js_1.assert)(typeof config.build.ssr === 'boolean');
|
|
18
|
-
const val = config.build.ssr;
|
|
19
|
-
if (options?.ssr !== undefined)
|
|
20
|
-
(0, assert_js_1.assert)(val === options.ssr);
|
|
21
|
-
return val;
|
|
22
|
-
}
|
|
23
|
-
else {
|
|
24
|
-
(0, assert_js_1.assert)(typeof options?.ssr === 'boolean');
|
|
25
|
-
const val = options.ssr;
|
|
26
|
-
/* This assert() fails (which is very unexpected).
|
|
27
|
-
if (typeof config.build.ssr === 'boolean') assert(val === config.build.ssr)
|
|
28
|
-
//*/
|
|
29
|
-
return val;
|
|
30
|
-
}
|
|
31
|
-
}
|
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
export { fixServerAssets };
|
|
2
|
-
export { fixServerAssets_isEnabled };
|
|
3
|
-
export { fixServerAssets_assertUsageCssCodeSplit };
|
|
4
|
-
export { fixServerAssets_assertUsageCssTarget };
|
|
5
|
-
export { writeManifestFile };
|
|
6
|
-
import { ViteManifest } from '../../../../shared/ViteManifest.js';
|
|
7
|
-
import { ResolvedConfig } from 'vite';
|
|
8
|
-
/**
|
|
9
|
-
* true => use workaround config.build.ssrEmitAssets
|
|
10
|
-
* false => use workaround extractAssets plugin
|
|
11
|
-
*
|
|
12
|
-
* Only used by V1 design.
|
|
13
|
-
*/
|
|
14
|
-
declare function fixServerAssets_isEnabled(): boolean;
|
|
15
|
-
/** https://github.com/vikejs/vike/issues/1339 */
|
|
16
|
-
declare function fixServerAssets(config: ResolvedConfig): Promise<{
|
|
17
|
-
clientManifestMod: ViteManifest;
|
|
18
|
-
serverManifestMod: ViteManifest;
|
|
19
|
-
}>;
|
|
20
|
-
declare function fixServerAssets_assertUsageCssCodeSplit(config: ResolvedConfig): void;
|
|
21
|
-
declare function fixServerAssets_assertUsageCssTarget(config: ResolvedConfig): Promise<void>;
|
|
22
|
-
declare function writeManifestFile(manifest: ViteManifest, manifestFilePath: string): Promise<void>;
|