vike 0.4.221 → 0.4.222-commit-207e079
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/api/prepareViteApiCall.js +18 -16
- package/dist/cjs/node/plugin/index.js +1 -1
- package/dist/cjs/node/plugin/plugins/baseUrls.js +6 -1
- package/dist/cjs/node/plugin/plugins/buildConfig/fixServerAssets.js +8 -10
- package/dist/cjs/node/plugin/plugins/buildConfig.js +0 -1
- package/dist/cjs/node/plugin/plugins/commonConfig.js +4 -1
- package/dist/cjs/node/plugin/plugins/importUserCode/index.js +73 -39
- package/dist/cjs/node/plugin/plugins/importUserCode/v1-design/getVikeConfig/crawlPlusFiles.js +64 -14
- package/dist/cjs/node/plugin/plugins/importUserCode/v1-design/getVikeConfig/filesystemRouting.js +0 -5
- package/dist/cjs/node/plugin/plugins/importUserCode/v1-design/getVikeConfig/getPlusFilesAll.js +2 -40
- package/dist/cjs/node/plugin/plugins/importUserCode/v1-design/getVikeConfig/loadFileAtConfigTime.js +1 -1
- package/dist/cjs/node/plugin/plugins/importUserCode/v1-design/getVikeConfig/transpileAndExecuteFile.js +6 -3
- package/dist/cjs/node/plugin/plugins/importUserCode/v1-design/getVikeConfig.js +49 -18
- package/dist/cjs/node/runtime/globalContext.js +24 -8
- package/dist/cjs/node/runtime/renderPage/loadUserFilesServerSide.js +3 -3
- package/dist/cjs/node/runtime/renderPage/renderPageAlreadyRouted.js +2 -4
- package/dist/cjs/node/runtime/renderPage.js +4 -8
- package/dist/cjs/node/runtime-dev/createDevMiddleware.js +3 -3
- package/dist/cjs/node/shared/resolveBase.js +0 -13
- package/dist/cjs/shared/getPageConfigsRuntime.js +10 -1
- package/dist/cjs/shared/page-configs/getPageConfigUserFriendly.js +4 -2
- package/dist/cjs/shared/route/loadPageRoutes.js +1 -1
- package/dist/cjs/utils/PROJECT_VERSION.js +1 -1
- package/dist/cjs/utils/assertSingleInstance.js +1 -1
- package/dist/cjs/utils/debug.js +9 -6
- package/dist/esm/client/client-routing-runtime/prefetch.js +1 -1
- package/dist/esm/client/client-routing-runtime/renderPageClientSide.d.ts +5 -0
- package/dist/esm/client/client-routing-runtime/renderPageClientSide.js +9 -2
- package/dist/esm/client/server-routing-runtime/getPageContext.d.ts +1 -0
- package/dist/esm/client/server-routing-runtime/getPageContext.js +4 -3
- package/dist/esm/client/shared/loadUserFilesClientSide.d.ts +3 -2
- package/dist/esm/client/shared/loadUserFilesClientSide.js +2 -2
- package/dist/esm/node/api/prepareViteApiCall.d.ts +2 -2
- package/dist/esm/node/api/prepareViteApiCall.js +18 -16
- package/dist/esm/node/plugin/index.d.ts +4 -1
- package/dist/esm/node/plugin/index.js +1 -1
- package/dist/esm/node/plugin/plugins/baseUrls.js +6 -1
- package/dist/esm/node/plugin/plugins/buildConfig/fixServerAssets.d.ts +0 -2
- package/dist/esm/node/plugin/plugins/buildConfig/fixServerAssets.js +8 -10
- package/dist/esm/node/plugin/plugins/buildConfig.js +1 -2
- package/dist/esm/node/plugin/plugins/commonConfig.d.ts +1 -0
- package/dist/esm/node/plugin/plugins/commonConfig.js +4 -1
- package/dist/esm/node/plugin/plugins/importUserCode/index.js +73 -39
- package/dist/esm/node/plugin/plugins/importUserCode/v1-design/getVikeConfig/crawlPlusFiles.d.ts +4 -0
- package/dist/esm/node/plugin/plugins/importUserCode/v1-design/getVikeConfig/crawlPlusFiles.js +65 -15
- package/dist/esm/node/plugin/plugins/importUserCode/v1-design/getVikeConfig/filesystemRouting.d.ts +0 -3
- package/dist/esm/node/plugin/plugins/importUserCode/v1-design/getVikeConfig/filesystemRouting.js +0 -5
- package/dist/esm/node/plugin/plugins/importUserCode/v1-design/getVikeConfig/getPlusFilesAll.d.ts +0 -2
- package/dist/esm/node/plugin/plugins/importUserCode/v1-design/getVikeConfig/getPlusFilesAll.js +2 -37
- package/dist/esm/node/plugin/plugins/importUserCode/v1-design/getVikeConfig/loadFileAtConfigTime.js +1 -1
- 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 +6 -3
- package/dist/esm/node/plugin/plugins/importUserCode/v1-design/getVikeConfig.d.ts +3 -2
- package/dist/esm/node/plugin/plugins/importUserCode/v1-design/getVikeConfig.js +50 -19
- package/dist/esm/node/runtime/globalContext.d.ts +10 -7
- package/dist/esm/node/runtime/globalContext.js +24 -8
- package/dist/esm/node/runtime/html/injectAssets/getViteDevScript.d.ts +2 -2
- package/dist/esm/node/runtime/html/injectAssets.d.ts +2 -2
- package/dist/esm/node/runtime/renderPage/analyzePage.d.ts +2 -2
- package/dist/esm/node/runtime/renderPage/getPageAssets.d.ts +2 -2
- package/dist/esm/node/runtime/renderPage/handleErrorWithoutErrorPage.d.ts +2 -2
- package/dist/esm/node/runtime/renderPage/loadUserFilesServerSide.d.ts +2 -2
- package/dist/esm/node/runtime/renderPage/loadUserFilesServerSide.js +3 -3
- package/dist/esm/node/runtime/renderPage/log404/index.d.ts +2 -2
- package/dist/esm/node/runtime/renderPage/preparePageContextForUserConsumptionServerSide.d.ts +2 -2
- package/dist/esm/node/runtime/renderPage/renderPageAlreadyRouted.d.ts +8 -8
- package/dist/esm/node/runtime/renderPage/renderPageAlreadyRouted.js +2 -4
- package/dist/esm/node/runtime/renderPage.js +4 -8
- package/dist/esm/node/runtime-dev/createDevMiddleware.js +3 -3
- package/dist/esm/node/shared/resolveBase.d.ts +1 -9
- package/dist/esm/node/shared/resolveBase.js +0 -13
- package/dist/esm/shared/getPageConfigsRuntime.d.ts +2 -1
- package/dist/esm/shared/getPageConfigsRuntime.js +10 -1
- package/dist/esm/shared/page-configs/getPageConfigUserFriendly.d.ts +8 -2
- package/dist/esm/shared/page-configs/getPageConfigUserFriendly.js +4 -2
- package/dist/esm/shared/route/loadPageRoutes.js +1 -1
- package/dist/esm/shared/types.d.ts +9 -0
- package/dist/esm/utils/PROJECT_VERSION.d.ts +1 -1
- package/dist/esm/utils/PROJECT_VERSION.js +1 -1
- package/dist/esm/utils/assertSingleInstance.js +1 -1
- package/dist/esm/utils/debug.d.ts +1 -1
- package/dist/esm/utils/debug.js +9 -6
- package/dist/esm/utils/projectInfo.d.ts +1 -1
- package/package.json +1 -1
|
@@ -49,18 +49,18 @@ const utils_js_1 = require("./utils.js");
|
|
|
49
49
|
const picocolors_1 = __importDefault(require("@brillout/picocolors"));
|
|
50
50
|
const globalContext_js_1 = require("../runtime/globalContext.js");
|
|
51
51
|
const globalObject = (0, utils_js_1.getGlobalObject)('prepareViteApiCall.ts', {});
|
|
52
|
-
async function prepareViteApiCall(
|
|
52
|
+
async function prepareViteApiCall(viteConfigFromOptions, operation) {
|
|
53
53
|
clear();
|
|
54
54
|
(0, context_js_1.setContextApiOperation)(operation);
|
|
55
|
-
return enhanceViteConfig(
|
|
55
|
+
return enhanceViteConfig(viteConfigFromOptions, operation);
|
|
56
56
|
}
|
|
57
57
|
// For subsequent API calls, e.g. calling prerender() after build()
|
|
58
58
|
function clear() {
|
|
59
59
|
(0, context_js_1.clearContextApiOperation)();
|
|
60
60
|
(0, globalContext_js_1.clearGlobalContext)();
|
|
61
61
|
}
|
|
62
|
-
async function enhanceViteConfig(
|
|
63
|
-
const viteInfo = await getInfoFromVite(
|
|
62
|
+
async function enhanceViteConfig(viteConfigFromOptions, operation) {
|
|
63
|
+
const viteInfo = await getInfoFromVite(viteConfigFromOptions, operation);
|
|
64
64
|
await assertViteRoot2(viteInfo.root, viteInfo.viteConfigEnhanced, operation);
|
|
65
65
|
const vikeConfig = await (0, getVikeConfig_js_1.getVikeConfig2)(viteInfo.root, operation === 'dev', viteInfo.vikeVitePluginOptions);
|
|
66
66
|
const viteConfigEnhanced = addViteSettingsSetByVikeConfig(viteInfo.viteConfigEnhanced, vikeConfig);
|
|
@@ -76,6 +76,7 @@ function addViteSettingsSetByVikeConfig(viteConfigEnhanced, vikeConfig) {
|
|
|
76
76
|
viteConfigs.values.forEach((v) => {
|
|
77
77
|
(0, utils_js_1.assertUsage)((0, utils_js_1.isObject)(v.value), `${v.definedAt} should be an object`);
|
|
78
78
|
viteConfigEnhanced = (0, vite_1.mergeConfig)(viteConfigEnhanced ?? {}, v.value);
|
|
79
|
+
(0, utils_js_1.assertUsage)(!findVikeVitePlugin(v.value), "Using the +vite setting to add Vike's Vite plugin is forbidden");
|
|
79
80
|
});
|
|
80
81
|
return viteConfigEnhanced;
|
|
81
82
|
}
|
|
@@ -85,13 +86,14 @@ async function getViteRoot(operation) {
|
|
|
85
86
|
(0, utils_js_1.assert)(globalObject.root);
|
|
86
87
|
return globalObject.root;
|
|
87
88
|
}
|
|
88
|
-
async function getInfoFromVite(
|
|
89
|
-
const
|
|
90
|
-
const root = normalizeViteRoot(
|
|
89
|
+
async function getInfoFromVite(viteConfigFromOptions, operation) {
|
|
90
|
+
const viteConfigFromUserViteFile = await loadViteConfigFile(viteConfigFromOptions, operation);
|
|
91
|
+
const root = normalizeViteRoot(viteConfigFromUserViteFile?.root ?? viteConfigFromOptions?.root ?? process.cwd());
|
|
91
92
|
globalObject.root = root;
|
|
92
93
|
let vikeVitePluginOptions;
|
|
93
|
-
let viteConfigEnhanced =
|
|
94
|
-
|
|
94
|
+
let viteConfigEnhanced = viteConfigFromOptions;
|
|
95
|
+
// If Vike's Vite plugin is found in both viteConfigFromOptions and viteConfigFromUserViteFile then Vike will later throw an error
|
|
96
|
+
const found = findVikeVitePlugin(viteConfigFromOptions) || findVikeVitePlugin(viteConfigFromUserViteFile);
|
|
95
97
|
if (found) {
|
|
96
98
|
vikeVitePluginOptions = found.vikeVitePluginOptions;
|
|
97
99
|
}
|
|
@@ -100,20 +102,20 @@ async function getInfoFromVite(viteConfig, operation) {
|
|
|
100
102
|
// Using a dynamic import because the script calling the Vike API may not live in the same place as vite.config.js, thus vike/plugin may resolved to two different node_modules/vike directories.
|
|
101
103
|
const { plugin: vikePlugin } = await Promise.resolve().then(() => __importStar(require('../plugin/index.js')));
|
|
102
104
|
viteConfigEnhanced = {
|
|
103
|
-
...
|
|
104
|
-
plugins: [...(
|
|
105
|
+
...viteConfigFromOptions,
|
|
106
|
+
plugins: [...(viteConfigFromOptions?.plugins ?? []), vikePlugin()]
|
|
105
107
|
};
|
|
106
|
-
const res = findVikeVitePlugin(viteConfigEnhanced
|
|
108
|
+
const res = findVikeVitePlugin(viteConfigEnhanced);
|
|
107
109
|
(0, utils_js_1.assert)(res);
|
|
108
110
|
vikeVitePluginOptions = res.vikeVitePluginOptions;
|
|
109
111
|
}
|
|
110
112
|
(0, utils_js_1.assert)(vikeVitePluginOptions);
|
|
111
113
|
return { root, vikeVitePluginOptions, viteConfigEnhanced };
|
|
112
114
|
}
|
|
113
|
-
function findVikeVitePlugin(
|
|
115
|
+
function findVikeVitePlugin(viteConfig) {
|
|
114
116
|
let vikeVitePluginOptions;
|
|
115
117
|
let vikeVitePuginFound = false;
|
|
116
|
-
plugins
|
|
118
|
+
viteConfig?.plugins?.forEach((p) => {
|
|
117
119
|
if (p && '__vikeVitePluginOptions' in p) {
|
|
118
120
|
vikeVitePuginFound = true;
|
|
119
121
|
const options = p.__vikeVitePluginOptions;
|
|
@@ -126,8 +128,8 @@ function findVikeVitePlugin(plugins) {
|
|
|
126
128
|
return { vikeVitePluginOptions };
|
|
127
129
|
}
|
|
128
130
|
// Copied from https://github.com/vitejs/vite/blob/4f5845a3182fc950eb9cd76d7161698383113b18/packages/vite/src/node/config.ts#L961-L1005
|
|
129
|
-
async function loadViteConfigFile(
|
|
130
|
-
const [inlineConfig, command, defaultMode, _defaultNodeEnv, isPreview] = getResolveConfigArgs(
|
|
131
|
+
async function loadViteConfigFile(viteConfigFromOptions, operation) {
|
|
132
|
+
const [inlineConfig, command, defaultMode, _defaultNodeEnv, isPreview] = getResolveConfigArgs(viteConfigFromOptions, operation);
|
|
131
133
|
let config = inlineConfig;
|
|
132
134
|
let mode = inlineConfig.mode || defaultMode;
|
|
133
135
|
const configEnv = {
|
|
@@ -35,7 +35,7 @@ const workaroundVite6HmrRegression_js_1 = require("./plugins/workaroundVite6HmrR
|
|
|
35
35
|
const buildApp_js_1 = require("./plugins/buildApp.js");
|
|
36
36
|
// We don't call this in ./onLoad.ts to avoid a cyclic dependency with utils.ts
|
|
37
37
|
(0, getPageAssets_js_1.setResolveClientEntriesDev)(resolveClientEntriesDev_js_1.resolveClientEntriesDev);
|
|
38
|
-
// Return
|
|
38
|
+
// Return `PluginInterop` instead of `Plugin` to avoid type mismatch upon different Vite versions
|
|
39
39
|
function plugin(vikeVitePluginOptions = {}) {
|
|
40
40
|
const plugins = [
|
|
41
41
|
...(0, commonConfig_js_1.commonConfig)(vikeVitePluginOptions),
|
|
@@ -29,7 +29,7 @@ function baseUrls() {
|
|
|
29
29
|
},
|
|
30
30
|
async configResolved(config) {
|
|
31
31
|
const vikeConfig = await (0, getVikeConfig_js_1.getVikeConfig)(config);
|
|
32
|
-
const basesResolved2 =
|
|
32
|
+
const basesResolved2 = resolveBaseFromResolvedConfig(vikeConfig.global.config.baseServer ?? null, vikeConfig.global.config.baseAssets ?? null, config);
|
|
33
33
|
(0, utils_js_1.assert)(basesResolved2.baseServer === basesResolved.baseServer);
|
|
34
34
|
(0, utils_js_1.assert)(basesResolved2.baseAssets === basesResolved.baseAssets);
|
|
35
35
|
/* In dev, Vite seems buggy around setting vite.config.js#base to an absolute URL (e.g. http://localhost:8080/cdn/)
|
|
@@ -40,3 +40,8 @@ function baseUrls() {
|
|
|
40
40
|
}
|
|
41
41
|
};
|
|
42
42
|
}
|
|
43
|
+
function resolveBaseFromResolvedConfig(baseServer, baseAssets, config) {
|
|
44
|
+
let baseViteOriginal = config._baseViteOriginal;
|
|
45
|
+
(0, utils_js_1.assert)(baseViteOriginal === null || typeof baseViteOriginal == 'string');
|
|
46
|
+
return (0, resolveBase_js_1.resolveBase)(baseViteOriginal, baseServer, baseAssets);
|
|
47
|
+
}
|
|
@@ -7,7 +7,6 @@ exports.fixServerAssets = fixServerAssets;
|
|
|
7
7
|
exports.fixServerAssets_isEnabled = fixServerAssets_isEnabled;
|
|
8
8
|
exports.fixServerAssets_assertCssCodeSplit = fixServerAssets_assertCssCodeSplit;
|
|
9
9
|
exports.fixServerAssets_assertCssTarget = fixServerAssets_assertCssTarget;
|
|
10
|
-
exports.fixServerAssets_assertCssTarget_populate = fixServerAssets_assertCssTarget_populate;
|
|
11
10
|
const promises_1 = __importDefault(require("fs/promises"));
|
|
12
11
|
const fs_1 = __importDefault(require("fs"));
|
|
13
12
|
const path_1 = __importDefault(require("path"));
|
|
@@ -200,17 +199,15 @@ function fixServerAssets_assertCssCodeSplit(config) {
|
|
|
200
199
|
(0, utils_js_1.assertWarning)(config.build.cssCodeSplit, `${picocolors_1.default.cyan('build.cssCodeSplit')} shouldn't be set to ${picocolors_1.default.cyan('false')} (https://github.com/vikejs/vike/issues/1993)`, { onlyOnce: true });
|
|
201
200
|
}
|
|
202
201
|
const targets = [];
|
|
203
|
-
function fixServerAssets_assertCssTarget_populate(config) {
|
|
204
|
-
const isServerSide = (0, viteIsSSR_js_1.viteIsSSR)(config);
|
|
205
|
-
(0, utils_js_1.assert)(typeof isServerSide === 'boolean');
|
|
206
|
-
(0, utils_js_1.assert)(config.build.target !== undefined);
|
|
207
|
-
targets.push({ global: config.build.target, css: config.build.cssTarget, isServerSide });
|
|
208
|
-
}
|
|
209
202
|
async function fixServerAssets_assertCssTarget(config) {
|
|
210
203
|
if (!fixServerAssets_isEnabled())
|
|
211
204
|
return;
|
|
212
205
|
if (!(await (0, getVikeConfig_js_1.isV1Design)(config)))
|
|
213
206
|
return;
|
|
207
|
+
const isServerSide = (0, viteIsSSR_js_1.viteIsSSR)(config);
|
|
208
|
+
(0, utils_js_1.assert)(typeof isServerSide === 'boolean');
|
|
209
|
+
(0, utils_js_1.assert)(config.build.target !== undefined);
|
|
210
|
+
targets.push({ global: config.build.target, css: config.build.cssTarget, isServerSide });
|
|
214
211
|
const targetsServer = targets.filter((t) => t.isServerSide);
|
|
215
212
|
const targetsClient = targets.filter((t) => !t.isServerSide);
|
|
216
213
|
targetsClient.forEach((targetClient) => {
|
|
@@ -218,9 +215,10 @@ async function fixServerAssets_assertCssTarget(config) {
|
|
|
218
215
|
targetsServer.forEach((targetServer) => {
|
|
219
216
|
const targetCssResolvedServer = resolveCssTarget(targetServer);
|
|
220
217
|
(0, utils_js_1.assertWarning)((0, utils_js_1.isEqualStringList)(targetCssResolvedClient, targetCssResolvedServer), [
|
|
221
|
-
'The CSS browser target should be the same for both client
|
|
222
|
-
`Client
|
|
223
|
-
`Server
|
|
218
|
+
'The CSS browser target should be the same for both client and server, but we got:',
|
|
219
|
+
`Client: ${picocolors_1.default.cyan(JSON.stringify(targetCssResolvedClient))}`,
|
|
220
|
+
`Server: ${picocolors_1.default.cyan(JSON.stringify(targetCssResolvedServer))}`,
|
|
221
|
+
`Different targets lead to CSS duplication, see ${picocolors_1.default.underline('https://github.com/vikejs/vike/issues/1815#issuecomment-2507002979')} for more information.`
|
|
224
222
|
].join('\n'), {
|
|
225
223
|
showStackTrace: true,
|
|
226
224
|
onlyOnce: 'different-css-target'
|
|
@@ -54,7 +54,6 @@ function buildConfig() {
|
|
|
54
54
|
config.build.ssrEmitAssets = true;
|
|
55
55
|
// Required if `ssrEmitAssets: true`, see https://github.com/vitejs/vite/pull/11430#issuecomment-1454800934
|
|
56
56
|
config.build.cssMinify = 'esbuild';
|
|
57
|
-
(0, fixServerAssets_js_1.fixServerAssets_assertCssTarget_populate)(config);
|
|
58
57
|
(0, fixServerAssets_js_1.fixServerAssets_assertCssCodeSplit)(config);
|
|
59
58
|
}
|
|
60
59
|
}
|
|
@@ -35,7 +35,10 @@ function commonConfig(vikeVitePluginOptions) {
|
|
|
35
35
|
_isDev: isDev,
|
|
36
36
|
_root: root,
|
|
37
37
|
_vikeVitePluginOptions: vikeVitePluginOptions,
|
|
38
|
-
vike: {
|
|
38
|
+
vike: {
|
|
39
|
+
pages: vikeConfig.pages,
|
|
40
|
+
config: vikeConfig.global.config
|
|
41
|
+
},
|
|
39
42
|
// TODO/v1-release: remove https://github.com/vikejs/vike/issues/2122
|
|
40
43
|
configVikePromise: Promise.resolve({
|
|
41
44
|
prerender: (0, context_js_2.isPrerenderEnabled)(vikeConfig)
|
|
@@ -15,8 +15,8 @@ const getVikeConfig_js_1 = require("./v1-design/getVikeConfig.js");
|
|
|
15
15
|
const picocolors_1 = __importDefault(require("@brillout/picocolors"));
|
|
16
16
|
const loggerNotProd_js_1 = require("../../shared/loggerNotProd.js");
|
|
17
17
|
const getFilePath_js_1 = require("../../shared/getFilePath.js");
|
|
18
|
-
const getPlusFilesAll_js_1 = require("./v1-design/getVikeConfig/getPlusFilesAll.js");
|
|
19
18
|
const globalContext_js_1 = require("../../../runtime/globalContext.js");
|
|
19
|
+
const crawlPlusFiles_js_1 = require("./v1-design/getVikeConfig/crawlPlusFiles.js");
|
|
20
20
|
function importUserCode() {
|
|
21
21
|
let config;
|
|
22
22
|
let vikeConfig;
|
|
@@ -73,50 +73,55 @@ function handleFileAddRemove(server, config) {
|
|
|
73
73
|
return;
|
|
74
74
|
function listener(file, isRemove) {
|
|
75
75
|
file = (0, vite_1.normalizePath)(file);
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
const virtualModules = getVirtualModules(server);
|
|
79
|
-
virtualModules.forEach((mod) => {
|
|
80
|
-
server.moduleGraph.invalidateModule(mod);
|
|
81
|
-
});
|
|
76
|
+
if ((0, crawlPlusFiles_js_1.isPlusFile)(file) || isVikeConfigDependency(file, server.moduleGraph)?.modifiesVikeVirtualFiles) {
|
|
77
|
+
invalidateVikeVirtualFiles(server);
|
|
82
78
|
reloadConfig(file, config, isRemove ? 'removed' : 'created');
|
|
83
79
|
}
|
|
84
80
|
}
|
|
85
81
|
}
|
|
82
|
+
function invalidateVikeVirtualFiles(server) {
|
|
83
|
+
const vikeVirtualFiles = getVikeVirtualFiles(server);
|
|
84
|
+
vikeVirtualFiles.forEach((mod) => {
|
|
85
|
+
server.moduleGraph.invalidateModule(mod);
|
|
86
|
+
});
|
|
87
|
+
}
|
|
86
88
|
function handleHotUpdate(ctx, config) {
|
|
87
89
|
const { file, server } = ctx;
|
|
88
|
-
const isVikeConfig =
|
|
89
|
-
const isViteModule = ctx.modules.length > 0;
|
|
90
|
-
/* Should we show this?
|
|
91
|
-
// - Can be useful for server files that aren't processed by Vite.
|
|
92
|
-
// - Can be annoying for files that obviously aren't processed by Vite.
|
|
93
|
-
if (!isVikeConfig && !isViteModule) {
|
|
94
|
-
logViteAny(
|
|
95
|
-
`${msg} — ${pc.cyan('no HMR')}, see https://vike.dev/on-demand-compiler`,
|
|
96
|
-
'info',
|
|
97
|
-
null,
|
|
98
|
-
true
|
|
99
|
-
)
|
|
100
|
-
return
|
|
101
|
-
}
|
|
102
|
-
//*/
|
|
103
|
-
// It can hide an error it shouldn't hide (because the error isn't shown again), but it's ok since users can reload the page and the error will be shown again (Vite transpilation errors are shown again upon a page reload).
|
|
104
|
-
if (!isVikeConfig && isViteModule) {
|
|
105
|
-
return;
|
|
106
|
-
}
|
|
90
|
+
const isVikeConfig = isVikeConfigDependency(ctx.file, ctx.server.moduleGraph);
|
|
107
91
|
if (isVikeConfig) {
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
92
|
+
if (isVikeConfig.modifiesVikeVirtualFiles) {
|
|
93
|
+
/* Tailwind breaks this assertion, see https://github.com/vikejs/vike/discussions/1330#discussioncomment-7787238
|
|
94
|
+
const isViteModule = ctx.modules.length > 0
|
|
95
|
+
assert(!isViteModule)
|
|
96
|
+
*/
|
|
97
|
+
// Ensure server.ssrLoadModule() loads fresh Vike virtual files (`reloadConfig()` > `updateUserFiles()` > `server.ssrLoadModule()`)
|
|
98
|
+
invalidateVikeVirtualFiles(server);
|
|
99
|
+
reloadConfig(file, config, 'modified');
|
|
100
|
+
// Triggers a full page reload
|
|
101
|
+
const vikeVirtualFiles = getVikeVirtualFiles(server);
|
|
102
|
+
return vikeVirtualFiles;
|
|
103
|
+
}
|
|
104
|
+
else {
|
|
105
|
+
// Ensure we invalidate `file` *before* server.ssrLoadModule() in updateUserFiles()
|
|
106
|
+
// Vite already invalidates it, but possibly *after* handleHotUpdate() and thus after server.ssrLoadModule()
|
|
107
|
+
ctx.modules.forEach((mod) => server.moduleGraph.invalidateModule(mod));
|
|
108
|
+
(0, globalContext_js_1.updateUserFiles)();
|
|
109
|
+
}
|
|
114
110
|
}
|
|
115
111
|
}
|
|
116
|
-
function
|
|
112
|
+
function isVikeConfigDependency(filePathAbsoluteFilesystem, moduleGraph) {
|
|
113
|
+
// Check config-only files, for example all pages/+config.js dependencies. (There aren't part of Vite's module graph.)
|
|
117
114
|
(0, utils_js_1.assertPosixPath)(filePathAbsoluteFilesystem);
|
|
118
115
|
getVikeConfig_js_1.vikeConfigDependencies.forEach((f) => (0, utils_js_1.assertPosixPath)(f));
|
|
119
|
-
|
|
116
|
+
if (getVikeConfig_js_1.vikeConfigDependencies.has(filePathAbsoluteFilesystem))
|
|
117
|
+
return { modifiesVikeVirtualFiles: true };
|
|
118
|
+
// Check using Vite's module graph, for example all +htmlAttributes dependencies.
|
|
119
|
+
// Alternatively, simply call updateUserFiles() on every handleHotUpdate() call.
|
|
120
|
+
const importers = getImporters(filePathAbsoluteFilesystem, moduleGraph);
|
|
121
|
+
const isPlusValueFileDependency = Array.from(importers).some((importer) => importer.file && (0, crawlPlusFiles_js_1.isPlusFile)(importer.file));
|
|
122
|
+
if (isPlusValueFileDependency)
|
|
123
|
+
return { modifiesVikeVirtualFiles: false };
|
|
124
|
+
return null;
|
|
120
125
|
}
|
|
121
126
|
function reloadConfig(filePath, config, op) {
|
|
122
127
|
{
|
|
@@ -127,16 +132,45 @@ function reloadConfig(filePath, config, op) {
|
|
|
127
132
|
(0, getVikeConfig_js_1.reloadVikeConfig)(config);
|
|
128
133
|
(0, globalContext_js_1.updateUserFiles)();
|
|
129
134
|
}
|
|
130
|
-
function
|
|
131
|
-
const
|
|
135
|
+
function getVikeVirtualFiles(server) {
|
|
136
|
+
const vikeVirtualFiles = Array.from(server.moduleGraph.urlToModuleMap.keys())
|
|
132
137
|
.filter((url) => (0, virtualFilePageConfigValuesAll_js_1.isVirtualFileIdPageConfigValuesAll)(url) || (0, virtualFileImportUserCode_js_1.isVirtualFileIdImportUserCode)(url))
|
|
133
138
|
.map((url) => {
|
|
134
139
|
const mod = server.moduleGraph.urlToModuleMap.get(url);
|
|
135
140
|
(0, utils_js_1.assert)(mod);
|
|
136
141
|
return mod;
|
|
137
142
|
});
|
|
138
|
-
return
|
|
143
|
+
return vikeVirtualFiles;
|
|
144
|
+
}
|
|
145
|
+
// Get all transitive importers (including the module itself)
|
|
146
|
+
function getImporters(file, moduleGraph) {
|
|
147
|
+
const importers = new Set();
|
|
148
|
+
const mods = moduleGraph.getModulesByFile(file);
|
|
149
|
+
if (!mods)
|
|
150
|
+
return importers;
|
|
151
|
+
for (const mod of mods) {
|
|
152
|
+
getModuleImporters(mod).forEach((importer) => {
|
|
153
|
+
if (importer)
|
|
154
|
+
importers.add(importer);
|
|
155
|
+
});
|
|
156
|
+
}
|
|
157
|
+
return importers;
|
|
139
158
|
}
|
|
140
|
-
function
|
|
141
|
-
|
|
159
|
+
function getModuleImporters(mod, seen = new Set()) {
|
|
160
|
+
if (seen.has(mod))
|
|
161
|
+
return new Set();
|
|
162
|
+
seen.add(mod);
|
|
163
|
+
const importers = new Set();
|
|
164
|
+
if (mod.id)
|
|
165
|
+
importers.add(mod);
|
|
166
|
+
// Traverse through the importers (modules that import this module)
|
|
167
|
+
for (const importer of mod.importers) {
|
|
168
|
+
if (importer.id)
|
|
169
|
+
importers.add(importer);
|
|
170
|
+
getModuleImporters(importer, seen).forEach((importerTransitive) => {
|
|
171
|
+
if (importerTransitive)
|
|
172
|
+
importers.add(importerTransitive);
|
|
173
|
+
});
|
|
174
|
+
}
|
|
175
|
+
return importers;
|
|
142
176
|
}
|
package/dist/cjs/node/plugin/plugins/importUserCode/v1-design/getVikeConfig/crawlPlusFiles.js
CHANGED
|
@@ -4,6 +4,8 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
6
|
exports.crawlPlusFiles = crawlPlusFiles;
|
|
7
|
+
exports.isPlusFile = isPlusFile;
|
|
8
|
+
exports.getPlusFileValueConfigName = getPlusFileValueConfigName;
|
|
7
9
|
const utils_js_1 = require("../../../../utils.js");
|
|
8
10
|
const path_1 = __importDefault(require("path"));
|
|
9
11
|
const fast_glob_1 = __importDefault(require("fast-glob"));
|
|
@@ -12,6 +14,7 @@ const util_1 = require("util");
|
|
|
12
14
|
const transpileAndExecuteFile_js_1 = require("./transpileAndExecuteFile.js");
|
|
13
15
|
const getEnvVarObject_js_1 = require("../../../../shared/getEnvVarObject.js");
|
|
14
16
|
const execA = (0, util_1.promisify)(child_process_1.exec);
|
|
17
|
+
const debug = (0, utils_js_1.createDebugger)('vike:crawl');
|
|
15
18
|
(0, utils_js_1.assertIsNotProductionRuntime)();
|
|
16
19
|
(0, utils_js_1.assertIsSingleModuleInstance)('crawlPlusFiles.ts');
|
|
17
20
|
let gitIsNotUsable = false;
|
|
@@ -35,17 +38,16 @@ async function crawlPlusFiles(userRootDir, outDirAbsoluteFilesystem) {
|
|
|
35
38
|
//
|
|
36
39
|
!outDirRelativeFromUserRootDir.startsWith('../')));
|
|
37
40
|
// Crawl
|
|
38
|
-
|
|
39
|
-
const
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
files
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
}
|
|
41
|
+
const filesGit = !isGitCrawlDisabled() && (await gitLsFiles(userRootDir, outDirRelativeFromUserRootDir));
|
|
42
|
+
const filesGitNothingFound = !filesGit || filesGit.length === 0;
|
|
43
|
+
const filesGlob = (filesGitNothingFound || debug.isActivated) && (await fastGlob(userRootDir, outDirRelativeFromUserRootDir));
|
|
44
|
+
let files = !filesGitNothingFound
|
|
45
|
+
? filesGit
|
|
46
|
+
: // Fallback to fast-glob for users that dynamically generate plus files. (Assuming that no plus file is found because of the user's .gitignore list.)
|
|
47
|
+
filesGlob;
|
|
48
|
+
(0, utils_js_1.assert)(files);
|
|
49
|
+
if (debug.isActivated)
|
|
50
|
+
(0, utils_js_1.assert)((0, utils_js_1.deepEqual)(filesGlob, filesGit), "Git and glob results aren't matching.");
|
|
49
51
|
// Filter build files
|
|
50
52
|
files = files.filter((filePath) => !(0, transpileAndExecuteFile_js_1.isTemporaryBuildFile)(filePath));
|
|
51
53
|
// Normalize
|
|
@@ -54,6 +56,7 @@ async function crawlPlusFiles(userRootDir, outDirAbsoluteFilesystem) {
|
|
|
54
56
|
(0, utils_js_1.assertPosixPath)(filePath);
|
|
55
57
|
(0, utils_js_1.assert)(!filePath.startsWith(userRootDir));
|
|
56
58
|
const filePathAbsoluteUserRootDir = path_1.default.posix.join('/', filePath);
|
|
59
|
+
(0, utils_js_1.assert)(isPlusFile(filePathAbsoluteUserRootDir));
|
|
57
60
|
return { filePathAbsoluteUserRootDir };
|
|
58
61
|
});
|
|
59
62
|
return plusFiles;
|
|
@@ -74,7 +77,7 @@ async function gitLsFiles(userRootDir, outDirRelativeFromUserRootDir) {
|
|
|
74
77
|
preserveUTF8,
|
|
75
78
|
'ls-files',
|
|
76
79
|
// Performance gain seems negligible: https://github.com/vikejs/vike/pull/1688#issuecomment-2166206648
|
|
77
|
-
...utils_js_1.scriptFileExtensionList.map((ext) => `"**/+*.${ext}"`),
|
|
80
|
+
...utils_js_1.scriptFileExtensionList.map((ext) => `"**/+*.${ext}" "+*.${ext}"`),
|
|
78
81
|
// Performance gain is non-negligible.
|
|
79
82
|
// - https://github.com/vikejs/vike/pull/1688#issuecomment-2166206648
|
|
80
83
|
// - When node_modules/ is untracked the performance gain could be significant?
|
|
@@ -101,6 +104,12 @@ async function gitLsFiles(userRootDir, outDirRelativeFromUserRootDir) {
|
|
|
101
104
|
}
|
|
102
105
|
throw err;
|
|
103
106
|
}
|
|
107
|
+
if (debug.isActivated) {
|
|
108
|
+
debug('[git] userRootDir:', userRootDir);
|
|
109
|
+
debug('[git] cmd:', cmd);
|
|
110
|
+
debug('[git] result:', filesAll);
|
|
111
|
+
debug('[git] filesDeleted:', filesDeleted);
|
|
112
|
+
}
|
|
104
113
|
const files = [];
|
|
105
114
|
for (const filePath of filesAll) {
|
|
106
115
|
// + file?
|
|
@@ -121,14 +130,21 @@ async function gitLsFiles(userRootDir, outDirRelativeFromUserRootDir) {
|
|
|
121
130
|
}
|
|
122
131
|
// Same as gitLsFiles() but using fast-glob
|
|
123
132
|
async function fastGlob(userRootDir, outDirRelativeFromUserRootDir) {
|
|
124
|
-
const
|
|
133
|
+
const pattern = `**/+*.${utils_js_1.scriptFileExtensions}`;
|
|
134
|
+
const options = {
|
|
125
135
|
ignore: getIgnoreAsPatterns(outDirRelativeFromUserRootDir),
|
|
126
136
|
cwd: userRootDir,
|
|
127
137
|
dot: false
|
|
128
|
-
}
|
|
138
|
+
};
|
|
139
|
+
const files = await (0, fast_glob_1.default)(pattern, options);
|
|
129
140
|
// Make build deterministic, in order to get a stable generated hash for dist/client/assets/entries/entry-client-routing.${hash}.js
|
|
130
141
|
// https://github.com/vikejs/vike/pull/1750
|
|
131
142
|
files.sort();
|
|
143
|
+
if (debug.isActivated) {
|
|
144
|
+
debug('[glob] pattern:', pattern);
|
|
145
|
+
debug('[glob] options:', options);
|
|
146
|
+
debug('[glob] result:', files);
|
|
147
|
+
}
|
|
132
148
|
return files;
|
|
133
149
|
}
|
|
134
150
|
// Same as getIgnoreAsFilterFn() but as glob pattern
|
|
@@ -215,3 +231,37 @@ function isGitCrawlDisabled() {
|
|
|
215
231
|
const crawSettings = (0, getEnvVarObject_js_1.getEnvVarObject)('VIKE_CRAWL');
|
|
216
232
|
return crawSettings?.git === false;
|
|
217
233
|
}
|
|
234
|
+
function isPlusFile(filePath) {
|
|
235
|
+
(0, utils_js_1.assertPosixPath)(filePath);
|
|
236
|
+
if ((0, transpileAndExecuteFile_js_1.isTemporaryBuildFile)(filePath))
|
|
237
|
+
return false;
|
|
238
|
+
const fileName = filePath.split('/').pop();
|
|
239
|
+
return fileName.startsWith('+');
|
|
240
|
+
}
|
|
241
|
+
function getPlusFileValueConfigName(filePath) {
|
|
242
|
+
if (!isPlusFile(filePath))
|
|
243
|
+
return null;
|
|
244
|
+
const fileName = path_1.default.posix.basename(filePath);
|
|
245
|
+
// assertNoUnexpectedPlusSign(filePath, fileName)
|
|
246
|
+
const basename = fileName.split('.')[0];
|
|
247
|
+
(0, utils_js_1.assert)(basename.startsWith('+'));
|
|
248
|
+
const configName = basename.slice(1);
|
|
249
|
+
(0, utils_js_1.assertUsage)(configName !== '', `${filePath} Invalid filename ${fileName}`);
|
|
250
|
+
return configName;
|
|
251
|
+
}
|
|
252
|
+
/* https://github.com/vikejs/vike/issues/1407
|
|
253
|
+
function assertNoUnexpectedPlusSign(filePath: string, fileName: string) {
|
|
254
|
+
const dirs = path.posix.dirname(filePath).split('/')
|
|
255
|
+
dirs.forEach((dir, i) => {
|
|
256
|
+
const dirPath = dirs.slice(0, i + 1).join('/')
|
|
257
|
+
assertUsage(
|
|
258
|
+
!dir.includes('+'),
|
|
259
|
+
`Character '+' is a reserved character: remove '+' from the directory name ${dirPath}/`
|
|
260
|
+
)
|
|
261
|
+
})
|
|
262
|
+
assertUsage(
|
|
263
|
+
!fileName.slice(1).includes('+'),
|
|
264
|
+
`Character '+' is only allowed at the beginning of filenames: make sure ${filePath} doesn't contain any '+' in its filename other than its first letter`
|
|
265
|
+
)
|
|
266
|
+
}
|
|
267
|
+
*/
|
package/dist/cjs/node/plugin/plugins/importUserCode/v1-design/getVikeConfig/filesystemRouting.js
CHANGED
|
@@ -8,7 +8,6 @@ exports.getFilesystemRouteDefinedBy = getFilesystemRouteDefinedBy;
|
|
|
8
8
|
exports.isInherited = isInherited;
|
|
9
9
|
exports.getLocationId = getLocationId;
|
|
10
10
|
exports.sortAfterInheritanceOrder = sortAfterInheritanceOrder;
|
|
11
|
-
exports.isGlobalLocation = isGlobalLocation;
|
|
12
11
|
exports.applyFilesystemRoutingRootEffect = applyFilesystemRoutingRootEffect;
|
|
13
12
|
exports.getLogicalPath = getLogicalPath;
|
|
14
13
|
const picocolors_1 = __importDefault(require("@brillout/picocolors"));
|
|
@@ -45,10 +44,6 @@ function getLogicalPath(locationId, ignoredDirs, removeParenthesesDirs) {
|
|
|
45
44
|
assertIsPath(logicalPath);
|
|
46
45
|
return logicalPath;
|
|
47
46
|
}
|
|
48
|
-
/** Whether configs defined in `locationId` apply in every `locationIds` */
|
|
49
|
-
function isGlobalLocation(locationId, locationIds) {
|
|
50
|
-
return locationIds.every((locId) => isInherited(locationId, locId) || locationIsRendererDir(locId));
|
|
51
|
-
}
|
|
52
47
|
function sortAfterInheritanceOrder(locationId1, locationId2, locationIdPage) {
|
|
53
48
|
assertLocationId(locationId1);
|
|
54
49
|
assertLocationId(locationId2);
|
package/dist/cjs/node/plugin/plugins/importUserCode/v1-design/getVikeConfig/getPlusFilesAll.js
CHANGED
|
@@ -1,27 +1,21 @@
|
|
|
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.getPlusFilesAll = getPlusFilesAll;
|
|
7
|
-
exports.getPlusFileValueConfigName = getPlusFileValueConfigName;
|
|
8
4
|
const utils_js_1 = require("../../../../utils.js");
|
|
9
5
|
const configDefinitionsBuiltIn_js_1 = require("./configDefinitionsBuiltIn.js");
|
|
10
6
|
const filesystemRouting_js_1 = require("./filesystemRouting.js");
|
|
11
|
-
const transpileAndExecuteFile_js_1 = require("./transpileAndExecuteFile.js");
|
|
12
7
|
const crawlPlusFiles_js_1 = require("./crawlPlusFiles.js");
|
|
13
8
|
const getConfigFileExport_js_1 = require("./getConfigFileExport.js");
|
|
14
9
|
const loadFileAtConfigTime_js_1 = require("./loadFileAtConfigTime.js");
|
|
15
10
|
const resolvePointerImport_js_1 = require("./resolvePointerImport.js");
|
|
16
11
|
const getFilePath_js_1 = require("../../../../shared/getFilePath.js");
|
|
17
12
|
const assertExtensions_js_1 = require("./assertExtensions.js");
|
|
18
|
-
const node_path_1 = __importDefault(require("node:path"));
|
|
19
13
|
async function getPlusFilesAll(userRootDir, esbuildCache) {
|
|
20
14
|
const plusFiles = await findPlusFiles(userRootDir, null);
|
|
21
15
|
const configFiles = [];
|
|
22
16
|
const valueFiles = [];
|
|
23
17
|
plusFiles.forEach((f) => {
|
|
24
|
-
if (getPlusFileValueConfigName(f.filePathAbsoluteFilesystem) === 'config') {
|
|
18
|
+
if ((0, crawlPlusFiles_js_1.getPlusFileValueConfigName)(f.filePathAbsoluteFilesystem) === 'config') {
|
|
25
19
|
configFiles.push(f);
|
|
26
20
|
}
|
|
27
21
|
else {
|
|
@@ -66,7 +60,7 @@ async function getPlusFilesAll(userRootDir, esbuildCache) {
|
|
|
66
60
|
...valueFiles.map(async (filePath) => {
|
|
67
61
|
const { filePathAbsoluteUserRootDir } = filePath;
|
|
68
62
|
(0, utils_js_1.assert)(filePathAbsoluteUserRootDir);
|
|
69
|
-
const configName = getPlusFileValueConfigName(filePathAbsoluteUserRootDir);
|
|
63
|
+
const configName = (0, crawlPlusFiles_js_1.getPlusFileValueConfigName)(filePathAbsoluteUserRootDir);
|
|
70
64
|
(0, utils_js_1.assert)(configName);
|
|
71
65
|
const locationId = (0, filesystemRouting_js_1.getLocationId)(filePathAbsoluteUserRootDir);
|
|
72
66
|
const plusFile = {
|
|
@@ -125,35 +119,3 @@ async function findPlusFiles(userRootDir, outDirRoot) {
|
|
|
125
119
|
const plusFiles = files.map(({ filePathAbsoluteUserRootDir }) => (0, getFilePath_js_1.getFilePathResolved)({ filePathAbsoluteUserRootDir, userRootDir }));
|
|
126
120
|
return plusFiles;
|
|
127
121
|
}
|
|
128
|
-
function getPlusFileValueConfigName(filePath) {
|
|
129
|
-
(0, utils_js_1.assertPosixPath)(filePath);
|
|
130
|
-
if ((0, transpileAndExecuteFile_js_1.isTemporaryBuildFile)(filePath))
|
|
131
|
-
return null;
|
|
132
|
-
const fileName = node_path_1.default.posix.basename(filePath);
|
|
133
|
-
// assertNoUnexpectedPlusSign(filePath, fileName)
|
|
134
|
-
const basename = fileName.split('.')[0];
|
|
135
|
-
if (!basename.startsWith('+')) {
|
|
136
|
-
return null;
|
|
137
|
-
}
|
|
138
|
-
else {
|
|
139
|
-
const configName = basename.slice(1);
|
|
140
|
-
(0, utils_js_1.assertUsage)(configName !== '', `${filePath} Invalid filename ${fileName}`);
|
|
141
|
-
return configName;
|
|
142
|
-
}
|
|
143
|
-
}
|
|
144
|
-
/* https://github.com/vikejs/vike/issues/1407
|
|
145
|
-
function assertNoUnexpectedPlusSign(filePath: string, fileName: string) {
|
|
146
|
-
const dirs = path.posix.dirname(filePath).split('/')
|
|
147
|
-
dirs.forEach((dir, i) => {
|
|
148
|
-
const dirPath = dirs.slice(0, i + 1).join('/')
|
|
149
|
-
assertUsage(
|
|
150
|
-
!dir.includes('+'),
|
|
151
|
-
`Character '+' is a reserved character: remove '+' from the directory name ${dirPath}/`
|
|
152
|
-
)
|
|
153
|
-
})
|
|
154
|
-
assertUsage(
|
|
155
|
-
!fileName.slice(1).includes('+'),
|
|
156
|
-
`Character '+' is only allowed at the beginning of filenames: make sure ${filePath} doesn't contain any '+' in its filename other than its first letter`
|
|
157
|
-
)
|
|
158
|
-
}
|
|
159
|
-
*/
|
package/dist/cjs/node/plugin/plugins/importUserCode/v1-design/getVikeConfig/loadFileAtConfigTime.js
CHANGED
|
@@ -56,7 +56,7 @@ async function loadValueFile(interfaceValueFile, configDefinitions, userRootDir,
|
|
|
56
56
|
async function loadConfigFile(configFilePath, userRootDir, visited, isExtensionConfig, esbuildCache) {
|
|
57
57
|
const { filePathAbsoluteFilesystem } = configFilePath;
|
|
58
58
|
assertNoInfiniteLoop(visited, filePathAbsoluteFilesystem);
|
|
59
|
-
const { fileExports } = await (0, transpileAndExecuteFile_js_1.transpileAndExecuteFile)(configFilePath, userRootDir, isExtensionConfig
|
|
59
|
+
const { fileExports } = await (0, transpileAndExecuteFile_js_1.transpileAndExecuteFile)(configFilePath, userRootDir, isExtensionConfig, esbuildCache);
|
|
60
60
|
const { extendsConfigs, extendsFilePaths } = await loadExtendsConfigs(fileExports, configFilePath, userRootDir, [...visited, filePathAbsoluteFilesystem], esbuildCache);
|
|
61
61
|
const configFile = {
|
|
62
62
|
fileExports,
|
|
@@ -26,8 +26,9 @@ const debug = (0, utils_js_1.createDebugger)('vike:pointer-imports');
|
|
|
26
26
|
const debugEsbuildResolve = (0, utils_js_1.createDebugger)('vike:esbuild-resolve');
|
|
27
27
|
if (debugEsbuildResolve.isActivated)
|
|
28
28
|
debugEsbuildResolve('esbuild version', esbuild_1.version);
|
|
29
|
-
async function transpileAndExecuteFile(filePath, userRootDir,
|
|
29
|
+
async function transpileAndExecuteFile(filePath, userRootDir, isExtensionConfig, esbuildCache) {
|
|
30
30
|
const { filePathAbsoluteFilesystem, filePathToShowToUserResolved } = filePath;
|
|
31
|
+
(0, utils_js_1.assert)(filePathAbsoluteFilesystem);
|
|
31
32
|
const fileExtension = getFileExtension(filePathAbsoluteFilesystem);
|
|
32
33
|
if (esbuildCache[filePathAbsoluteFilesystem]) {
|
|
33
34
|
return await esbuildCache[filePathAbsoluteFilesystem];
|
|
@@ -40,12 +41,12 @@ async function transpileAndExecuteFile(filePath, userRootDir, isConfigFile, esbu
|
|
|
40
41
|
(0, utils_js_1.assertWarning)(false, `${picocolors_1.default.cyan('.h.js')} files are deprecated: simply renaming ${filePathToShowToUserResolved} to ${removeHeaderFileExtension(filePathToShowToUserResolved)} is usually enough, although you may occasionally need to use ${picocolors_1.default.cyan("with { type: 'pointer' }")} as explained at https://vike.dev/config#pointer-imports`, { onlyOnce: true });
|
|
41
42
|
}
|
|
42
43
|
let fileExports;
|
|
43
|
-
if (
|
|
44
|
+
if (isExtensionConfig && !isHeader && fileExtension.endsWith('js')) {
|
|
44
45
|
// This doesn't track dependencies => we should never use this for user land configs
|
|
45
46
|
fileExports = await executeFile(filePathAbsoluteFilesystem, filePath);
|
|
46
47
|
}
|
|
47
48
|
else {
|
|
48
|
-
const transformImports =
|
|
49
|
+
const transformImports = isHeader ? 'all' : true;
|
|
49
50
|
const code = await transpileFile(filePath, transformImports, userRootDir);
|
|
50
51
|
fileExports = await executeTranspiledFile(filePath, code);
|
|
51
52
|
}
|
|
@@ -54,6 +55,7 @@ async function transpileAndExecuteFile(filePath, userRootDir, isConfigFile, esbu
|
|
|
54
55
|
}
|
|
55
56
|
async function transpileFile(filePath, transformImports, userRootDir) {
|
|
56
57
|
const { filePathAbsoluteFilesystem, filePathToShowToUserResolved } = filePath;
|
|
58
|
+
(0, utils_js_1.assert)(filePathAbsoluteFilesystem);
|
|
57
59
|
(0, utils_js_1.assertPosixPath)(filePathAbsoluteFilesystem);
|
|
58
60
|
getVikeConfig_js_1.vikeConfigDependencies.add(filePathAbsoluteFilesystem);
|
|
59
61
|
if (debug.isActivated)
|
|
@@ -338,6 +340,7 @@ function isTemporaryBuildFile(filePath) {
|
|
|
338
340
|
const fileName = path_1.default.posix.basename(filePath);
|
|
339
341
|
return /\.build-[a-z0-9]{12}\.mjs$/.test(fileName);
|
|
340
342
|
}
|
|
343
|
+
// TODO/next-major: remove
|
|
341
344
|
function isHeaderFile(filePath) {
|
|
342
345
|
(0, utils_js_1.assertPosixPath)(filePath);
|
|
343
346
|
const fileExtensions = getFileExtensions(filePath);
|