vike 0.4.161-commit-ba539a4 → 0.4.161-commit-6a208ab
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/envVars.js +6 -2
- package/dist/cjs/node/plugin/plugins/extractAssetsPlugin.js +10 -3
- package/dist/cjs/node/plugin/plugins/extractExportNamesPlugin.js +2 -2
- package/dist/cjs/node/plugin/plugins/importBuild/getVikeManifest.js +1 -21
- package/dist/cjs/node/plugin/plugins/importBuild/index.js +1 -1
- package/dist/cjs/node/plugin/plugins/importUserCode/getVirtualFileImportUserCode.js +11 -91
- package/dist/cjs/node/plugin/plugins/importUserCode/v1-design/getVikeConfig.js +3 -1
- package/dist/cjs/node/plugin/plugins/setGlobalContext.js +0 -14
- package/dist/cjs/node/plugin/shared/rollupSourceMap.js +20 -0
- package/dist/cjs/node/prerender/runPrerender.js +1 -0
- package/dist/cjs/node/runtime/globalContext.js +8 -19
- package/dist/cjs/node/runtime/renderPage/getPageAssets/getManifestEntry.js +1 -3
- package/dist/cjs/node/runtime/renderPage/getPageAssets/retrieveAssetsProd.js +2 -2
- package/dist/cjs/node/runtime/renderPage/getPageAssets.js +8 -9
- package/dist/cjs/node/runtime/renderPage/renderPageAlreadyRouted.js +2 -23
- package/dist/cjs/node/shared/assertPluginManifest.js +1 -4
- package/dist/cjs/node/shared/assertV1Design.js +26 -0
- package/dist/cjs/node/shared/utils.js +2 -0
- package/dist/cjs/utils/projectInfo.js +1 -1
- package/dist/esm/node/plugin/plugins/envVars.js +6 -2
- package/dist/esm/node/plugin/plugins/extractAssetsPlugin.js +11 -4
- package/dist/esm/node/plugin/plugins/extractExportNamesPlugin.js +2 -2
- package/dist/esm/node/plugin/plugins/importBuild/getVikeManifest.d.ts +1 -2
- package/dist/esm/node/plugin/plugins/importBuild/getVikeManifest.js +2 -19
- package/dist/esm/node/plugin/plugins/importBuild/index.js +1 -1
- package/dist/esm/node/plugin/plugins/importUserCode/getVirtualFileImportUserCode.js +13 -93
- package/dist/esm/node/plugin/plugins/importUserCode/v1-design/getVikeConfig.d.ts +1 -0
- package/dist/esm/node/plugin/plugins/importUserCode/v1-design/getVikeConfig.js +3 -1
- package/dist/esm/node/plugin/plugins/setGlobalContext.js +1 -15
- package/dist/esm/node/plugin/shared/rollupSourceMap.d.ts +14 -0
- package/dist/esm/node/plugin/shared/rollupSourceMap.js +17 -0
- package/dist/esm/node/prerender/runPrerender.js +2 -1
- package/dist/esm/node/runtime/globalContext.d.ts +3 -10
- package/dist/esm/node/runtime/globalContext.js +7 -18
- package/dist/esm/node/runtime/renderPage/getPageAssets/getManifestEntry.d.ts +1 -1
- package/dist/esm/node/runtime/renderPage/getPageAssets/getManifestEntry.js +1 -3
- package/dist/esm/node/runtime/renderPage/getPageAssets/retrieveAssetsProd.d.ts +1 -1
- package/dist/esm/node/runtime/renderPage/getPageAssets/retrieveAssetsProd.js +2 -2
- package/dist/esm/node/runtime/renderPage/getPageAssets.js +8 -9
- package/dist/esm/node/runtime/renderPage/renderPageAlreadyRouted.js +3 -24
- package/dist/esm/node/shared/assertPluginManifest.d.ts +0 -1
- package/dist/esm/node/shared/assertPluginManifest.js +2 -5
- package/dist/esm/node/shared/assertV1Design.d.ts +4 -0
- package/dist/esm/node/shared/assertV1Design.js +23 -0
- package/dist/esm/node/shared/utils.d.ts +2 -0
- package/dist/esm/node/shared/utils.js +2 -0
- package/dist/esm/shared/page-configs/PageConfig.d.ts +1 -3
- package/dist/esm/utils/projectInfo.d.ts +2 -2
- package/dist/esm/utils/projectInfo.js +1 -1
- package/package.json +1 -1
- package/dist/cjs/node/plugin/shared/removeSourceMap.js +0 -12
- package/dist/esm/node/plugin/shared/removeSourceMap.d.ts +0 -7
- package/dist/esm/node/plugin/shared/removeSourceMap.js +0 -9
|
@@ -3,6 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.applyEnvVar = exports.envVarsPlugin = void 0;
|
|
4
4
|
const vite_1 = require("vite");
|
|
5
5
|
const utils_js_1 = require("../utils.js");
|
|
6
|
+
const rollupSourceMap_js_1 = require("../shared/rollupSourceMap.js");
|
|
6
7
|
function envVarsPlugin() {
|
|
7
8
|
let envsAll;
|
|
8
9
|
let config;
|
|
@@ -62,8 +63,11 @@ function envVarsPlugin() {
|
|
|
62
63
|
// Apply
|
|
63
64
|
code = applyEnvVar(envName, envVal, code);
|
|
64
65
|
});
|
|
65
|
-
//
|
|
66
|
-
|
|
66
|
+
// Line numbers didn't change.
|
|
67
|
+
// - We only break the column number of a couple of lines, wich is acceptable.
|
|
68
|
+
// - Anyways, I'm not even sure Vite supports high-resolution column number source mapping.
|
|
69
|
+
const ret = (0, rollupSourceMap_js_1.sourceMapPassthrough)(code);
|
|
70
|
+
return ret;
|
|
67
71
|
}
|
|
68
72
|
};
|
|
69
73
|
}
|
|
@@ -11,10 +11,11 @@ const extractAssetsQuery_js_1 = require("../../shared/extractAssetsQuery.js");
|
|
|
11
11
|
const getConfigVike_js_1 = require("../../shared/getConfigVike.js");
|
|
12
12
|
const isAsset_js_1 = require("../shared/isAsset.js");
|
|
13
13
|
const parseEsModule_js_1 = require("../shared/parseEsModule.js");
|
|
14
|
-
const
|
|
14
|
+
const rollupSourceMap_js_1 = require("../shared/rollupSourceMap.js");
|
|
15
15
|
const picocolors_1 = __importDefault(require("@brillout/picocolors"));
|
|
16
16
|
const fixServerAssets_js_1 = require("./buildConfig/fixServerAssets.js");
|
|
17
17
|
const getVikeConfig_js_1 = require("./importUserCode/v1-design/getVikeConfig.js");
|
|
18
|
+
const assertV1Design_js_1 = require("../../shared/assertV1Design.js");
|
|
18
19
|
const extractAssetsRE = /(\?|&)extractAssets(?:&|$)/;
|
|
19
20
|
exports.extractAssetsRE = extractAssetsRE;
|
|
20
21
|
const rawRE = /(\?|&)raw(?:&|$)/;
|
|
@@ -26,6 +27,7 @@ const debugEnabled = (0, utils_js_1.isDebugEnabled)(debugNamespace);
|
|
|
26
27
|
function extractAssetsPlugin() {
|
|
27
28
|
let config;
|
|
28
29
|
let configVike;
|
|
30
|
+
let vikeConfig;
|
|
29
31
|
let isServerAssetsFixEnabled;
|
|
30
32
|
return [
|
|
31
33
|
// 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'`).
|
|
@@ -38,14 +40,18 @@ function extractAssetsPlugin() {
|
|
|
38
40
|
if (!extractAssetsRE.test(id)) {
|
|
39
41
|
return;
|
|
40
42
|
}
|
|
41
|
-
|
|
43
|
+
if (isServerAssetsFixEnabled) {
|
|
44
|
+
// I'm guessing isServerAssetsFixEnabled can only be true when mixing both designs: https://github.com/vikejs/vike/issues/1480
|
|
45
|
+
(0, assertV1Design_js_1.assertV1Design)(true, vikeConfig.pageConfigs);
|
|
46
|
+
(0, utils_js_1.assert)(false);
|
|
47
|
+
}
|
|
42
48
|
(0, utils_js_1.assert)(configVike.includeAssetsImportedByServer);
|
|
43
49
|
(0, utils_js_1.assert)(!(0, utils_js_1.viteIsSSR_options)(options));
|
|
44
50
|
const importStatements = await (0, parseEsModule_js_1.getImportStatements)(src);
|
|
45
51
|
const moduleNames = getImportedModules(importStatements);
|
|
46
52
|
const code = moduleNames.map((moduleName) => `import '${moduleName}';`).join('\n');
|
|
47
53
|
debugTransformResult(id, code, importStatements);
|
|
48
|
-
return (0,
|
|
54
|
+
return (0, rollupSourceMap_js_1.sourceMapRemove)(code);
|
|
49
55
|
}
|
|
50
56
|
},
|
|
51
57
|
// This plugin appends `?extractAssets` to module IDs
|
|
@@ -136,6 +142,7 @@ function extractAssetsPlugin() {
|
|
|
136
142
|
async configResolved(config_) {
|
|
137
143
|
configVike = await (0, getConfigVike_js_1.getConfigVike)(config_);
|
|
138
144
|
config = config_;
|
|
145
|
+
vikeConfig = await (0, getVikeConfig_js_1.getVikeConfig)(config, false);
|
|
139
146
|
isServerAssetsFixEnabled = (0, fixServerAssets_js_1.fixServerAssets_isEnabled)() && (await (0, getVikeConfig_js_1.isV1Design)(config, false));
|
|
140
147
|
},
|
|
141
148
|
load(id) {
|
|
@@ -3,7 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.extractExportNamesRE = exports.isUsingClientRouter = exports.extractExportNamesPlugin = void 0;
|
|
4
4
|
const utils_js_1 = require("../utils.js");
|
|
5
5
|
const parseEsModule_js_1 = require("../shared/parseEsModule.js");
|
|
6
|
-
const
|
|
6
|
+
const rollupSourceMap_js_1 = require("../shared/rollupSourceMap.js");
|
|
7
7
|
const extractExportNamesRE = /(\?|&)extractExportNames(?:&|$)/;
|
|
8
8
|
exports.extractExportNamesRE = extractExportNamesRE;
|
|
9
9
|
const debugNamespace = 'vike:extractExportNames';
|
|
@@ -40,7 +40,7 @@ async function getExtractExportNamesCode(src, isClientSide, isProduction, id) {
|
|
|
40
40
|
globalObject.usesClientRouter = true;
|
|
41
41
|
}
|
|
42
42
|
const code = getCode(exportNames, wildcardReExports, isClientSide, isProduction, id);
|
|
43
|
-
return (0,
|
|
43
|
+
return (0, rollupSourceMap_js_1.sourceMapRemove)(code);
|
|
44
44
|
}
|
|
45
45
|
function getCode(exportNames, wildcardReExports, isClientSide, isProduction, id) {
|
|
46
46
|
let code = '';
|
|
@@ -1,38 +1,18 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
-
};
|
|
5
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
3
|
exports.getVikeManifest = void 0;
|
|
7
4
|
const utils_js_1 = require("../../utils.js");
|
|
8
5
|
const assertPluginManifest_js_1 = require("../../../shared/assertPluginManifest.js");
|
|
9
6
|
const extractExportNamesPlugin_js_1 = require("../extractExportNamesPlugin.js");
|
|
10
|
-
const path_1 = __importDefault(require("path"));
|
|
11
7
|
const globalContext_js_1 = require("../../../runtime/globalContext.js");
|
|
12
|
-
function getVikeManifest(
|
|
8
|
+
function getVikeManifest(configVike) {
|
|
13
9
|
const runtimeManifest = (0, globalContext_js_1.getRuntimeManifest)(configVike);
|
|
14
10
|
const manifest = {
|
|
15
11
|
version: utils_js_1.projectInfo.projectVersion,
|
|
16
12
|
usesClientRouter: (0, extractExportNamesPlugin_js_1.isUsingClientRouter)(), // TODO/v1-release: remove
|
|
17
|
-
manifestKeyMap: getManifestKeyMap(configVike, config),
|
|
18
13
|
...runtimeManifest
|
|
19
14
|
};
|
|
20
15
|
(0, assertPluginManifest_js_1.assertPluginManifest)(manifest);
|
|
21
16
|
return manifest;
|
|
22
17
|
}
|
|
23
18
|
exports.getVikeManifest = getVikeManifest;
|
|
24
|
-
function getManifestKeyMap(configVike, config) {
|
|
25
|
-
const manifestKeyMap = {};
|
|
26
|
-
configVike.extensions
|
|
27
|
-
.map(({ pageConfigsDistFiles }) => pageConfigsDistFiles)
|
|
28
|
-
.flat()
|
|
29
|
-
.filter(utils_js_1.isNotNullish)
|
|
30
|
-
.forEach(({ importPath, filePath }) => {
|
|
31
|
-
// Recreating https://github.com/vitejs/vite/blob/8158ece72b66307e7b607b98496891610ca70ea2/packages/vite/src/node/plugins/manifest.ts#L38
|
|
32
|
-
const filePathRelative = path_1.default.posix.relative(config.root, (0, utils_js_1.toPosixPath)(filePath));
|
|
33
|
-
(0, utils_js_1.assertPosixPath)(filePathRelative);
|
|
34
|
-
(0, utils_js_1.assertPosixPath)(importPath);
|
|
35
|
-
manifestKeyMap[importPath] = filePathRelative;
|
|
36
|
-
});
|
|
37
|
-
return manifestKeyMap;
|
|
38
|
-
}
|
|
@@ -39,7 +39,7 @@ function importBuild() {
|
|
|
39
39
|
exports.importBuild = importBuild;
|
|
40
40
|
function getEntryCode(config, configVike) {
|
|
41
41
|
const importPath = getImportPath(config);
|
|
42
|
-
const vikeManifest = (0, getVikeManifest_js_1.getVikeManifest)(
|
|
42
|
+
const vikeManifest = (0, getVikeManifest_js_1.getVikeManifest)(configVike);
|
|
43
43
|
const importerCode = [
|
|
44
44
|
` import { setImportBuildGetters } from '${importPath}';`,
|
|
45
45
|
` import * as pageFiles from '${virtualFileImportUserCode_js_1.virtualFileIdImportUserCodeServer}';`,
|
|
@@ -6,10 +6,10 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
6
6
|
exports.getVirtualFileImportUserCode = void 0;
|
|
7
7
|
const utils_js_1 = require("../../utils.js");
|
|
8
8
|
const virtualFileImportUserCode_js_1 = require("../../../shared/virtual-files/virtualFileImportUserCode.js");
|
|
9
|
+
const vite_1 = require("vite");
|
|
9
10
|
const fileTypes_js_1 = require("../../../../shared/getPageFiles/fileTypes.js");
|
|
10
11
|
const path_1 = __importDefault(require("path"));
|
|
11
12
|
const getVirtualFilePageConfigs_js_1 = require("./v1-design/getVirtualFilePageConfigs.js");
|
|
12
|
-
const generateEagerImport_js_1 = require("./generateEagerImport.js");
|
|
13
13
|
async function getVirtualFileImportUserCode(id, options, configVike, config, isDev) {
|
|
14
14
|
const idParsed = (0, virtualFileImportUserCode_js_1.isVirtualFileIdImportUserCode)(id);
|
|
15
15
|
(0, utils_js_1.assert)(idParsed);
|
|
@@ -27,53 +27,13 @@ async function getCode(config, configVike, isForClientSide, isClientRouting, isP
|
|
|
27
27
|
(0, utils_js_1.assert)(isDev === !isBuild);
|
|
28
28
|
let content = '';
|
|
29
29
|
{
|
|
30
|
-
const globRoots = getGlobRoots(config
|
|
30
|
+
const globRoots = getGlobRoots(config);
|
|
31
31
|
(0, utils_js_1.debugGlob)('Glob roots: ', globRoots);
|
|
32
32
|
content += await generateGlobImports(globRoots, isBuild, isForClientSide, isClientRouting, configVike, isPrerendering, config, isDev, id);
|
|
33
33
|
}
|
|
34
|
-
{
|
|
35
|
-
const extensionsImportPaths = configVike.extensions
|
|
36
|
-
.map(({ pageConfigsDistFiles }) => pageConfigsDistFiles)
|
|
37
|
-
.flat()
|
|
38
|
-
.filter(utils_js_1.isNotNullish)
|
|
39
|
-
.map(({ importPath }) => importPath);
|
|
40
|
-
content += generateExtensionImports(extensionsImportPaths, isForClientSide, isBuild, isClientRouting, isPrerendering);
|
|
41
|
-
}
|
|
42
34
|
(0, utils_js_1.debugGlob)(`Glob imports for ${isForClientSide ? 'client' : 'server'}:\n`, content);
|
|
43
35
|
return content;
|
|
44
36
|
}
|
|
45
|
-
function generateExtensionImports(extensionsImportPaths, isForClientSide, isBuild, isClientRouting, isPrerendering) {
|
|
46
|
-
let fileContent = '\n\n';
|
|
47
|
-
extensionsImportPaths
|
|
48
|
-
.filter((importPath) => {
|
|
49
|
-
(0, utils_js_1.assert)(
|
|
50
|
-
// V1 design
|
|
51
|
-
importPath.includes('+') ||
|
|
52
|
-
// V0.4 design
|
|
53
|
-
importPath.includes('.page.'));
|
|
54
|
-
return !importPath.includes('+');
|
|
55
|
-
})
|
|
56
|
-
.forEach((importPath) => {
|
|
57
|
-
const fileType = (0, fileTypes_js_1.determineFileType)(importPath);
|
|
58
|
-
const { includeImport, includeExportNames } = determineInjection({
|
|
59
|
-
fileType,
|
|
60
|
-
isForClientSide,
|
|
61
|
-
isClientRouting,
|
|
62
|
-
isPrerendering,
|
|
63
|
-
isBuild
|
|
64
|
-
});
|
|
65
|
-
if (includeImport) {
|
|
66
|
-
fileContent += addImport(importPath, fileType, false, isBuild);
|
|
67
|
-
}
|
|
68
|
-
if (includeExportNames) {
|
|
69
|
-
fileContent += addImport(importPath, fileType, true, isBuild);
|
|
70
|
-
}
|
|
71
|
-
if (!includeImport && !includeExportNames && !isForClientSide) {
|
|
72
|
-
fileContent += `pageFilesList.push("${importPath}");` + '\n';
|
|
73
|
-
}
|
|
74
|
-
});
|
|
75
|
-
return fileContent;
|
|
76
|
-
}
|
|
77
37
|
function determineInjection({ fileType, isForClientSide, isClientRouting, isPrerendering, isBuild }) {
|
|
78
38
|
if (!isForClientSide) {
|
|
79
39
|
return {
|
|
@@ -99,42 +59,6 @@ function determineInjection({ fileType, isForClientSide, isClientRouting, isPrer
|
|
|
99
59
|
}
|
|
100
60
|
}
|
|
101
61
|
}
|
|
102
|
-
function addImport(importPath, fileType, exportNames, isBuild) {
|
|
103
|
-
const pageFilesVar = (() => {
|
|
104
|
-
if (exportNames) {
|
|
105
|
-
if (isBuild) {
|
|
106
|
-
return 'pageFilesExportNamesEager';
|
|
107
|
-
}
|
|
108
|
-
else {
|
|
109
|
-
return 'pageFilesExportNamesLazy';
|
|
110
|
-
}
|
|
111
|
-
}
|
|
112
|
-
else {
|
|
113
|
-
if (fileType === '.page.route') {
|
|
114
|
-
return 'pageFilesEager';
|
|
115
|
-
}
|
|
116
|
-
else {
|
|
117
|
-
return 'pageFilesLazy';
|
|
118
|
-
}
|
|
119
|
-
}
|
|
120
|
-
})();
|
|
121
|
-
const query = !exportNames ? '' : '?extractExportNames';
|
|
122
|
-
let fileContent = '';
|
|
123
|
-
const mapVar = `${pageFilesVar}['${fileType}']`;
|
|
124
|
-
fileContent += `${mapVar} = ${mapVar} ?? {};\n`;
|
|
125
|
-
const value = (() => {
|
|
126
|
-
if (!pageFilesVar.endsWith('Eager')) {
|
|
127
|
-
return `() => import('${importPath}${query}')`;
|
|
128
|
-
}
|
|
129
|
-
else {
|
|
130
|
-
const { importName, importStatement } = (0, generateEagerImport_js_1.generateEagerImport)(`${importPath}${query}`);
|
|
131
|
-
fileContent += importStatement + '\n';
|
|
132
|
-
return importName;
|
|
133
|
-
}
|
|
134
|
-
})();
|
|
135
|
-
fileContent += `${mapVar}['${importPath}'] = ${value};\n`;
|
|
136
|
-
return fileContent;
|
|
137
|
-
}
|
|
138
62
|
async function generateGlobImports(globRoots, isBuild, isForClientSide, isClientRouting, configVike, isPrerendering, config, isDev, id) {
|
|
139
63
|
let fileContent = `// Generatead by node/plugin/plugins/virtualFiles/index.ts
|
|
140
64
|
|
|
@@ -212,10 +136,15 @@ function getGlobs(globRoots, isBuild, fileType, query) {
|
|
|
212
136
|
varNameLocals.push(varNameLocal);
|
|
213
137
|
const globIncludePath = `'${getGlobPath(globRoot.includeDir, fileType)}'`;
|
|
214
138
|
const globExcludePath = globRoot.excludeDir ? `'!${getGlobPath(globRoot.excludeDir, fileType)}'` : null;
|
|
215
|
-
const globOptions =
|
|
216
|
-
(0, utils_js_1.
|
|
139
|
+
const globOptions = { eager: isEager };
|
|
140
|
+
if ((0, utils_js_1.isVersionOrAbove)(vite_1.version, '5.1.0')) {
|
|
141
|
+
globOptions.as = query;
|
|
142
|
+
}
|
|
143
|
+
else {
|
|
144
|
+
globOptions.query = `?${query}`;
|
|
145
|
+
}
|
|
217
146
|
const globPaths = globExcludePath ? `[${globIncludePath}, ${globExcludePath}]` : `[${globIncludePath}]`;
|
|
218
|
-
const globLine = `const ${varNameLocal} = import.meta.glob(${globPaths}, ${globOptions});`;
|
|
147
|
+
const globLine = `const ${varNameLocal} = import.meta.glob(${globPaths}, ${JSON.stringify(globOptions)});`;
|
|
219
148
|
return globLine;
|
|
220
149
|
}),
|
|
221
150
|
`const ${varName} = {${varNameLocals.map((varNameLocal) => `...${varNameLocal}`).join(',')}};`,
|
|
@@ -223,22 +152,13 @@ function getGlobs(globRoots, isBuild, fileType, query) {
|
|
|
223
152
|
''
|
|
224
153
|
].join('\n');
|
|
225
154
|
}
|
|
226
|
-
function getGlobRoots(config
|
|
155
|
+
function getGlobRoots(config) {
|
|
227
156
|
const globRoots = [
|
|
228
157
|
{
|
|
229
158
|
includeDir: '/',
|
|
230
159
|
excludeDir: path_1.default.posix.relative(config.root, (0, utils_js_1.getOutDirs)(config).outDirRoot)
|
|
231
160
|
}
|
|
232
161
|
];
|
|
233
|
-
configVike.extensions
|
|
234
|
-
.map(({ pageConfigsSrcDir }) => pageConfigsSrcDir)
|
|
235
|
-
.filter(utils_js_1.isNotNullish)
|
|
236
|
-
.forEach((pageConfigsSrcDir) => {
|
|
237
|
-
const globRoot = {
|
|
238
|
-
includeDir: path_1.default.posix.relative(config.root, pageConfigsSrcDir)
|
|
239
|
-
};
|
|
240
|
-
globRoots.push(globRoot);
|
|
241
|
-
});
|
|
242
162
|
return globRoots;
|
|
243
163
|
}
|
|
244
164
|
function getGlobPath(globRootDir, fileType) {
|
|
@@ -76,7 +76,9 @@ async function getVikeConfig(config, isDev, tolerateInvalidConfig = false, exten
|
|
|
76
76
|
}
|
|
77
77
|
exports.getVikeConfig = getVikeConfig;
|
|
78
78
|
async function isV1Design(config, isDev) {
|
|
79
|
-
const
|
|
79
|
+
const vikeConfig = await getVikeConfig(config, isDev);
|
|
80
|
+
const { pageConfigs } = vikeConfig;
|
|
81
|
+
const isV1Design = pageConfigs.length > 0;
|
|
80
82
|
return isV1Design;
|
|
81
83
|
}
|
|
82
84
|
exports.isV1Design = isV1Design;
|
|
@@ -11,20 +11,6 @@ function setGlobalContext() {
|
|
|
11
11
|
handler(viteDevServer) {
|
|
12
12
|
(0, globalContext_js_1.setGlobalContext_viteDevServer)(viteDevServer);
|
|
13
13
|
}
|
|
14
|
-
},
|
|
15
|
-
configurePreviewServer: {
|
|
16
|
-
order: 'pre',
|
|
17
|
-
handler(vitePreviewServer) {
|
|
18
|
-
(0, globalContext_js_1.setGlobalContext_vitePreviewServer)(
|
|
19
|
-
// Type cast won't be necessary after https://github.com/vitejs/vite/pull/14119 is released in Vite 5
|
|
20
|
-
vitePreviewServer);
|
|
21
|
-
}
|
|
22
|
-
},
|
|
23
|
-
configResolved: {
|
|
24
|
-
order: 'pre',
|
|
25
|
-
handler(config) {
|
|
26
|
-
(0, globalContext_js_1.setGlobalContext_viteConfig)(config);
|
|
27
|
-
}
|
|
28
14
|
}
|
|
29
15
|
};
|
|
30
16
|
}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.sourceMapPassthrough = exports.sourceMapRemove = void 0;
|
|
4
|
+
// https://rollupjs.org/guide/en/#source-code-transformations
|
|
5
|
+
/** Remove entire source mapping, to save KBs. */
|
|
6
|
+
function sourceMapRemove(code) {
|
|
7
|
+
return {
|
|
8
|
+
code,
|
|
9
|
+
map: { mappings: '' }
|
|
10
|
+
};
|
|
11
|
+
}
|
|
12
|
+
exports.sourceMapRemove = sourceMapRemove;
|
|
13
|
+
/** Don't provide any source map, pass through current source map instead. */
|
|
14
|
+
function sourceMapPassthrough(code) {
|
|
15
|
+
return {
|
|
16
|
+
code,
|
|
17
|
+
map: null
|
|
18
|
+
};
|
|
19
|
+
}
|
|
20
|
+
exports.sourceMapPassthrough = sourceMapPassthrough;
|
|
@@ -90,6 +90,7 @@ async function runPrerender(options, manuallyTriggered) {
|
|
|
90
90
|
handleNodeEnv();
|
|
91
91
|
await disableReactStreaming();
|
|
92
92
|
const viteConfig = await (0, vite_1.resolveConfig)(options.viteConfig || {}, 'vike pre-rendering', 'production');
|
|
93
|
+
(0, globalContext_js_1.setGlobalContext_prerender)(viteConfig);
|
|
93
94
|
assertLoadedConfig(viteConfig, options);
|
|
94
95
|
const configVike = await (0, getConfigVike_js_1.getConfigVike)(viteConfig);
|
|
95
96
|
const { outDirClient, outDirRoot } = (0, utils_js_1.getOutDirs)(viteConfig);
|
|
@@ -3,7 +3,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
3
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.getRuntimeManifest = exports.
|
|
6
|
+
exports.getRuntimeManifest = exports.setGlobalContext_prerender = exports.setGlobalContext_viteDevServer = exports.getViteConfig = exports.getViteDevServer = exports.getGlobalContext = exports.initGlobalContext = void 0;
|
|
7
7
|
const utils_js_1 = require("./utils.js");
|
|
8
8
|
const loadImportBuild_js_1 = require("./globalContext/loadImportBuild.js");
|
|
9
9
|
const getPageFiles_js_1 = require("../../shared/getPageFiles.js");
|
|
@@ -21,27 +21,22 @@ function setGlobalContext_viteDevServer(viteDevServer) {
|
|
|
21
21
|
if (globalObject.viteDevServer)
|
|
22
22
|
return;
|
|
23
23
|
(0, utils_js_1.assert)(!globalObject.globalContext);
|
|
24
|
+
(0, utils_js_1.assert)(!globalObject.globalContext);
|
|
25
|
+
globalObject.viteConfig = viteDevServer.config;
|
|
24
26
|
globalObject.viteDevServer = viteDevServer;
|
|
25
27
|
}
|
|
26
28
|
exports.setGlobalContext_viteDevServer = setGlobalContext_viteDevServer;
|
|
27
|
-
function setGlobalContext_vitePreviewServer(vitePreviewServer) {
|
|
28
|
-
if (globalObject.vitePreviewServer)
|
|
29
|
-
return;
|
|
30
|
-
(0, utils_js_1.assert)(!globalObject.globalContext);
|
|
31
|
-
globalObject.vitePreviewServer = vitePreviewServer;
|
|
32
|
-
}
|
|
33
|
-
exports.setGlobalContext_vitePreviewServer = setGlobalContext_vitePreviewServer;
|
|
34
29
|
function getViteDevServer() {
|
|
35
30
|
return globalObject.viteDevServer ?? null;
|
|
36
31
|
}
|
|
37
32
|
exports.getViteDevServer = getViteDevServer;
|
|
38
|
-
function
|
|
33
|
+
function setGlobalContext_prerender(viteConfig) {
|
|
39
34
|
if (globalObject.viteConfig)
|
|
40
35
|
return;
|
|
41
36
|
(0, utils_js_1.assert)(!globalObject.globalContext);
|
|
42
37
|
globalObject.viteConfig = viteConfig;
|
|
43
38
|
}
|
|
44
|
-
exports.
|
|
39
|
+
exports.setGlobalContext_prerender = setGlobalContext_prerender;
|
|
45
40
|
function getViteConfig() {
|
|
46
41
|
return globalObject.viteConfig ?? null;
|
|
47
42
|
}
|
|
@@ -49,13 +44,12 @@ exports.getViteConfig = getViteConfig;
|
|
|
49
44
|
async function initGlobalContext(isPrerendering = false, outDir) {
|
|
50
45
|
if (globalObject.globalContext)
|
|
51
46
|
return;
|
|
52
|
-
const { viteDevServer,
|
|
47
|
+
const { viteDevServer, viteConfig } = globalObject;
|
|
53
48
|
assertNodeEnv(!!viteDevServer);
|
|
54
49
|
const isProduction = !viteDevServer;
|
|
55
50
|
if (!isProduction) {
|
|
56
51
|
(0, utils_js_1.assert)(viteConfig);
|
|
57
52
|
(0, utils_js_1.assert)(!isPrerendering);
|
|
58
|
-
(0, utils_js_1.assert)(!vitePreviewServer);
|
|
59
53
|
const configVike = await (0, getConfigVike_js_1.getConfigVike)(viteConfig);
|
|
60
54
|
const pluginManifest = getRuntimeManifest(configVike);
|
|
61
55
|
globalObject.globalContext = {
|
|
@@ -64,9 +58,7 @@ async function initGlobalContext(isPrerendering = false, outDir) {
|
|
|
64
58
|
clientManifest: null,
|
|
65
59
|
pluginManifest: null,
|
|
66
60
|
viteDevServer,
|
|
67
|
-
vitePreviewServer: null,
|
|
68
61
|
viteConfig,
|
|
69
|
-
configVike,
|
|
70
62
|
baseServer: pluginManifest.baseServer,
|
|
71
63
|
baseAssets: pluginManifest.baseAssets,
|
|
72
64
|
includeAssetsImportedByServer: pluginManifest.includeAssetsImportedByServer,
|
|
@@ -87,7 +79,6 @@ async function initGlobalContext(isPrerendering = false, outDir) {
|
|
|
87
79
|
clientManifest,
|
|
88
80
|
pluginManifest,
|
|
89
81
|
viteDevServer: null,
|
|
90
|
-
vitePreviewServer: vitePreviewServer ?? null,
|
|
91
82
|
baseServer: pluginManifest.baseServer,
|
|
92
83
|
baseAssets: pluginManifest.baseAssets,
|
|
93
84
|
includeAssetsImportedByServer: pluginManifest.includeAssetsImportedByServer,
|
|
@@ -101,16 +92,14 @@ async function initGlobalContext(isPrerendering = false, outDir) {
|
|
|
101
92
|
(0, utils_js_1.assert)(configVike);
|
|
102
93
|
(0, utils_js_1.objectAssign)(globalContext, {
|
|
103
94
|
isPrerendering: true,
|
|
104
|
-
viteConfig
|
|
105
|
-
configVike
|
|
95
|
+
viteConfig
|
|
106
96
|
});
|
|
107
97
|
globalObject.globalContext = globalContext;
|
|
108
98
|
}
|
|
109
99
|
else {
|
|
110
100
|
(0, utils_js_1.objectAssign)(globalContext, {
|
|
111
101
|
isPrerendering: false,
|
|
112
|
-
viteConfig: null
|
|
113
|
-
configVike: null
|
|
102
|
+
viteConfig: null
|
|
114
103
|
});
|
|
115
104
|
globalObject.globalContext = globalContext;
|
|
116
105
|
}
|
|
@@ -5,9 +5,7 @@ const utils_js_1 = require("../../utils.js");
|
|
|
5
5
|
const assertClientEntryId_js_1 = require("./assertClientEntryId.js");
|
|
6
6
|
const virtualFilePageConfigValuesAll_js_1 = require("../../../shared/virtual-files/virtualFilePageConfigValuesAll.js");
|
|
7
7
|
const prependEntriesDir_js_1 = require("../../../shared/prependEntriesDir.js");
|
|
8
|
-
function getManifestEntry(id, clientManifest
|
|
9
|
-
// TODO: remove
|
|
10
|
-
manifestKeyMap) {
|
|
8
|
+
function getManifestEntry(id, clientManifest) {
|
|
11
9
|
(0, assertClientEntryId_js_1.assertClientEntryId)(id);
|
|
12
10
|
const debugInfo = getDebugInfo(id, clientManifest);
|
|
13
11
|
// Vike client entry
|
|
@@ -4,7 +4,7 @@ exports.retrieveAssetsProd = void 0;
|
|
|
4
4
|
const utils_js_1 = require("../../utils.js");
|
|
5
5
|
const getManifestEntry_js_1 = require("./getManifestEntry.js");
|
|
6
6
|
const extractAssetsQuery_js_1 = require("../../../shared/extractAssetsQuery.js");
|
|
7
|
-
function retrieveAssetsProd(clientDependencies, clientManifest, includeAssetsImportedByServer
|
|
7
|
+
function retrieveAssetsProd(clientDependencies, clientManifest, includeAssetsImportedByServer) {
|
|
8
8
|
let assetUrls = new Set();
|
|
9
9
|
(0, utils_js_1.assert)(clientManifest);
|
|
10
10
|
const visistedAssets = new Set();
|
|
@@ -21,7 +21,7 @@ function retrieveAssetsProd(clientDependencies, clientManifest, includeAssetsImp
|
|
|
21
21
|
id = (0, extractAssetsQuery_js_1.extractAssetsAddQuery)(id);
|
|
22
22
|
}
|
|
23
23
|
}
|
|
24
|
-
const { manifestKey } = (0, getManifestEntry_js_1.getManifestEntry)(id, clientManifest
|
|
24
|
+
const { manifestKey } = (0, getManifestEntry_js_1.getManifestEntry)(id, clientManifest);
|
|
25
25
|
collectAssets(manifestKey, assetUrls, visistedAssets, clientManifest, onlyAssets);
|
|
26
26
|
});
|
|
27
27
|
collectSingleStyle(assetUrls, clientManifest);
|
|
@@ -16,15 +16,14 @@ async function getPageAssets(pageContext, clientDependencies, clientEntries) {
|
|
|
16
16
|
let assetUrls;
|
|
17
17
|
let clientEntriesSrc;
|
|
18
18
|
if (isDev) {
|
|
19
|
-
const { viteDevServer
|
|
20
|
-
clientEntriesSrc = await Promise.all(clientEntries.map((clientEntry) => resolveClientEntriesDev(clientEntry, viteDevServer
|
|
19
|
+
const { viteDevServer } = globalContext;
|
|
20
|
+
clientEntriesSrc = await Promise.all(clientEntries.map((clientEntry) => resolveClientEntriesDev(clientEntry, viteDevServer)));
|
|
21
21
|
assetUrls = await (0, retrieveAssetsDev_js_1.retrieveAssetsDev)(clientDependencies, viteDevServer);
|
|
22
22
|
}
|
|
23
23
|
else {
|
|
24
|
-
const {
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
assetUrls = (0, retrieveAssetsProd_js_1.retrieveAssetsProd)(clientDependencies, clientManifest, pageContext._includeAssetsImportedByServer, manifestKeyMap);
|
|
24
|
+
const { clientManifest } = globalContext;
|
|
25
|
+
clientEntriesSrc = clientEntries.map((clientEntry) => resolveClientEntriesProd(clientEntry, clientManifest));
|
|
26
|
+
assetUrls = (0, retrieveAssetsProd_js_1.retrieveAssetsProd)(clientDependencies, clientManifest, pageContext._includeAssetsImportedByServer);
|
|
28
27
|
}
|
|
29
28
|
let pageAssets = [];
|
|
30
29
|
(0, utils_js_1.unique)([...clientEntriesSrc, ...assetUrls]).forEach((src) => {
|
|
@@ -59,7 +58,7 @@ async function getPageAssets(pageContext, clientDependencies, clientEntries) {
|
|
|
59
58
|
return pageAssets;
|
|
60
59
|
}
|
|
61
60
|
exports.getPageAssets = getPageAssets;
|
|
62
|
-
async function resolveClientEntriesDev(clientEntry, viteDevServer
|
|
61
|
+
async function resolveClientEntriesDev(clientEntry, viteDevServer) {
|
|
63
62
|
(0, assertClientEntryId_js_1.assertClientEntryId)(clientEntry);
|
|
64
63
|
let root = viteDevServer.config.root;
|
|
65
64
|
(0, utils_js_1.assert)(root);
|
|
@@ -120,8 +119,8 @@ async function resolveClientEntriesDev(clientEntry, viteDevServer, configVike) {
|
|
|
120
119
|
(0, utils_js_1.assertPosixPath)(filePath);
|
|
121
120
|
return filePath;
|
|
122
121
|
}
|
|
123
|
-
function resolveClientEntriesProd(clientEntry, clientManifest
|
|
124
|
-
const { manifestEntry } = (0, getManifestEntry_js_1.getManifestEntry)(clientEntry, clientManifest
|
|
122
|
+
function resolveClientEntriesProd(clientEntry, clientManifest) {
|
|
123
|
+
const { manifestEntry } = (0, getManifestEntry_js_1.getManifestEntry)(clientEntry, clientManifest);
|
|
125
124
|
(0, utils_js_1.assert)(manifestEntry.isEntry || manifestEntry.isDynamicEntry || clientEntry.endsWith('.css'), { clientEntry });
|
|
126
125
|
let { file } = manifestEntry;
|
|
127
126
|
(0, utils_js_1.assert)(!file.startsWith('/'));
|
|
@@ -21,8 +21,8 @@ const preparePageContextForUserConsumptionServerSide_js_1 = require("./preparePa
|
|
|
21
21
|
const executeGuardHook_js_1 = require("../../../shared/route/executeGuardHook.js");
|
|
22
22
|
const loadPageRoutes_js_1 = require("../../../shared/route/loadPageRoutes.js");
|
|
23
23
|
const picocolors_1 = __importDefault(require("@brillout/picocolors"));
|
|
24
|
-
const helpers_js_1 = require("../../../shared/page-configs/helpers.js");
|
|
25
24
|
const isServerSideError_js_1 = require("../../../shared/misc/isServerSideError.js");
|
|
25
|
+
const assertV1Design_js_1 = require("../../shared/assertV1Design.js");
|
|
26
26
|
async function renderPageAlreadyRouted(pageContext) {
|
|
27
27
|
// pageContext._pageId can either be the:
|
|
28
28
|
// - ID of the page matching the routing, or the
|
|
@@ -156,7 +156,7 @@ async function getRenderContext() {
|
|
|
156
156
|
const globalContext = (0, globalContext_js_1.getGlobalContext)();
|
|
157
157
|
const { pageFilesAll, allPageIds, pageConfigs, pageConfigGlobal } = await (0, getPageFiles_js_1.getPageFilesAll)(false, globalContext.isProduction);
|
|
158
158
|
const { pageRoutes, onBeforeRouteHook } = await (0, loadPageRoutes_js_1.loadPageRoutes)(pageFilesAll, pageConfigs, pageConfigGlobal, allPageIds);
|
|
159
|
-
assertV1Design(pageFilesAll, pageConfigs);
|
|
159
|
+
(0, assertV1Design_js_1.assertV1Design)(pageFilesAll.length > 0, pageConfigs, pageFilesAll);
|
|
160
160
|
const renderContext = {
|
|
161
161
|
pageFilesAll: pageFilesAll,
|
|
162
162
|
pageConfigs,
|
|
@@ -168,24 +168,3 @@ async function getRenderContext() {
|
|
|
168
168
|
return renderContext;
|
|
169
169
|
}
|
|
170
170
|
exports.getRenderContext = getRenderContext;
|
|
171
|
-
function assertV1Design(pageFilesAll, pageConfigs) {
|
|
172
|
-
const isV1Design = pageConfigs.length !== 0;
|
|
173
|
-
const isDesignOld = pageFilesAll.length !== 0;
|
|
174
|
-
if (isV1Design && isDesignOld) {
|
|
175
|
-
const indent = '- ';
|
|
176
|
-
const v1Files = (0, utils_js_1.unique)(pageConfigs
|
|
177
|
-
.map((p) => Object.values(p.configValues)
|
|
178
|
-
.map(helpers_js_1.getConfigValueFilePathToShowToUser)
|
|
179
|
-
.filter(utils_js_1.isNotNullish)
|
|
180
|
-
.map((filePathToShowToUser) => indent + filePathToShowToUser))
|
|
181
|
-
.flat(2));
|
|
182
|
-
(0, utils_js_1.assertUsage)(false, [
|
|
183
|
-
'Mixing the new V1 design with the old V0.4 design is forbidden.',
|
|
184
|
-
'V1 files:',
|
|
185
|
-
...v1Files,
|
|
186
|
-
'V0.4 files:',
|
|
187
|
-
...pageFilesAll.map((p) => indent + p.filePath)
|
|
188
|
-
].join('\n'));
|
|
189
|
-
}
|
|
190
|
-
(0, utils_js_1.assertWarning)(!isDesignOld, "You are using Vike's deprecated design. Update to the new V1 design, see https://vike.dev/migration/v1-design for how to migrate.", { onlyOnce: true });
|
|
191
|
-
}
|
|
@@ -9,16 +9,13 @@ function assertPluginManifest(pluginManifest) {
|
|
|
9
9
|
(0, assertRuntimeManifest_js_1.assertRuntimeManifest)(pluginManifest);
|
|
10
10
|
(0, utils_js_1.assert)((0, utils_js_1.hasProp)(pluginManifest, 'usesClientRouter', 'boolean'));
|
|
11
11
|
(0, utils_js_1.assert)((0, utils_js_1.hasProp)(pluginManifest, 'version', 'string'));
|
|
12
|
-
(0, utils_js_1.assert)((0, utils_js_1.hasProp)(pluginManifest, 'manifestKeyMap', 'object'));
|
|
13
|
-
const { manifestKeyMap } = pluginManifest;
|
|
14
|
-
(0, utils_js_1.assert)((0, utils_js_1.isStringRecord)(manifestKeyMap));
|
|
15
12
|
// Avoid:
|
|
16
13
|
// ```
|
|
17
14
|
// Uncaught (in promise) TypeError: Cannot set property manifestKeyMap of #<Object> which has only a getter
|
|
18
15
|
// ```
|
|
16
|
+
// We removed manifestKeyMap, maybe this isn't needed anymore.
|
|
19
17
|
// See https://github.com/vikejs/vike/issues/596
|
|
20
18
|
const pluginManifestClone = { ...pluginManifest };
|
|
21
|
-
(0, utils_js_1.objectAssign)(pluginManifestClone, { manifestKeyMap });
|
|
22
19
|
(0, utils_js_1.checkType)(pluginManifestClone);
|
|
23
20
|
}
|
|
24
21
|
exports.assertPluginManifest = assertPluginManifest;
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.assertV1Design = void 0;
|
|
4
|
+
const helpers_js_1 = require("../../shared/page-configs/helpers.js");
|
|
5
|
+
const utils_js_1 = require("./utils.js");
|
|
6
|
+
function assertV1Design(isOldDesign, pageConfigs, pageFilesAll) {
|
|
7
|
+
const isV1Design = pageConfigs.length > 0;
|
|
8
|
+
if (isV1Design && isOldDesign) {
|
|
9
|
+
const lines = ['Mixing the new V1 design with the old V0.4 design is forbidden.'];
|
|
10
|
+
if (pageFilesAll) {
|
|
11
|
+
(0, utils_js_1.assert)(pageFilesAll.length > 0);
|
|
12
|
+
const indent = '- ';
|
|
13
|
+
const filesV1 = (0, utils_js_1.unique)(pageConfigs
|
|
14
|
+
.map((p) => Object.values(p.configValues)
|
|
15
|
+
.map(helpers_js_1.getConfigValueFilePathToShowToUser)
|
|
16
|
+
.filter(utils_js_1.isNotNullish)
|
|
17
|
+
.map((filePathToShowToUser) => indent + filePathToShowToUser))
|
|
18
|
+
.flat(2));
|
|
19
|
+
const filesOld = pageFilesAll.map((p) => indent + p.filePath);
|
|
20
|
+
lines.push(...['V1 design files:', ...filesV1, 'Old design files:', ...filesOld]);
|
|
21
|
+
}
|
|
22
|
+
(0, utils_js_1.assertUsage)(false, lines.join('\n'));
|
|
23
|
+
}
|
|
24
|
+
(0, utils_js_1.assertWarning)(!isOldDesign, "You are using Vike's deprecated design. Update to the new V1 design, see https://vike.dev/migration/v1-design for how to migrate.", { onlyOnce: true });
|
|
25
|
+
}
|
|
26
|
+
exports.assertV1Design = assertV1Design;
|
|
@@ -31,3 +31,5 @@ __exportStar(require("../../utils/parseUrl-extras.js"), exports);
|
|
|
31
31
|
__exportStar(require("../../utils/isObject.js"), exports);
|
|
32
32
|
__exportStar(require("../../utils/virtual-files.js"), exports);
|
|
33
33
|
__exportStar(require("../../utils/assertIsNotBrowser.js"), exports);
|
|
34
|
+
__exportStar(require("../../utils/isNotNullish.js"), exports);
|
|
35
|
+
__exportStar(require("../../utils/unique.js"), exports);
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.PROJECT_VERSION = exports.projectInfo = void 0;
|
|
4
4
|
const assertSingleInstance_js_1 = require("./assertSingleInstance.js");
|
|
5
|
-
const PROJECT_VERSION = '0.4.161-commit-
|
|
5
|
+
const PROJECT_VERSION = '0.4.161-commit-6a208ab';
|
|
6
6
|
exports.PROJECT_VERSION = PROJECT_VERSION;
|
|
7
7
|
const projectInfo = {
|
|
8
8
|
projectName: 'Vike',
|