vike 0.4.161 → 0.4.162
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/__internal/index.js +2 -2
- package/dist/cjs/node/plugin/index.js +0 -2
- package/dist/cjs/node/plugin/plugins/buildConfig.js +20 -20
- package/dist/cjs/node/plugin/plugins/config/index.js +2 -7
- package/dist/cjs/node/plugin/plugins/devConfig/determineFsAllowList.js +1 -8
- package/dist/cjs/node/plugin/plugins/devConfig/determineOptimizeDeps.js +1 -18
- package/dist/cjs/node/plugin/plugins/devConfig/index.js +2 -4
- package/dist/cjs/node/plugin/plugins/envVars.js +6 -2
- package/dist/cjs/node/plugin/plugins/extractAssetsPlugin.js +10 -22
- 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 +29 -95
- package/dist/cjs/node/plugin/plugins/importUserCode/index.js +8 -8
- package/dist/cjs/node/plugin/plugins/importUserCode/v1-design/getConfigValuesSerialized.js +1 -9
- package/dist/cjs/node/plugin/plugins/importUserCode/v1-design/getVikeConfig/configDefinitionsBuiltIn.js +3 -0
- package/dist/cjs/node/plugin/plugins/importUserCode/v1-design/getVikeConfig/filesystemRouting.js +1 -1
- package/dist/cjs/node/plugin/plugins/importUserCode/v1-design/getVikeConfig/loadFileAtConfigTime.js +4 -4
- package/dist/cjs/node/plugin/plugins/importUserCode/v1-design/getVikeConfig/resolveImportPath.js +1 -1
- package/dist/cjs/node/plugin/plugins/importUserCode/v1-design/getVikeConfig/transformFileImports.js +35 -36
- package/dist/cjs/node/plugin/plugins/importUserCode/v1-design/getVikeConfig/transpileAndExecuteFile.js +109 -104
- package/dist/cjs/node/plugin/plugins/importUserCode/v1-design/getVikeConfig.js +39 -33
- package/dist/cjs/node/plugin/plugins/setGlobalContext.js +0 -14
- package/dist/cjs/node/plugin/shared/rollupSourceMap.js +20 -0
- package/dist/cjs/node/plugin/utils.js +0 -1
- package/dist/cjs/node/prerender/runPrerender.js +3 -2
- package/dist/cjs/node/prerender/utils.js +1 -1
- package/dist/cjs/node/runtime/globalContext.js +8 -19
- package/dist/cjs/node/runtime/html/serializePageContextClientSide.js +1 -0
- package/dist/cjs/node/runtime/renderPage/analyzePage.js +2 -2
- package/dist/cjs/node/runtime/renderPage/getPageAssets/assertClientEntryId.js +2 -8
- package/dist/cjs/node/runtime/renderPage/getPageAssets/getManifestEntry.js +6 -7
- package/dist/cjs/node/runtime/renderPage/getPageAssets/retrieveAssetsProd.js +2 -2
- package/dist/cjs/node/runtime/renderPage/getPageAssets.js +23 -28
- package/dist/cjs/node/runtime/renderPage/renderPageAlreadyRouted.js +2 -23
- package/dist/cjs/node/runtime/utils.js +1 -2
- package/dist/cjs/node/shared/assertPluginManifest.js +1 -4
- package/dist/cjs/node/shared/assertV1Design.js +26 -0
- package/dist/cjs/node/shared/{getClientEntryFilePath.js → getClientEntry.js} +3 -3
- package/dist/cjs/node/shared/prependEntriesDir.js +13 -0
- package/dist/cjs/node/shared/utils.js +2 -0
- package/dist/cjs/node/shared/virtual-files/virtualFileImportUserCode.js +1 -0
- package/dist/cjs/shared/hooks/getHook.js +1 -1
- package/dist/cjs/shared/page-configs/helpers/getConfigValue.js +1 -0
- package/dist/cjs/shared/page-configs/serialize/parseConfigValuesImported.js +1 -1
- package/dist/cjs/shared/route/abort.js +1 -0
- package/dist/cjs/shared/route/resolvePrecedence.js +1 -0
- package/dist/cjs/utils/{nodeEnv.js → assertNodeEnv.js} +3 -0
- package/dist/cjs/utils/formatHintLog.js +1 -0
- package/dist/cjs/utils/hasProp.js +1 -0
- package/dist/cjs/utils/isScriptFile.js +15 -4
- package/dist/cjs/utils/projectInfo.js +1 -1
- package/dist/esm/__internal/index.js +1 -1
- package/dist/esm/client/shared/loadUserFilesClientSide.js +1 -0
- package/dist/esm/node/plugin/index.js +0 -2
- package/dist/esm/node/plugin/plugins/buildConfig.js +19 -19
- package/dist/esm/node/plugin/plugins/config/index.js +2 -7
- package/dist/esm/node/plugin/plugins/devConfig/determineFsAllowList.d.ts +1 -2
- package/dist/esm/node/plugin/plugins/devConfig/determineFsAllowList.js +1 -8
- package/dist/esm/node/plugin/plugins/devConfig/determineOptimizeDeps.d.ts +1 -2
- package/dist/esm/node/plugin/plugins/devConfig/determineOptimizeDeps.js +2 -19
- package/dist/esm/node/plugin/plugins/devConfig/index.js +2 -4
- package/dist/esm/node/plugin/plugins/envVars.js +6 -2
- package/dist/esm/node/plugin/plugins/extractAssetsPlugin.js +11 -23
- 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 +31 -97
- package/dist/esm/node/plugin/plugins/importUserCode/index.js +8 -8
- package/dist/esm/node/plugin/plugins/importUserCode/v1-design/getConfigValuesSerialized.js +1 -9
- package/dist/esm/node/plugin/plugins/importUserCode/v1-design/getVikeConfig/configDefinitionsBuiltIn.js +3 -0
- package/dist/esm/node/plugin/plugins/importUserCode/v1-design/getVikeConfig/filesystemRouting.d.ts +3 -3
- package/dist/esm/node/plugin/plugins/importUserCode/v1-design/getVikeConfig/filesystemRouting.js +1 -1
- package/dist/esm/node/plugin/plugins/importUserCode/v1-design/getVikeConfig/loadFileAtConfigTime.d.ts +1 -1
- package/dist/esm/node/plugin/plugins/importUserCode/v1-design/getVikeConfig/loadFileAtConfigTime.js +4 -4
- package/dist/esm/node/plugin/plugins/importUserCode/v1-design/getVikeConfig/resolveImportPath.js +1 -1
- package/dist/esm/node/plugin/plugins/importUserCode/v1-design/getVikeConfig/transformFileImports.d.ts +1 -13
- package/dist/esm/node/plugin/plugins/importUserCode/v1-design/getVikeConfig/transformFileImports.js +35 -36
- package/dist/esm/node/plugin/plugins/importUserCode/v1-design/getVikeConfig/transpileAndExecuteFile.d.ts +1 -1
- package/dist/esm/node/plugin/plugins/importUserCode/v1-design/getVikeConfig/transpileAndExecuteFile.js +111 -106
- package/dist/esm/node/plugin/plugins/importUserCode/v1-design/getVikeConfig.d.ts +3 -3
- package/dist/esm/node/plugin/plugins/importUserCode/v1-design/getVikeConfig.js +39 -33
- 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/plugin/utils.d.ts +0 -1
- package/dist/esm/node/plugin/utils.js +0 -1
- package/dist/esm/node/prerender/runPrerender.d.ts +3 -3
- package/dist/esm/node/prerender/runPrerender.js +4 -3
- package/dist/esm/node/prerender/utils.d.ts +1 -1
- package/dist/esm/node/prerender/utils.js +1 -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/html/serializePageContextClientSide.js +1 -0
- package/dist/esm/node/runtime/renderPage/analyzePage.js +2 -2
- package/dist/esm/node/runtime/renderPage/getPageAssets/assertClientEntryId.js +2 -8
- package/dist/esm/node/runtime/renderPage/getPageAssets/getManifestEntry.d.ts +1 -1
- package/dist/esm/node/runtime/renderPage/getPageAssets/getManifestEntry.js +6 -7
- 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 +24 -29
- package/dist/esm/node/runtime/renderPage/renderPageAlreadyRouted.js +3 -24
- package/dist/esm/node/runtime/utils.d.ts +1 -2
- package/dist/esm/node/runtime/utils.js +1 -2
- package/dist/esm/node/shared/ViteManifest.d.ts +1 -0
- 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/getClientEntry.d.ts +3 -0
- package/dist/esm/node/shared/{getClientEntryFilePath.js → getClientEntry.js} +2 -2
- package/dist/esm/node/shared/prependEntriesDir.d.ts +2 -0
- package/dist/esm/node/shared/prependEntriesDir.js +10 -0
- package/dist/esm/node/shared/utils.d.ts +2 -0
- package/dist/esm/node/shared/utils.js +2 -0
- package/dist/esm/node/shared/virtual-files/virtualFileImportUserCode.js +1 -0
- package/dist/esm/shared/ConfigVike.d.ts +0 -27
- package/dist/esm/shared/hooks/getHook.js +2 -2
- package/dist/esm/shared/page-configs/Config.d.ts +5 -0
- package/dist/esm/shared/page-configs/PageConfig.d.ts +2 -4
- package/dist/esm/shared/page-configs/helpers/getConfigValue.js +1 -0
- package/dist/esm/shared/page-configs/serialize/parseConfigValuesImported.js +1 -1
- package/dist/esm/shared/route/abort.js +1 -0
- package/dist/esm/shared/route/resolvePrecedence.js +1 -0
- package/dist/esm/utils/{nodeEnv.js → assertNodeEnv.js} +3 -0
- package/dist/esm/utils/debug.d.ts +1 -1
- package/dist/esm/utils/formatHintLog.js +1 -0
- package/dist/esm/utils/hasProp.js +1 -0
- package/dist/esm/utils/isScriptFile.d.ts +3 -1
- package/dist/esm/utils/isScriptFile.js +14 -3
- package/dist/esm/utils/projectInfo.d.ts +2 -2
- package/dist/esm/utils/projectInfo.js +1 -1
- package/package.json +4 -3
- package/dist/cjs/node/plugin/plugins/config/findConfigVikeFromStemPackages.js +0 -27
- package/dist/cjs/node/plugin/plugins/config/resolveExtensions.js +0 -107
- package/dist/cjs/node/plugin/plugins/config/stemUtils.js +0 -85
- package/dist/cjs/node/plugin/plugins/extensionsAssets.js +0 -101
- package/dist/cjs/node/plugin/shared/removeSourceMap.js +0 -12
- package/dist/cjs/utils/getDependencyPackageJson.js +0 -91
- package/dist/cjs/utils/isStemPackageName.js +0 -14
- package/dist/esm/node/plugin/plugins/config/findConfigVikeFromStemPackages.d.ts +0 -3
- package/dist/esm/node/plugin/plugins/config/findConfigVikeFromStemPackages.js +0 -24
- package/dist/esm/node/plugin/plugins/config/resolveExtensions.d.ts +0 -4
- package/dist/esm/node/plugin/plugins/config/resolveExtensions.js +0 -101
- package/dist/esm/node/plugin/plugins/config/stemUtils.d.ts +0 -8
- package/dist/esm/node/plugin/plugins/config/stemUtils.js +0 -79
- package/dist/esm/node/plugin/plugins/extensionsAssets.d.ts +0 -3
- package/dist/esm/node/plugin/plugins/extensionsAssets.js +0 -95
- package/dist/esm/node/plugin/shared/removeSourceMap.d.ts +0 -7
- package/dist/esm/node/plugin/shared/removeSourceMap.js +0 -9
- package/dist/esm/node/shared/getClientEntryFilePath.d.ts +0 -3
- package/dist/esm/utils/getDependencyPackageJson.d.ts +0 -6
- package/dist/esm/utils/getDependencyPackageJson.js +0 -85
- package/dist/esm/utils/isStemPackageName.d.ts +0 -1
- package/dist/esm/utils/isStemPackageName.js +0 -10
- /package/dist/esm/utils/{nodeEnv.d.ts → assertNodeEnv.d.ts} +0 -0
|
@@ -3,7 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.getPagesAndRoutes = exports.route = void 0;
|
|
4
4
|
const index_js_1 = require("../shared/route/index.js");
|
|
5
5
|
const globalContext_js_1 = require("../node/runtime/globalContext.js");
|
|
6
|
-
const
|
|
6
|
+
const assertNodeEnv_js_1 = require("../utils/assertNodeEnv.js");
|
|
7
7
|
const assert_js_1 = require("../utils/assert.js");
|
|
8
8
|
const renderPageAlreadyRouted_js_1 = require("../node/runtime/renderPage/renderPageAlreadyRouted.js");
|
|
9
9
|
/**
|
|
@@ -13,7 +13,7 @@ const renderPageAlreadyRouted_js_1 = require("../node/runtime/renderPage/renderP
|
|
|
13
13
|
* @param config
|
|
14
14
|
*/
|
|
15
15
|
async function getPagesAndRoutes() {
|
|
16
|
-
(0,
|
|
16
|
+
(0, assertNodeEnv_js_1.setNodeEnvToProduction)();
|
|
17
17
|
await (0, globalContext_js_1.initGlobalContext)(true);
|
|
18
18
|
const globalContext = (0, globalContext_js_1.getGlobalContext)();
|
|
19
19
|
(0, assert_js_1.assert)(globalContext.isProduction === true);
|
|
@@ -23,7 +23,6 @@ const suppressRollupWarning_js_1 = require("./plugins/suppressRollupWarning.js")
|
|
|
23
23
|
const setGlobalContext_js_1 = require("./plugins/setGlobalContext.js");
|
|
24
24
|
const index_js_4 = require("./plugins/importBuild/index.js");
|
|
25
25
|
const commonConfig_js_1 = require("./plugins/commonConfig.js");
|
|
26
|
-
const extensionsAssets_js_1 = require("./plugins/extensionsAssets.js");
|
|
27
26
|
const baseUrls_js_1 = require("./plugins/baseUrls.js");
|
|
28
27
|
const envVars_js_1 = require("./plugins/envVars.js");
|
|
29
28
|
const picocolors_1 = __importDefault(require("@brillout/picocolors"));
|
|
@@ -48,7 +47,6 @@ function plugin(vikeConfig) {
|
|
|
48
47
|
(0, suppressRollupWarning_js_1.suppressRollupWarning)(),
|
|
49
48
|
(0, setGlobalContext_js_1.setGlobalContext)(),
|
|
50
49
|
...(0, index_js_4.importBuild)(),
|
|
51
|
-
(0, extensionsAssets_js_1.extensionsAssets)(),
|
|
52
50
|
(0, baseUrls_js_1.baseUrls)(vikeConfig),
|
|
53
51
|
(0, envVars_js_1.envVarsPlugin)(),
|
|
54
52
|
(0, fileEnv_js_1.fileEnv)()
|
|
@@ -12,11 +12,12 @@ const getConfigVike_js_1 = require("../../shared/getConfigVike.js");
|
|
|
12
12
|
const virtualFilePageConfigValuesAll_js_1 = require("../../shared/virtual-files/virtualFilePageConfigValuesAll.js");
|
|
13
13
|
const extractAssetsQuery_js_1 = require("../../shared/extractAssetsQuery.js");
|
|
14
14
|
const module_1 = require("module");
|
|
15
|
-
const
|
|
15
|
+
const getClientEntry_js_1 = require("../../shared/getClientEntry.js");
|
|
16
16
|
const promises_1 = __importDefault(require("fs/promises"));
|
|
17
17
|
const path_1 = __importDefault(require("path"));
|
|
18
18
|
const fixServerAssets_js_1 = require("./buildConfig/fixServerAssets.js");
|
|
19
19
|
const index_js_1 = require("./importBuild/index.js");
|
|
20
|
+
const prependEntriesDir_js_1 = require("../../shared/prependEntriesDir.js");
|
|
20
21
|
// @ts-ignore Shimmed by dist-cjs-fixup.js for CJS build.
|
|
21
22
|
const importMetaUrl = `file://${__filename}`;
|
|
22
23
|
const require_ = (0, module_1.createRequire)(importMetaUrl);
|
|
@@ -136,7 +137,7 @@ function analyzeClientEntries(pageConfigs, config) {
|
|
|
136
137
|
let hasClientRouting = false;
|
|
137
138
|
let hasServerRouting = false;
|
|
138
139
|
let clientEntries = {};
|
|
139
|
-
let
|
|
140
|
+
let clientEntryList = [];
|
|
140
141
|
pageConfigs.forEach((pageConfig) => {
|
|
141
142
|
const configValue = (0, helpers_js_1.getConfigValue)(pageConfig, 'clientRouting', 'boolean');
|
|
142
143
|
if (configValue?.value) {
|
|
@@ -151,15 +152,15 @@ function analyzeClientEntries(pageConfigs, config) {
|
|
|
151
152
|
clientEntries[entryName] = entryTarget;
|
|
152
153
|
}
|
|
153
154
|
{
|
|
154
|
-
const
|
|
155
|
-
if (
|
|
156
|
-
|
|
155
|
+
const clientEntry = (0, getClientEntry_js_1.getClientEntry)(pageConfig);
|
|
156
|
+
if (clientEntry) {
|
|
157
|
+
clientEntryList.push(clientEntry);
|
|
157
158
|
}
|
|
158
159
|
}
|
|
159
160
|
});
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
const { entryName, entryTarget } =
|
|
161
|
+
clientEntryList = (0, utils_js_1.unique)(clientEntryList);
|
|
162
|
+
clientEntryList.forEach((clientEntry) => {
|
|
163
|
+
const { entryName, entryTarget } = getEntryFromClientEntry(clientEntry, config);
|
|
163
164
|
clientEntries[entryName] = entryTarget;
|
|
164
165
|
});
|
|
165
166
|
return { hasClientRouting, hasServerRouting, clientEntries };
|
|
@@ -182,12 +183,18 @@ async function getPageFileEntries(config, includeAssetsImportedByServer) {
|
|
|
182
183
|
(0, utils_js_1.assert)(includeAssetsImportedByServer);
|
|
183
184
|
addExtractAssetsQuery = true;
|
|
184
185
|
}
|
|
185
|
-
const { entryName, entryTarget } =
|
|
186
|
+
const { entryName, entryTarget } = getEntryFromClientEntry(pageFile, config, addExtractAssetsQuery);
|
|
186
187
|
pageFileEntries[entryName] = entryTarget;
|
|
187
188
|
});
|
|
188
189
|
return pageFileEntries;
|
|
189
190
|
}
|
|
190
|
-
function
|
|
191
|
+
function getEntryFromClientEntry(clientEntry, config, addExtractAssetsQuery) {
|
|
192
|
+
if ((0, utils_js_1.isNpmPackageImport)(clientEntry)) {
|
|
193
|
+
const entryTarget = clientEntry;
|
|
194
|
+
const entryName = (0, prependEntriesDir_js_1.prependEntriesDir)(clientEntry);
|
|
195
|
+
return { entryName, entryTarget };
|
|
196
|
+
}
|
|
197
|
+
const filePath = clientEntry;
|
|
191
198
|
(0, utils_js_1.assertPosixPath)(filePath);
|
|
192
199
|
(0, utils_js_1.assert)(filePath.startsWith('/'));
|
|
193
200
|
let entryTarget = (0, utils_js_1.getFilePathAbsolute)(filePath, config);
|
|
@@ -197,24 +204,16 @@ function getEntryFromFilePath(filePath, config, addExtractAssetsQuery) {
|
|
|
197
204
|
if (addExtractAssetsQuery)
|
|
198
205
|
entryName = (0, extractAssetsQuery_js_1.extractAssetsAddQuery)(entryName);
|
|
199
206
|
entryName = (0, utils_js_1.removeFileExtention)(entryName);
|
|
200
|
-
entryName = prependEntriesDir(entryName);
|
|
207
|
+
entryName = (0, prependEntriesDir_js_1.prependEntriesDir)(entryName);
|
|
201
208
|
return { entryName, entryTarget };
|
|
202
209
|
}
|
|
203
210
|
function getEntryFromPageConfig(pageConfig, isForClientSide) {
|
|
204
211
|
let { pageId } = pageConfig;
|
|
205
212
|
const entryTarget = (0, virtualFilePageConfigValuesAll_js_1.getVirtualFileIdPageConfigValuesAll)(pageId, isForClientSide);
|
|
206
213
|
let entryName = pageId;
|
|
207
|
-
entryName = prependEntriesDir(entryName);
|
|
214
|
+
entryName = (0, prependEntriesDir_js_1.prependEntriesDir)(entryName);
|
|
208
215
|
return { entryName, entryTarget };
|
|
209
216
|
}
|
|
210
|
-
function prependEntriesDir(entryName) {
|
|
211
|
-
if (entryName.startsWith('/')) {
|
|
212
|
-
entryName = entryName.slice(1);
|
|
213
|
-
}
|
|
214
|
-
(0, utils_js_1.assert)(!entryName.startsWith('/'));
|
|
215
|
-
entryName = `entries/${entryName}`;
|
|
216
|
-
return entryName;
|
|
217
|
-
}
|
|
218
217
|
function resolve(filePath) {
|
|
219
218
|
(0, utils_js_1.assert)(filePath.startsWith('dist/'));
|
|
220
219
|
// [RELATIVE_PATH_FROM_DIST] Current directory: node_modules/vike/dist/esm/node/plugin/plugins/
|
|
@@ -234,6 +233,7 @@ function addLogHook() {
|
|
|
234
233
|
});
|
|
235
234
|
// Exhaustive list extracted from writeLine() calls at https://github.com/vitejs/vite/blob/193d55c7b9cbfec5b79ebfca276d4a721e7de14d/packages/vite/src/node/plugins/reporter.ts
|
|
236
235
|
// prettier-ignore
|
|
236
|
+
// biome-ignore format:
|
|
237
237
|
const viteTransientLogs = [
|
|
238
238
|
'transforming (',
|
|
239
239
|
'rendering chunks (',
|
|
@@ -6,9 +6,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
6
6
|
exports.resolveVikeConfig = void 0;
|
|
7
7
|
const assertVikeConfig_js_1 = require("./assertVikeConfig.js");
|
|
8
8
|
const utils_js_1 = require("../../utils.js");
|
|
9
|
-
const findConfigVikeFromStemPackages_js_1 = require("./findConfigVikeFromStemPackages.js");
|
|
10
9
|
const pickFirst_js_1 = require("./pickFirst.js");
|
|
11
|
-
const resolveExtensions_js_1 = require("./resolveExtensions.js");
|
|
12
10
|
const resolveBase_js_1 = require("./resolveBase.js");
|
|
13
11
|
const getVikeConfig_js_1 = require("../importUserCode/v1-design/getVikeConfig.js");
|
|
14
12
|
const picocolors_1 = __importDefault(require("@brillout/picocolors"));
|
|
@@ -27,10 +25,8 @@ exports.resolveVikeConfig = resolveVikeConfig;
|
|
|
27
25
|
async function getConfigVikPromise(vikeConfig, config) {
|
|
28
26
|
const fromPluginOptions = (vikeConfig ?? {});
|
|
29
27
|
const fromViteConfig = (config.vike ?? {});
|
|
30
|
-
const
|
|
31
|
-
const
|
|
32
|
-
const extensions = (0, resolveExtensions_js_1.resolveExtensions)(configs, config);
|
|
33
|
-
const { globalVikeConfig: fromPlusConfigFile } = await (0, getVikeConfig_js_1.getVikeConfig)(config, (0, utils_js_1.isDev2)(config), false, extensions);
|
|
28
|
+
const configs = [fromPluginOptions, fromViteConfig];
|
|
29
|
+
const { globalVikeConfig: fromPlusConfigFile } = await (0, getVikeConfig_js_1.getVikeConfig)(config, (0, utils_js_1.isDev2)(config), false);
|
|
34
30
|
configs.push(fromPlusConfigFile);
|
|
35
31
|
(0, assertVikeConfig_js_1.assertVikeConfig)(fromPlusConfigFile, ({ prop, errMsg }) => {
|
|
36
32
|
// TODO: add config file path ?
|
|
@@ -42,7 +38,6 @@ async function getConfigVikPromise(vikeConfig, config) {
|
|
|
42
38
|
const { baseServer, baseAssets } = (0, resolveBase_js_1.resolveBase)(configs, config);
|
|
43
39
|
const configVike = {
|
|
44
40
|
disableAutoFullBuild: (0, pickFirst_js_1.pickFirst)(configs.map((c) => c.disableAutoFullBuild)) ?? null,
|
|
45
|
-
extensions,
|
|
46
41
|
prerender: resolvePrerenderOptions(configs),
|
|
47
42
|
includeAssetsImportedByServer: (0, pickFirst_js_1.pickFirst)(configs.map((c) => c.includeAssetsImportedByServer)) ?? true,
|
|
48
43
|
baseServer,
|
|
@@ -6,7 +6,6 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
6
6
|
exports.determineFsAllowList = void 0;
|
|
7
7
|
const vite_1 = require("vite");
|
|
8
8
|
const path_1 = __importDefault(require("path"));
|
|
9
|
-
const fs_1 = __importDefault(require("fs"));
|
|
10
9
|
const utils_js_1 = require("../../utils.js");
|
|
11
10
|
const module_1 = require("module");
|
|
12
11
|
const path_2 = require("path");
|
|
@@ -15,7 +14,7 @@ const url_1 = require("url");
|
|
|
15
14
|
const importMetaUrl = `file://${__filename}`;
|
|
16
15
|
const require_ = (0, module_1.createRequire)(importMetaUrl);
|
|
17
16
|
const __dirname_ = (0, path_2.dirname)((0, url_1.fileURLToPath)(importMetaUrl));
|
|
18
|
-
async function determineFsAllowList(config
|
|
17
|
+
async function determineFsAllowList(config) {
|
|
19
18
|
const fsAllow = config.server.fs.allow;
|
|
20
19
|
// fsAllow should already contain searchForWorkspaceRoot()
|
|
21
20
|
(0, utils_js_1.assert)(fsAllow.length >= 1);
|
|
@@ -32,11 +31,5 @@ async function determineFsAllowList(config, configVike) {
|
|
|
32
31
|
require_.resolve(`${vikeRoot}/dist/esm/node/plugin/plugins/devConfig/index.js`);
|
|
33
32
|
fsAllow.push(vikeRoot);
|
|
34
33
|
}
|
|
35
|
-
// Add Vike extensions, e.g. node_modules/stem-react/
|
|
36
|
-
configVike.extensions.forEach(({ npmPackageRootDir }) => {
|
|
37
|
-
const npmPackageRootDirReal = fs_1.default.realpathSync(npmPackageRootDir);
|
|
38
|
-
fsAllow.push(npmPackageRootDir);
|
|
39
|
-
fsAllow.push(npmPackageRootDirReal);
|
|
40
|
-
});
|
|
41
34
|
}
|
|
42
35
|
exports.determineFsAllowList = determineFsAllowList;
|
|
@@ -7,7 +7,7 @@ const getVikeConfig_js_1 = require("../importUserCode/v1-design/getVikeConfig.js
|
|
|
7
7
|
const getConfigValueSourcesNotOverriden_js_1 = require("../../shared/getConfigValueSourcesNotOverriden.js");
|
|
8
8
|
const buildConfig_js_1 = require("../buildConfig.js");
|
|
9
9
|
const virtualFileImportUserCode_js_1 = require("../../../shared/virtual-files/virtualFileImportUserCode.js");
|
|
10
|
-
async function determineOptimizeDeps(config,
|
|
10
|
+
async function determineOptimizeDeps(config, isDev) {
|
|
11
11
|
const { pageConfigs } = await (0, getVikeConfig_js_1.getVikeConfig)(config, isDev);
|
|
12
12
|
const { entries, include } = await getPageDeps(config, pageConfigs, isDev);
|
|
13
13
|
{
|
|
@@ -18,7 +18,6 @@ async function determineOptimizeDeps(config, configVike, isDev) {
|
|
|
18
18
|
const entriesVirtualFiles = getVirtualFiles(config, pageConfigs);
|
|
19
19
|
entries.push(...entriesVirtualFiles);
|
|
20
20
|
}
|
|
21
|
-
include.push(...getExtensionsDeps(configVike));
|
|
22
21
|
/* Other Vite plugins may populate optimizeDeps, e.g. Cypress: https://github.com/vikejs/vike/issues/386
|
|
23
22
|
assert(config.optimizeDeps.entries === undefined)
|
|
24
23
|
*/
|
|
@@ -91,22 +90,6 @@ function getVirtualFiles(config, pageConfigs) {
|
|
|
91
90
|
entriesVirtualFiles.push(virtualFileImportUserCode_js_1.virtualFileIdImportUserCodeClientSR);
|
|
92
91
|
return entriesVirtualFiles;
|
|
93
92
|
}
|
|
94
|
-
function getExtensionsDeps(configVike) {
|
|
95
|
-
return [
|
|
96
|
-
/* Doesn't work since `pageConfigsSrcDir` is a directory. We could make it work by using find-glob.
|
|
97
|
-
...configVike.extensions
|
|
98
|
-
.map(({ pageConfigsSrcDir }) => pageConfigsSrcDir)
|
|
99
|
-
.flat()
|
|
100
|
-
.filter(isNotNullish),
|
|
101
|
-
//*/
|
|
102
|
-
...configVike.extensions
|
|
103
|
-
.map(({ pageConfigsDistFiles }) => pageConfigsDistFiles)
|
|
104
|
-
.flat()
|
|
105
|
-
.filter(utils_js_1.isNotNullish)
|
|
106
|
-
.filter(({ importPath }) => !importPath.endsWith('.css'))
|
|
107
|
-
.map(({ importPath }) => importPath)
|
|
108
|
-
];
|
|
109
|
-
}
|
|
110
93
|
function normalizeEntries(entries) {
|
|
111
94
|
if (Array.isArray(entries))
|
|
112
95
|
return entries;
|
|
@@ -3,7 +3,6 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.devConfig = void 0;
|
|
4
4
|
const determineOptimizeDeps_js_1 = require("./determineOptimizeDeps.js");
|
|
5
5
|
const determineFsAllowList_js_1 = require("./determineFsAllowList.js");
|
|
6
|
-
const getConfigVike_js_1 = require("../../../shared/getConfigVike.js");
|
|
7
6
|
const addSsrMiddleware_js_1 = require("../../shared/addSsrMiddleware.js");
|
|
8
7
|
const utils_js_1 = require("../../utils.js");
|
|
9
8
|
const loggerVite_js_1 = require("../../shared/loggerVite.js");
|
|
@@ -57,9 +56,8 @@ function devConfig() {
|
|
|
57
56
|
},
|
|
58
57
|
async configResolved(config_) {
|
|
59
58
|
config = config_;
|
|
60
|
-
|
|
61
|
-
await (0,
|
|
62
|
-
await (0, determineFsAllowList_js_1.determineFsAllowList)(config, configVike);
|
|
59
|
+
await (0, determineOptimizeDeps_js_1.determineOptimizeDeps)(config, isDev);
|
|
60
|
+
await (0, determineFsAllowList_js_1.determineFsAllowList)(config);
|
|
63
61
|
if (!(0, isErrorDebug_js_1.isErrorDebug)()) {
|
|
64
62
|
await (0, getHttpRequestAsyncStore_js_1.installHttpRequestAsyncStore)();
|
|
65
63
|
(0, loggerVite_js_1.improveViteLogs)(config);
|
|
@@ -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
|
|
@@ -96,25 +102,6 @@ function extractAssetsPlugin() {
|
|
|
96
102
|
if (!(0, utils_js_1.isScriptFile)(file)) {
|
|
97
103
|
return emptyModule(file, importer);
|
|
98
104
|
}
|
|
99
|
-
// If the dependency is a Vike extension and has `configVike.extension[number].pageConfigsSrcDir`, then include its CSS
|
|
100
|
-
if (configVike.extensions
|
|
101
|
-
.filter(({ pageConfigsSrcDir }) => pageConfigsSrcDir !== null)
|
|
102
|
-
.some(({ npmPackageName }) => {
|
|
103
|
-
const check1 = source === npmPackageName ||
|
|
104
|
-
source.startsWith(npmPackageName + '/') ||
|
|
105
|
-
// Include relative imports within modules of `npmPackageName`. (This only works for dependencies: user may use import path aliases.)
|
|
106
|
-
source.startsWith('.');
|
|
107
|
-
// This doesn't work for linked dependencies
|
|
108
|
-
const check2 = file.includes('node_modules/' + npmPackageName + '/') ||
|
|
109
|
-
file.includes('node_modules\\' + npmPackageName + '\\');
|
|
110
|
-
if (check1) {
|
|
111
|
-
return true;
|
|
112
|
-
}
|
|
113
|
-
(0, utils_js_1.assert)(!check2);
|
|
114
|
-
return false;
|
|
115
|
-
})) {
|
|
116
|
-
return appendExtractAssetsQuery(file, importer);
|
|
117
|
-
}
|
|
118
105
|
// If the import path resolves to a file in `node_modules/`, we ignore that file:
|
|
119
106
|
// - Direct CSS dependencies are included though, such as `import 'bootstrap/theme/dark.css'`. (Because the above if-branch for CSS files will add the file.)
|
|
120
107
|
// - Loading CSS from a library (living in `node_modules/`) in a non-direct way is non-standard; we can safely not support this case. (I'm not aware of any library that does this.)
|
|
@@ -136,6 +123,7 @@ function extractAssetsPlugin() {
|
|
|
136
123
|
async configResolved(config_) {
|
|
137
124
|
configVike = await (0, getConfigVike_js_1.getConfigVike)(config_);
|
|
138
125
|
config = config_;
|
|
126
|
+
vikeConfig = await (0, getVikeConfig_js_1.getVikeConfig)(config, false);
|
|
139
127
|
isServerAssetsFixEnabled = (0, fixServerAssets_js_1.fixServerAssets_isEnabled)() && (await (0, getVikeConfig_js_1.isV1Design)(config, false));
|
|
140
128
|
},
|
|
141
129
|
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,11 @@ 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
|
|
13
|
+
const getVikeConfig_js_1 = require("./v1-design/getVikeConfig.js");
|
|
13
14
|
async function getVirtualFileImportUserCode(id, options, configVike, config, isDev) {
|
|
14
15
|
const idParsed = (0, virtualFileImportUserCode_js_1.isVirtualFileIdImportUserCode)(id);
|
|
15
16
|
(0, utils_js_1.assert)(idParsed);
|
|
@@ -27,53 +28,13 @@ async function getCode(config, configVike, isForClientSide, isClientRouting, isP
|
|
|
27
28
|
(0, utils_js_1.assert)(isDev === !isBuild);
|
|
28
29
|
let content = '';
|
|
29
30
|
{
|
|
30
|
-
const globRoots = getGlobRoots(config
|
|
31
|
+
const globRoots = getGlobRoots(config);
|
|
31
32
|
(0, utils_js_1.debugGlob)('Glob roots: ', globRoots);
|
|
32
33
|
content += await generateGlobImports(globRoots, isBuild, isForClientSide, isClientRouting, configVike, isPrerendering, config, isDev, id);
|
|
33
34
|
}
|
|
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
35
|
(0, utils_js_1.debugGlob)(`Glob imports for ${isForClientSide ? 'client' : 'server'}:\n`, content);
|
|
43
36
|
return content;
|
|
44
37
|
}
|
|
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
38
|
function determineInjection({ fileType, isForClientSide, isClientRouting, isPrerendering, isBuild }) {
|
|
78
39
|
if (!isForClientSide) {
|
|
79
40
|
return {
|
|
@@ -99,42 +60,6 @@ function determineInjection({ fileType, isForClientSide, isClientRouting, isPrer
|
|
|
99
60
|
}
|
|
100
61
|
}
|
|
101
62
|
}
|
|
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
63
|
async function generateGlobImports(globRoots, isBuild, isForClientSide, isClientRouting, configVike, isPrerendering, config, isDev, id) {
|
|
139
64
|
let fileContent = `// Generatead by node/plugin/plugins/virtualFiles/index.ts
|
|
140
65
|
|
|
@@ -149,6 +74,8 @@ export const isGeneratedFile = true;
|
|
|
149
74
|
${await (0, getVirtualFilePageConfigs_js_1.getVirtualFilePageConfigs)(isForClientSide, isDev, id, isClientRouting, config)}
|
|
150
75
|
|
|
151
76
|
`;
|
|
77
|
+
// We still use import.meta.glob() when using th V1 design in order to not break the V1 design deprecation warning
|
|
78
|
+
const isV1Design = await (0, getVikeConfig_js_1.isV1Design)(config, isDev);
|
|
152
79
|
fileTypes_js_1.fileTypes
|
|
153
80
|
.filter((fileType) => fileType !== '.css')
|
|
154
81
|
.forEach((fileType) => {
|
|
@@ -161,18 +88,18 @@ ${await (0, getVirtualFilePageConfigs_js_1.getVirtualFilePageConfigs)(isForClien
|
|
|
161
88
|
isBuild
|
|
162
89
|
});
|
|
163
90
|
if (includeImport) {
|
|
164
|
-
fileContent += getGlobs(globRoots, isBuild, fileType);
|
|
91
|
+
fileContent += getGlobs(globRoots, isBuild, fileType, null, isV1Design);
|
|
165
92
|
}
|
|
166
93
|
if (includeExportNames) {
|
|
167
|
-
fileContent += getGlobs(globRoots, isBuild, fileType, 'extractExportNames');
|
|
94
|
+
fileContent += getGlobs(globRoots, isBuild, fileType, 'extractExportNames', isV1Design);
|
|
168
95
|
}
|
|
169
96
|
});
|
|
170
97
|
if (configVike.includeAssetsImportedByServer && isForClientSide) {
|
|
171
|
-
fileContent += getGlobs(globRoots, isBuild, '.page.server', 'extractAssets');
|
|
98
|
+
fileContent += getGlobs(globRoots, isBuild, '.page.server', 'extractAssets', isV1Design);
|
|
172
99
|
}
|
|
173
100
|
return fileContent;
|
|
174
101
|
}
|
|
175
|
-
function getGlobs(globRoots, isBuild, fileType, query) {
|
|
102
|
+
function getGlobs(globRoots, isBuild, fileType, query, isV1Design) {
|
|
176
103
|
const isEager = isBuild && (query === 'extractExportNames' || fileType === '.page.route');
|
|
177
104
|
let pageFilesVar;
|
|
178
105
|
if (query === 'extractExportNames') {
|
|
@@ -212,10 +139,26 @@ function getGlobs(globRoots, isBuild, fileType, query) {
|
|
|
212
139
|
varNameLocals.push(varNameLocal);
|
|
213
140
|
const globIncludePath = `'${getGlobPath(globRoot.includeDir, fileType)}'`;
|
|
214
141
|
const globExcludePath = globRoot.excludeDir ? `'!${getGlobPath(globRoot.excludeDir, fileType)}'` : null;
|
|
215
|
-
const globOptions =
|
|
216
|
-
|
|
142
|
+
const globOptions = { eager: isEager };
|
|
143
|
+
if (query) {
|
|
144
|
+
const isNewViteInterface = (0, utils_js_1.isVersionOrAbove)(vite_1.version, '5.1.0');
|
|
145
|
+
if (isNewViteInterface &&
|
|
146
|
+
// When used for the old design, the new syntax breaks Vike's CI (surprinsigly so). I couldn't reproduce locally (I didn't dig much).
|
|
147
|
+
isV1Design) {
|
|
148
|
+
globOptions.query = `?${query}`;
|
|
149
|
+
}
|
|
150
|
+
else {
|
|
151
|
+
globOptions.as = query;
|
|
152
|
+
const msg = [
|
|
153
|
+
"Update to the new V1 design to get rid of Vite's warning:",
|
|
154
|
+
'The glob option "as" has been deprecated in favour of "query".',
|
|
155
|
+
'See https://vike.dev/migration/v1-design for how to migrate.'
|
|
156
|
+
].join(' ');
|
|
157
|
+
(0, utils_js_1.assertWarning)(!isNewViteInterface, msg, { onlyOnce: true });
|
|
158
|
+
}
|
|
159
|
+
}
|
|
217
160
|
const globPaths = globExcludePath ? `[${globIncludePath}, ${globExcludePath}]` : `[${globIncludePath}]`;
|
|
218
|
-
const globLine = `const ${varNameLocal} = import.meta.glob(${globPaths}, ${globOptions});`;
|
|
161
|
+
const globLine = `const ${varNameLocal} = import.meta.glob(${globPaths}, ${JSON.stringify(globOptions)});`;
|
|
219
162
|
return globLine;
|
|
220
163
|
}),
|
|
221
164
|
`const ${varName} = {${varNameLocals.map((varNameLocal) => `...${varNameLocal}`).join(',')}};`,
|
|
@@ -223,22 +166,13 @@ function getGlobs(globRoots, isBuild, fileType, query) {
|
|
|
223
166
|
''
|
|
224
167
|
].join('\n');
|
|
225
168
|
}
|
|
226
|
-
function getGlobRoots(config
|
|
169
|
+
function getGlobRoots(config) {
|
|
227
170
|
const globRoots = [
|
|
228
171
|
{
|
|
229
172
|
includeDir: '/',
|
|
230
173
|
excludeDir: path_1.default.posix.relative(config.root, (0, utils_js_1.getOutDirs)(config).outDirRoot)
|
|
231
174
|
}
|
|
232
175
|
];
|
|
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
176
|
return globRoots;
|
|
243
177
|
}
|
|
244
178
|
function getGlobPath(globRootDir, fileType) {
|