vike 0.4.222 → 0.4.223-commit-6f064ad
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/client/shared/getPageContextProxyForUser.js +1 -1
- package/dist/cjs/node/api/prepareViteApiCall.js +1 -1
- package/dist/cjs/node/plugin/index.js +6 -4
- package/dist/cjs/node/plugin/plugins/baseUrls.js +9 -2
- package/dist/cjs/node/plugin/plugins/buildApp.js +14 -7
- package/dist/cjs/node/plugin/plugins/buildConfig/fixServerAssets.js +49 -19
- package/dist/cjs/node/plugin/plugins/buildConfig.js +6 -1
- package/dist/cjs/node/plugin/plugins/commonConfig.js +17 -1
- package/dist/cjs/node/plugin/plugins/devConfig/determineOptimizeDeps.js +1 -1
- package/dist/cjs/node/plugin/plugins/envVars.js +2 -18
- package/dist/cjs/node/plugin/plugins/extractAssetsPlugin.js +2 -2
- package/dist/cjs/node/plugin/plugins/extractExportNamesPlugin.js +1 -1
- package/dist/cjs/node/plugin/plugins/importUserCode/v1-design/getVikeConfig/assertExtensions.js +4 -4
- package/dist/cjs/node/plugin/plugins/importUserCode/v1-design/getVikeConfig/configDefinitionsBuiltIn.js +6 -1
- package/dist/cjs/node/plugin/plugins/importUserCode/v1-design/getVikeConfig/crawlPlusFiles.js +11 -10
- package/dist/cjs/node/plugin/plugins/importUserCode/v1-design/getVikeConfig/transpileAndExecuteFile.js +8 -5
- package/dist/cjs/node/plugin/plugins/importUserCode/v1-design/getVikeConfig.js +36 -71
- package/dist/cjs/node/plugin/shared/findPageFiles.js +3 -3
- package/dist/cjs/node/plugin/shared/getHttpRequestAsyncStore.js +1 -1
- package/dist/cjs/node/plugin/shared/viteIsSSR.js +19 -10
- package/dist/cjs/node/prerender/runPrerender.js +3 -1
- package/dist/cjs/node/runtime/globalContext.js +19 -8
- package/dist/cjs/node/runtime/renderPage/createHttpResponse/assertNoInfiniteHttpRedirect.js +1 -1
- package/dist/cjs/node/runtime/renderPage/createHttpResponse.js +24 -0
- package/dist/cjs/node/runtime/renderPage/getPageAssets.js +1 -1
- package/dist/cjs/node/runtime/renderPage/handlePageContextRequestUrl.js +1 -1
- package/dist/cjs/node/runtime/renderPage/isNewError.js +1 -1
- package/dist/cjs/node/runtime/renderPage/isVikeConfigInvalid.js +10 -0
- package/dist/cjs/node/runtime/renderPage/loadUserFilesServerSide.js +1 -1
- package/dist/cjs/node/runtime/renderPage/logErrorHint.js +7 -1
- package/dist/cjs/node/runtime/renderPage/renderPageAlreadyRouted.js +2 -4
- package/dist/cjs/node/runtime/renderPage.js +63 -49
- package/dist/cjs/node/runtime/universal-middleware.js +14 -0
- package/dist/cjs/node/shared/resolveBase.js +0 -13
- package/dist/cjs/shared/getPageConfigsRuntime.js +2 -8
- package/dist/cjs/shared/getPageContextRequestUrl.js +1 -1
- package/dist/cjs/shared/getPageContextUrlComputed.js +12 -9
- package/dist/cjs/shared/hooks/getHook.js +1 -1
- package/dist/cjs/shared/page-configs/getPageConfigUserFriendly.js +44 -12
- package/dist/cjs/shared/page-configs/serialize/parsePageConfigs.js +2 -8
- package/dist/cjs/shared/page-configs/serialize/serializeConfigValues.js +16 -6
- package/dist/cjs/shared/route/loadPageRoutes.js +1 -1
- package/dist/cjs/utils/PROJECT_VERSION.js +1 -1
- package/dist/cjs/utils/assert.js +1 -1
- package/dist/cjs/utils/assertSetup.js +1 -1
- package/dist/cjs/utils/assertSingleInstance.js +2 -2
- package/dist/cjs/utils/findFile.js +1 -1
- package/dist/cjs/utils/getGlobalObject.js +2 -6
- package/dist/cjs/utils/parseUrl-extras.js +2 -2
- package/dist/cjs/utils/parseUrl.js +5 -5
- package/dist/esm/client/client-routing-runtime/getPageContextCurrent.d.ts +2 -2
- package/dist/esm/client/client-routing-runtime/getPageContextCurrent.js +1 -1
- package/dist/esm/client/client-routing-runtime/getPageContextFromHooks.d.ts +4 -4
- package/dist/esm/client/client-routing-runtime/getPageContextFromHooks.js +1 -1
- package/dist/esm/client/client-routing-runtime/history.js +1 -1
- package/dist/esm/client/client-routing-runtime/index.d.ts +1 -0
- package/dist/esm/client/client-routing-runtime/index.js +1 -0
- package/dist/esm/client/client-routing-runtime/prefetch/getPrefetchSettings.d.ts +2 -2
- package/dist/esm/client/client-routing-runtime/prefetch.d.ts +2 -2
- package/dist/esm/client/client-routing-runtime/prefetch.js +3 -3
- package/dist/esm/client/client-routing-runtime/renderPageClientSide.d.ts +8 -0
- package/dist/esm/client/client-routing-runtime/renderPageClientSide.js +12 -3
- package/dist/esm/client/client-routing-runtime/scrollRestoration.js +1 -1
- package/dist/esm/client/client-routing-runtime/skipLink.js +2 -2
- package/dist/esm/client/server-routing-runtime/getPageContext.d.ts +1 -1
- package/dist/esm/client/shared/executeOnRenderClientHook.d.ts +2 -2
- package/dist/esm/client/shared/getPageContextProxyForUser.js +1 -1
- package/dist/esm/client/shared/loadUserFilesClientSide.d.ts +2 -2
- package/dist/esm/client/shared/loadUserFilesClientSide.js +2 -2
- package/dist/esm/client/shared/preparePageContextForUserConsumptionClientSide.d.ts +2 -2
- package/dist/esm/node/api/prepareViteApiCall.js +1 -1
- package/dist/esm/node/plugin/index.d.ts +6 -2
- package/dist/esm/node/plugin/index.js +2 -1
- package/dist/esm/node/plugin/plugins/baseUrls.js +9 -2
- package/dist/esm/node/plugin/plugins/buildApp.js +14 -7
- package/dist/esm/node/plugin/plugins/buildConfig/fixServerAssets.js +49 -19
- package/dist/esm/node/plugin/plugins/buildConfig.js +6 -1
- package/dist/esm/node/plugin/plugins/commonConfig.d.ts +14 -6
- package/dist/esm/node/plugin/plugins/commonConfig.js +17 -1
- package/dist/esm/node/plugin/plugins/devConfig/determineOptimizeDeps.js +1 -1
- package/dist/esm/node/plugin/plugins/envVars.js +2 -18
- package/dist/esm/node/plugin/plugins/extractAssetsPlugin.js +3 -3
- package/dist/esm/node/plugin/plugins/extractExportNamesPlugin.js +1 -1
- package/dist/esm/node/plugin/plugins/importUserCode/v1-design/getVikeConfig/assertExtensions.js +4 -4
- package/dist/esm/node/plugin/plugins/importUserCode/v1-design/getVikeConfig/configDefinitionsBuiltIn.js +6 -1
- package/dist/esm/node/plugin/plugins/importUserCode/v1-design/getVikeConfig/crawlPlusFiles.js +10 -9
- package/dist/esm/node/plugin/plugins/importUserCode/v1-design/getVikeConfig/transpileAndExecuteFile.js +8 -5
- package/dist/esm/node/plugin/plugins/importUserCode/v1-design/getVikeConfig.d.ts +5 -5
- package/dist/esm/node/plugin/plugins/importUserCode/v1-design/getVikeConfig.js +38 -73
- package/dist/esm/node/plugin/shared/findPageFiles.js +3 -3
- package/dist/esm/node/plugin/shared/getHttpRequestAsyncStore.js +2 -2
- package/dist/esm/node/plugin/shared/viteIsSSR.d.ts +7 -4
- package/dist/esm/node/plugin/shared/viteIsSSR.js +20 -11
- package/dist/esm/node/prerender/runPrerender.js +3 -1
- package/dist/esm/node/runtime/globalContext.d.ts +9 -8
- package/dist/esm/node/runtime/globalContext.js +19 -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/createHttpResponse/assertNoInfiniteHttpRedirect.js +1 -1
- package/dist/esm/node/runtime/renderPage/createHttpResponse.d.ts +2 -0
- package/dist/esm/node/runtime/renderPage/createHttpResponse.js +24 -0
- package/dist/esm/node/runtime/renderPage/executeOnBeforeRenderAndDataHooks.d.ts +2 -2
- package/dist/esm/node/runtime/renderPage/getPageAssets.d.ts +2 -2
- package/dist/esm/node/runtime/renderPage/getPageAssets.js +1 -1
- package/dist/esm/node/runtime/renderPage/handleErrorWithoutErrorPage.d.ts +2 -2
- package/dist/esm/node/runtime/renderPage/handlePageContextRequestUrl.js +1 -1
- package/dist/esm/node/runtime/renderPage/isNewError.js +1 -1
- package/dist/esm/node/runtime/renderPage/isVikeConfigInvalid.d.ts +6 -0
- package/dist/esm/node/runtime/renderPage/isVikeConfigInvalid.js +8 -0
- package/dist/esm/node/runtime/renderPage/loadUserFilesServerSide.d.ts +3 -3
- package/dist/esm/node/runtime/renderPage/loadUserFilesServerSide.js +2 -2
- package/dist/esm/node/runtime/renderPage/log404/index.d.ts +2 -2
- package/dist/esm/node/runtime/renderPage/logErrorHint.js +7 -1
- package/dist/esm/node/runtime/renderPage/preparePageContextForUserConsumptionServerSide.d.ts +4 -4
- package/dist/esm/node/runtime/renderPage/renderPageAlreadyRouted.d.ts +12 -12
- package/dist/esm/node/runtime/renderPage/renderPageAlreadyRouted.js +2 -4
- package/dist/esm/node/runtime/renderPage.d.ts +5 -5
- package/dist/esm/node/runtime/renderPage.js +64 -49
- package/dist/esm/node/runtime/universal-middleware.d.ts +1 -0
- package/dist/esm/node/runtime/universal-middleware.js +11 -0
- 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 -2
- package/dist/esm/shared/getPageConfigsRuntime.js +3 -9
- package/dist/esm/shared/getPageContextRequestUrl.js +1 -1
- package/dist/esm/shared/getPageContextUrlComputed.js +12 -9
- package/dist/esm/shared/getPageFiles.d.ts +1 -1
- package/dist/esm/shared/hooks/getHook.d.ts +3 -3
- package/dist/esm/shared/hooks/getHook.js +1 -1
- package/dist/esm/shared/page-configs/Config.d.ts +3 -1
- package/dist/esm/shared/page-configs/PageConfig.d.ts +12 -4
- package/dist/esm/shared/page-configs/getPageConfigUserFriendly.d.ts +24 -16
- package/dist/esm/shared/page-configs/getPageConfigUserFriendly.js +44 -12
- package/dist/esm/shared/page-configs/serialize/PageConfigSerialized.d.ts +3 -2
- package/dist/esm/shared/page-configs/serialize/parsePageConfigs.js +2 -8
- package/dist/esm/shared/page-configs/serialize/serializeConfigValues.d.ts +2 -0
- package/dist/esm/shared/page-configs/serialize/serializeConfigValues.js +16 -6
- package/dist/esm/shared/route/executeGuardHook.d.ts +2 -2
- package/dist/esm/shared/route/loadPageRoutes.js +1 -1
- package/dist/esm/shared/types.d.ts +6 -0
- package/dist/esm/utils/PROJECT_VERSION.d.ts +1 -1
- package/dist/esm/utils/PROJECT_VERSION.js +1 -1
- package/dist/esm/utils/assert.js +1 -1
- package/dist/esm/utils/assertSetup.js +1 -1
- package/dist/esm/utils/assertSingleInstance.js +2 -2
- package/dist/esm/utils/findFile.js +1 -1
- package/dist/esm/utils/getGlobalObject.d.ts +3 -2
- package/dist/esm/utils/getGlobalObject.js +2 -6
- package/dist/esm/utils/parseUrl-extras.js +2 -2
- package/dist/esm/utils/parseUrl.d.ts +3 -4
- package/dist/esm/utils/parseUrl.js +5 -5
- package/dist/esm/utils/projectInfo.d.ts +1 -1
- package/package.json +16 -3
- package/universal-middleware.js +3 -0
- package/dist/cjs/node/runtime/renderPage/isConfigInvalid.js +0 -10
- package/dist/esm/node/runtime/renderPage/isConfigInvalid.d.ts +0 -6
- package/dist/esm/node/runtime/renderPage/isConfigInvalid.js +0 -8
|
@@ -17,6 +17,7 @@ import { getFilePathResolved } from '../shared/getFilePath.js';
|
|
|
17
17
|
import { getConfigValueBuildTime } from '../../../shared/page-configs/getConfigValueBuildTime.js';
|
|
18
18
|
import { getOutDirs, resolveOutDir } from '../shared/getOutDirs.js';
|
|
19
19
|
import { viteIsSSR } from '../shared/viteIsSSR.js';
|
|
20
|
+
import { getVikeConfigPublic } from './commonConfig.js';
|
|
20
21
|
// @ts-ignore Shimmed by dist-cjs-fixup.js for CJS build.
|
|
21
22
|
const importMetaUrl = import.meta.url;
|
|
22
23
|
const require_ = createRequire(importMetaUrl);
|
|
@@ -57,11 +58,12 @@ function buildConfig() {
|
|
|
57
58
|
order: 'post',
|
|
58
59
|
handler(config) {
|
|
59
60
|
onSetupBuild();
|
|
61
|
+
const vike = getVikeConfigPublic(config);
|
|
60
62
|
return {
|
|
61
63
|
build: {
|
|
62
64
|
outDir: resolveOutDir(config),
|
|
63
65
|
manifest: manifestTempFile,
|
|
64
|
-
copyPublicDir:
|
|
66
|
+
copyPublicDir: vike.config.viteEnvironmentAPI
|
|
65
67
|
? // Already set by buildApp() plugin
|
|
66
68
|
undefined
|
|
67
69
|
: !viteIsSSR(config)
|
|
@@ -80,6 +82,9 @@ function buildConfig() {
|
|
|
80
82
|
{
|
|
81
83
|
name: 'vike:buildConfig:pre',
|
|
82
84
|
apply: 'build',
|
|
85
|
+
applyToEnvironment(env) {
|
|
86
|
+
return env.name === 'ssr';
|
|
87
|
+
},
|
|
83
88
|
// Make sure other writeBundle() hooks are called after this writeBundle() hook.
|
|
84
89
|
// - set_ASSETS_MANIFEST() needs to be called before dist/server/ code is executed.
|
|
85
90
|
// - For example, the writeBundle() hook of vite-plugin-vercel needs to be called after this writeBundle() hook, otherwise: https://github.com/vikejs/vike/issues/1527
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
export { commonConfig };
|
|
2
|
-
|
|
2
|
+
export { getVikeConfigPublic };
|
|
3
|
+
import { type InlineConfig, type Plugin, type ResolvedConfig, type UserConfig } from 'vite';
|
|
3
4
|
import { type VikeConfigObject } from './importUserCode/v1-design/getVikeConfig.js';
|
|
4
5
|
import type { PrerenderContextPublic } from '../../prerender/runPrerender.js';
|
|
5
6
|
declare module 'vite' {
|
|
@@ -9,11 +10,18 @@ declare module 'vite' {
|
|
|
9
10
|
_root?: string;
|
|
10
11
|
_baseViteOriginal?: string;
|
|
11
12
|
_viteConfigEnhanced?: InlineConfig;
|
|
12
|
-
|
|
13
|
-
config: VikeConfigObject['global']['config'];
|
|
14
|
-
pages: VikeConfigObject['pages'];
|
|
15
|
-
prerenderContext?: PrerenderContextPublic;
|
|
16
|
-
};
|
|
13
|
+
_vike?: VikeConfigPublic;
|
|
17
14
|
}
|
|
18
15
|
}
|
|
16
|
+
type VikeConfigPublic = {
|
|
17
|
+
config: VikeConfigObject['global']['config'];
|
|
18
|
+
pages: VikeConfigObject['pages'];
|
|
19
|
+
prerenderContext?: PrerenderContextPublic;
|
|
20
|
+
};
|
|
19
21
|
declare function commonConfig(vikeVitePluginOptions: unknown): Plugin[];
|
|
22
|
+
/**
|
|
23
|
+
* Get all the information Vike knows about the app in your Vite plugin.
|
|
24
|
+
*
|
|
25
|
+
* https://vike.dev/getVikeConfig
|
|
26
|
+
*/
|
|
27
|
+
declare function getVikeConfigPublic(config: ResolvedConfig | UserConfig): VikeConfigPublic;
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
export { commonConfig };
|
|
2
|
+
export { getVikeConfigPublic };
|
|
2
3
|
import { mergeConfig } from 'vite';
|
|
3
4
|
import { assert, assertUsage, assertWarning, findPackageJson, hasProp, isDevCheck, isDocker, isObject } from '../utils.js';
|
|
4
5
|
import { assertRollupInput } from './buildConfig.js';
|
|
@@ -30,7 +31,7 @@ function commonConfig(vikeVitePluginOptions) {
|
|
|
30
31
|
_isDev: isDev,
|
|
31
32
|
_root: root,
|
|
32
33
|
_vikeVitePluginOptions: vikeVitePluginOptions,
|
|
33
|
-
|
|
34
|
+
_vike: {
|
|
34
35
|
pages: vikeConfig.pages,
|
|
35
36
|
config: vikeConfig.global.config
|
|
36
37
|
},
|
|
@@ -168,3 +169,18 @@ function temp_supportOldInterface(config) {
|
|
|
168
169
|
}
|
|
169
170
|
assert(false);
|
|
170
171
|
}
|
|
172
|
+
// TODO/soon rename:
|
|
173
|
+
// - `getVikeConfig()` => `resolveVikeConfig()` ?
|
|
174
|
+
// - `getVikeConfigPublic()` => `getVikeConfig()`
|
|
175
|
+
// - `VikeConfigPublic` => `VikeConfig` ?
|
|
176
|
+
// - `VikeConfigObject` => `VikeConfigInternal` ?
|
|
177
|
+
/**
|
|
178
|
+
* Get all the information Vike knows about the app in your Vite plugin.
|
|
179
|
+
*
|
|
180
|
+
* https://vike.dev/getVikeConfig
|
|
181
|
+
*/
|
|
182
|
+
function getVikeConfigPublic(config) {
|
|
183
|
+
const vikeConfig = config._vike;
|
|
184
|
+
assert(vikeConfig);
|
|
185
|
+
return vikeConfig;
|
|
186
|
+
}
|
|
@@ -48,7 +48,7 @@ async function getPageDeps(config, pageConfigs) {
|
|
|
48
48
|
sources
|
|
49
49
|
.filter((c) => !c.isOverriden)
|
|
50
50
|
.forEach((configValueSource) => {
|
|
51
|
-
if (!configValueSource.
|
|
51
|
+
if (!configValueSource.valueIsLoadedWithImport && !configValueSource.valueIsFilePath)
|
|
52
52
|
return;
|
|
53
53
|
const { definedAtFilePath, configEnv } = configValueSource;
|
|
54
54
|
if (!configEnv.client)
|
|
@@ -4,6 +4,7 @@ import { assert, assertPosixPath, assertUsage, assertWarning, escapeRegex, isArr
|
|
|
4
4
|
import { sourceMapPassthrough } from '../shared/rollupSourceMap.js';
|
|
5
5
|
import { getModuleFilePathAbsolute } from '../shared/getFilePath.js';
|
|
6
6
|
import { normalizeId } from '../shared/normalizeId.js';
|
|
7
|
+
import { viteIsSSR_safe } from '../shared/viteIsSSR.js';
|
|
7
8
|
// TODO/enventually: (after we implemented vike.config.js)
|
|
8
9
|
// - Make import.meta.env work inside +config.js
|
|
9
10
|
// - For it to work, we'll probably need the user to define the settings (e.g. `envDir`) for loadEnv() inside vike.config.js instead of vite.config.js
|
|
@@ -36,7 +37,7 @@ function envVarsPlugin() {
|
|
|
36
37
|
if (!code.includes('import.meta.env.'))
|
|
37
38
|
return;
|
|
38
39
|
const isBuild = config.command === 'build';
|
|
39
|
-
const isClientSide =
|
|
40
|
+
const isClientSide = !viteIsSSR_safe(config, options);
|
|
40
41
|
Object.entries(envsAll)
|
|
41
42
|
.filter(([key]) => {
|
|
42
43
|
// Already handled by Vite
|
|
@@ -82,20 +83,3 @@ function envVarsPlugin() {
|
|
|
82
83
|
function applyEnvVar(envStatementRegEx, envVal, code) {
|
|
83
84
|
return code.replace(envStatementRegEx, JSON.stringify(envVal));
|
|
84
85
|
}
|
|
85
|
-
function getIsClientSide(config, options) {
|
|
86
|
-
const isBuild = config.command === 'build';
|
|
87
|
-
if (isBuild) {
|
|
88
|
-
assert(typeof config.build.ssr === 'boolean');
|
|
89
|
-
const isServerSide = config.build.ssr;
|
|
90
|
-
if (options !== undefined) {
|
|
91
|
-
assert(options.ssr === isServerSide);
|
|
92
|
-
}
|
|
93
|
-
return !isServerSide;
|
|
94
|
-
}
|
|
95
|
-
else {
|
|
96
|
-
assert(config.build.ssr === false);
|
|
97
|
-
assert(typeof options?.ssr === 'boolean');
|
|
98
|
-
const isServerSide = options.ssr;
|
|
99
|
-
return !isServerSide;
|
|
100
|
-
}
|
|
101
|
-
}
|
|
@@ -17,7 +17,7 @@ import { fixServerAssets_isEnabled } from './buildConfig/fixServerAssets.js';
|
|
|
17
17
|
import { getVikeConfig, isV1Design } from './importUserCode/v1-design/getVikeConfig.js';
|
|
18
18
|
import { assertV1Design } from '../../shared/assertV1Design.js';
|
|
19
19
|
import { normalizeId } from '../shared/normalizeId.js';
|
|
20
|
-
import {
|
|
20
|
+
import { viteIsSSR_safe } from '../shared/viteIsSSR.js';
|
|
21
21
|
const extractAssetsRE = /(\?|&)extractAssets(?:&|$)/;
|
|
22
22
|
const rawRE = /(\?|&)raw(?:&|$)/;
|
|
23
23
|
const urlRE = /(\?|&)url(?:&|$)/;
|
|
@@ -46,7 +46,7 @@ function extractAssetsPlugin() {
|
|
|
46
46
|
}
|
|
47
47
|
// TODO/now: add meta.default
|
|
48
48
|
assert(vikeConfig.global.config.includeAssetsImportedByServer ?? true);
|
|
49
|
-
assert(!
|
|
49
|
+
assert(!viteIsSSR_safe(config, options));
|
|
50
50
|
const importStatements = await getImportStatements(src);
|
|
51
51
|
const moduleNames = getImportedModules(importStatements);
|
|
52
52
|
const code = moduleNames.map((moduleName) => `import '${moduleName}';`).join('\n');
|
|
@@ -63,7 +63,7 @@ function extractAssetsPlugin() {
|
|
|
63
63
|
// - Vite's `vite:resolve` plugin; https://github.com/vitejs/vite/blob/d649daba7682791178b711d9a3e44a6b5d00990c/packages/vite/src/node/plugins/resolve.ts#L105
|
|
64
64
|
enforce: 'pre',
|
|
65
65
|
async resolveId(source, importer, options) {
|
|
66
|
-
if (
|
|
66
|
+
if (viteIsSSR_safe(config, options)) {
|
|
67
67
|
// When building for the server, there should never be a `?extractAssets` query
|
|
68
68
|
assert(!extractAssetsRE.test(source));
|
|
69
69
|
assert(importer === undefined || !extractAssetsRE.test(importer));
|
|
@@ -8,7 +8,7 @@ import { normalizeId } from '../shared/normalizeId.js';
|
|
|
8
8
|
import { viteIsSSR_options } from '../shared/viteIsSSR.js';
|
|
9
9
|
const extractExportNamesRE = /(\?|&)extractExportNames(?:&|$)/;
|
|
10
10
|
const debug = createDebugger('vike:extractExportNames');
|
|
11
|
-
const globalObject = getGlobalObject('extractExportNamesPlugin.ts', {});
|
|
11
|
+
const globalObject = getGlobalObject('plugins/extractExportNamesPlugin.ts', {});
|
|
12
12
|
function extractExportNamesPlugin() {
|
|
13
13
|
let isDev = false;
|
|
14
14
|
return {
|
package/dist/esm/node/plugin/plugins/importUserCode/v1-design/getVikeConfig/assertExtensions.js
CHANGED
|
@@ -63,8 +63,8 @@ function getConfigRequireValue(plusFile) {
|
|
|
63
63
|
const confVal = getConfVal(plusFile, 'require');
|
|
64
64
|
if (!confVal)
|
|
65
65
|
return null;
|
|
66
|
-
assert(confVal.
|
|
67
|
-
const require = confVal.
|
|
66
|
+
assert(confVal.valueIsLoaded);
|
|
67
|
+
const require = confVal.value;
|
|
68
68
|
const { filePathToShowToUserResolved } = plusFile.filePath;
|
|
69
69
|
assert(filePathToShowToUserResolved);
|
|
70
70
|
assertUsage(isObjectOfStrings(require), `The setting ${pc.bold('require')} defined at ${filePathToShowToUserResolved} should be an object with string values (${pc.bold('Record<string, string>')}).`);
|
|
@@ -74,8 +74,8 @@ function getNameValue(plusFile) {
|
|
|
74
74
|
const confVal = getConfVal(plusFile, 'name');
|
|
75
75
|
if (!confVal)
|
|
76
76
|
return null;
|
|
77
|
-
assert(confVal.
|
|
78
|
-
const name = confVal.
|
|
77
|
+
assert(confVal.valueIsLoaded);
|
|
78
|
+
const name = confVal.value;
|
|
79
79
|
const filePathToShowToUser = getFilePathToShowToUser(plusFile);
|
|
80
80
|
assertUsage(typeof name === 'string', `The setting ${pc.bold('name')} defined at ${filePathToShowToUser} should be a string.`);
|
|
81
81
|
return name;
|
|
@@ -31,7 +31,12 @@ const configDefinitionsBuiltIn = {
|
|
|
31
31
|
cumulative: true
|
|
32
32
|
},
|
|
33
33
|
route: {
|
|
34
|
-
env: {
|
|
34
|
+
env: {
|
|
35
|
+
server: true,
|
|
36
|
+
client: 'if-client-routing',
|
|
37
|
+
// For vite-plugin-vercel
|
|
38
|
+
config: true
|
|
39
|
+
},
|
|
35
40
|
eager: true
|
|
36
41
|
},
|
|
37
42
|
guard: {
|
package/dist/esm/node/plugin/plugins/importUserCode/v1-design/getVikeConfig/crawlPlusFiles.js
CHANGED
|
@@ -3,7 +3,7 @@ export { isPlusFile };
|
|
|
3
3
|
export { getPlusFileValueConfigName };
|
|
4
4
|
import { assertPosixPath, assert, scriptFileExtensions, assertIsSingleModuleInstance, assertIsNotProductionRuntime, isVersionOrAbove, isScriptFile, scriptFileExtensionList, createDebugger, deepEqual, assertUsage } from '../../../../utils.js';
|
|
5
5
|
import path from 'path';
|
|
6
|
-
import glob from '
|
|
6
|
+
import { glob } from 'tinyglobby';
|
|
7
7
|
import { exec } from 'child_process';
|
|
8
8
|
import { promisify } from 'util';
|
|
9
9
|
import { isTemporaryBuildFile } from './transpileAndExecuteFile.js';
|
|
@@ -11,7 +11,7 @@ import { getEnvVarObject } from '../../../../shared/getEnvVarObject.js';
|
|
|
11
11
|
const execA = promisify(exec);
|
|
12
12
|
const debug = createDebugger('vike:crawl');
|
|
13
13
|
assertIsNotProductionRuntime();
|
|
14
|
-
assertIsSingleModuleInstance('crawlPlusFiles.ts');
|
|
14
|
+
assertIsSingleModuleInstance('getVikeConfig/crawlPlusFiles.ts');
|
|
15
15
|
let gitIsNotUsable = false;
|
|
16
16
|
async function crawlPlusFiles(userRootDir, outDirAbsoluteFilesystem) {
|
|
17
17
|
assertPosixPath(userRootDir);
|
|
@@ -35,10 +35,10 @@ async function crawlPlusFiles(userRootDir, outDirAbsoluteFilesystem) {
|
|
|
35
35
|
// Crawl
|
|
36
36
|
const filesGit = !isGitCrawlDisabled() && (await gitLsFiles(userRootDir, outDirRelativeFromUserRootDir));
|
|
37
37
|
const filesGitNothingFound = !filesGit || filesGit.length === 0;
|
|
38
|
-
const filesGlob = (filesGitNothingFound || debug.isActivated) && (await
|
|
38
|
+
const filesGlob = (filesGitNothingFound || debug.isActivated) && (await tinyglobby(userRootDir, outDirRelativeFromUserRootDir));
|
|
39
39
|
let files = !filesGitNothingFound
|
|
40
40
|
? filesGit
|
|
41
|
-
: // Fallback to
|
|
41
|
+
: // Fallback to tinyglobby for users that dynamically generate plus files. (Assuming that no plus file is found because of the user's .gitignore list.)
|
|
42
42
|
filesGlob;
|
|
43
43
|
assert(files);
|
|
44
44
|
if (debug.isActivated)
|
|
@@ -47,7 +47,7 @@ async function crawlPlusFiles(userRootDir, outDirAbsoluteFilesystem) {
|
|
|
47
47
|
files = files.filter((filePath) => !isTemporaryBuildFile(filePath));
|
|
48
48
|
// Normalize
|
|
49
49
|
const plusFiles = files.map((filePath) => {
|
|
50
|
-
// Both `$ git-ls files` and
|
|
50
|
+
// Both `$ git-ls files` and tinyglobby return posix paths
|
|
51
51
|
assertPosixPath(filePath);
|
|
52
52
|
assert(!filePath.startsWith(userRootDir));
|
|
53
53
|
const filePathAbsoluteUserRootDir = path.posix.join('/', filePath);
|
|
@@ -56,7 +56,7 @@ async function crawlPlusFiles(userRootDir, outDirAbsoluteFilesystem) {
|
|
|
56
56
|
});
|
|
57
57
|
return plusFiles;
|
|
58
58
|
}
|
|
59
|
-
// Same as
|
|
59
|
+
// Same as tinyglobby() but using `$ git ls-files`
|
|
60
60
|
async function gitLsFiles(userRootDir, outDirRelativeFromUserRootDir) {
|
|
61
61
|
if (gitIsNotUsable)
|
|
62
62
|
return null;
|
|
@@ -123,13 +123,14 @@ async function gitLsFiles(userRootDir, outDirRelativeFromUserRootDir) {
|
|
|
123
123
|
}
|
|
124
124
|
return files;
|
|
125
125
|
}
|
|
126
|
-
// Same as gitLsFiles() but using
|
|
127
|
-
async function
|
|
126
|
+
// Same as gitLsFiles() but using tinyglobby
|
|
127
|
+
async function tinyglobby(userRootDir, outDirRelativeFromUserRootDir) {
|
|
128
128
|
const pattern = `**/+*.${scriptFileExtensions}`;
|
|
129
129
|
const options = {
|
|
130
130
|
ignore: getIgnoreAsPatterns(outDirRelativeFromUserRootDir),
|
|
131
131
|
cwd: userRootDir,
|
|
132
|
-
dot: false
|
|
132
|
+
dot: false,
|
|
133
|
+
expandDirectories: false
|
|
133
134
|
};
|
|
134
135
|
const files = await glob(pattern, options);
|
|
135
136
|
// Make build deterministic, in order to get a stable generated hash for dist/client/assets/entries/entry-client-routing.${hash}.js
|
|
@@ -163,14 +163,17 @@ async function transpileWithEsbuild(filePath, userRootDir, transformImports) {
|
|
|
163
163
|
// - vike@0.4.162 started soft-requiring Vike extensions to set the name config.
|
|
164
164
|
// - In practice, it seems like it requires some (non-trivial?) refactoring.
|
|
165
165
|
isVikeExtensionImport;
|
|
166
|
+
// Externalize npm package imports
|
|
166
167
|
assertPosixPath(importPathResolved);
|
|
167
|
-
const
|
|
168
|
+
const isNpmPkgImport = importPathResolved.includes('/node_modules/') ||
|
|
169
|
+
// Linked npm packages
|
|
170
|
+
!importPathResolved.startsWith(userRootDir);
|
|
168
171
|
const isExternal = isPointerImport ||
|
|
169
172
|
// Performance: npm package imports can be externalized. (We could as well let esbuild transpile /node_modules/ code but it's useless as /node_modules/ code is already built. It would unnecessarily slow down transpilation.)
|
|
170
|
-
|
|
173
|
+
isNpmPkgImport;
|
|
171
174
|
if (!isExternal) {
|
|
172
175
|
// User-land config code (i.e. not runtime code) => let esbuild transpile it
|
|
173
|
-
assert(!isPointerImport && !
|
|
176
|
+
assert(!isPointerImport && !isNpmPkgImport);
|
|
174
177
|
if (debug.isActivated)
|
|
175
178
|
debug('onResolved()', { args, resolved, isPointerImport, isExternal });
|
|
176
179
|
return resolved;
|
|
@@ -189,7 +192,7 @@ async function transpileWithEsbuild(filePath, userRootDir, transformImports) {
|
|
|
189
192
|
userRootDir
|
|
190
193
|
});
|
|
191
194
|
// We assuming that path aliases always resolve inside `userRootDir`.
|
|
192
|
-
if (filePathAbsoluteUserRootDir && !
|
|
195
|
+
if (filePathAbsoluteUserRootDir && !isNpmPkgImport) {
|
|
193
196
|
// `importPathOriginal` is a path alias.
|
|
194
197
|
// - We have to use esbuild's path alias resolution, because:
|
|
195
198
|
// - Vike doesn't resolve path aliases at all.
|
|
@@ -211,7 +214,7 @@ async function transpileWithEsbuild(filePath, userRootDir, transformImports) {
|
|
|
211
214
|
// Import of runtime code => handled by Vike
|
|
212
215
|
isPointerImport ||
|
|
213
216
|
// Import of config code => loaded by Node.js at build-time
|
|
214
|
-
|
|
217
|
+
isNpmPkgImport);
|
|
215
218
|
pointerImports[importPathTranspiled] = isPointerImport;
|
|
216
219
|
return { external: true, path: importPathTranspiled };
|
|
217
220
|
});
|
|
@@ -9,12 +9,12 @@ export type { VikeConfigObject };
|
|
|
9
9
|
import type { PageConfigGlobalBuildTime, PageConfigBuildTime } from '../../../../../shared/page-configs/PageConfig.js';
|
|
10
10
|
import { type ConfigDefinitions, type ConfigDefinitionInternal } from './getVikeConfig/configDefinitionsBuiltIn.js';
|
|
11
11
|
import type { ResolvedConfig } from 'vite';
|
|
12
|
-
import { type
|
|
12
|
+
import { type PageConfigUserFriendly, type PageConfigsUserFriendly } from '../../../../../shared/page-configs/getPageConfigUserFriendly.js';
|
|
13
13
|
import { type PlusFile } from './getVikeConfig/getPlusFilesAll.js';
|
|
14
14
|
type VikeConfigObject = {
|
|
15
15
|
pageConfigs: PageConfigBuildTime[];
|
|
16
16
|
pageConfigGlobal: PageConfigGlobalBuildTime;
|
|
17
|
-
global:
|
|
17
|
+
global: PageConfigUserFriendly;
|
|
18
18
|
pages: PageConfigsUserFriendly;
|
|
19
19
|
};
|
|
20
20
|
declare const vikeConfigDependencies: Set<string>;
|
|
@@ -26,8 +26,8 @@ declare function getVikeConfig2(userRootDir: string, isDev: boolean, vikeVitePlu
|
|
|
26
26
|
declare function isV1Design(config: ResolvedConfig): Promise<boolean>;
|
|
27
27
|
declare function getConfigDefinitionOptional(configDefinitions: ConfigDefinitions, configName: string): ConfigDefinitionInternal | null;
|
|
28
28
|
declare function getConfVal(plusFile: PlusFile, configName: string): null | {
|
|
29
|
-
|
|
30
|
-
|
|
29
|
+
value: unknown;
|
|
30
|
+
valueIsLoaded: true;
|
|
31
31
|
} | {
|
|
32
|
-
|
|
32
|
+
valueIsLoaded: false;
|
|
33
33
|
};
|
|
@@ -8,7 +8,7 @@ export { getConfigDefinitionOptional };
|
|
|
8
8
|
import { assertPosixPath, assert, isObject, assertUsage, assertWarning, objectEntries, hasProp, includes, assertIsNotProductionRuntime, getMostSimilar, joinEnglish, assertKeys, objectKeys, objectFromEntries, unique, isCallable, makeFirst, lowerFirst } from '../../../utils.js';
|
|
9
9
|
import { configDefinitionsBuiltIn } from './getVikeConfig/configDefinitionsBuiltIn.js';
|
|
10
10
|
import { getLocationId, getFilesystemRouteString, getFilesystemRouteDefinedBy, isInherited, sortAfterInheritanceOrder, applyFilesystemRoutingRootEffect } from './getVikeConfig/filesystemRouting.js';
|
|
11
|
-
import {
|
|
11
|
+
import { isVikeConfigInvalid, isVikeConfigInvalid_set } from '../../../../runtime/renderPage/isVikeConfigInvalid.js';
|
|
12
12
|
import { getViteDevServer } from '../../../../runtime/globalContext.js';
|
|
13
13
|
import { logConfigError, logConfigErrorRecover } from '../../../shared/loggerNotProd.js';
|
|
14
14
|
import { removeSuperfluousViteLog_enable, removeSuperfluousViteLog_disable } from '../../../shared/loggerVite/removeSuperfluousViteLog.js';
|
|
@@ -19,8 +19,8 @@ import { resolvePointerImport } from './getVikeConfig/resolvePointerImport.js';
|
|
|
19
19
|
import { getFilePathResolved } from '../../../shared/getFilePath.js';
|
|
20
20
|
import { getConfigValueBuildTime } from '../../../../../shared/page-configs/getConfigValueBuildTime.js';
|
|
21
21
|
import { assertExtensionsRequire } from './getVikeConfig/assertExtensions.js';
|
|
22
|
-
import {
|
|
23
|
-
import { getConfigValuesBase } from '../../../../../shared/page-configs/serialize/serializeConfigValues.js';
|
|
22
|
+
import { getPageConfigGlobalUserFriendly, getPageConfigUserFriendly } from '../../../../../shared/page-configs/getPageConfigUserFriendly.js';
|
|
23
|
+
import { getConfigValuesBase, isJsonValue } from '../../../../../shared/page-configs/serialize/serializeConfigValues.js';
|
|
24
24
|
import { getPlusFilesAll } from './getVikeConfig/getPlusFilesAll.js';
|
|
25
25
|
assertIsNotProductionRuntime();
|
|
26
26
|
let restartVite = false;
|
|
@@ -37,7 +37,7 @@ function reloadVikeConfig(config) {
|
|
|
37
37
|
handleReloadSideEffects();
|
|
38
38
|
}
|
|
39
39
|
async function handleReloadSideEffects() {
|
|
40
|
-
wasConfigInvalid = !!
|
|
40
|
+
wasConfigInvalid = !!isVikeConfigInvalid;
|
|
41
41
|
const vikeConfigPromisePrevious = vikeConfigPromise;
|
|
42
42
|
try {
|
|
43
43
|
await vikeConfigPromise;
|
|
@@ -52,7 +52,7 @@ async function handleReloadSideEffects() {
|
|
|
52
52
|
// Let the next handleReloadSideEffects() call handle side effects
|
|
53
53
|
return;
|
|
54
54
|
}
|
|
55
|
-
if (!
|
|
55
|
+
if (!isVikeConfigInvalid) {
|
|
56
56
|
if (wasConfigInvalid) {
|
|
57
57
|
wasConfigInvalid = false;
|
|
58
58
|
logConfigErrorRecover();
|
|
@@ -105,13 +105,13 @@ async function loadVikeConfig_withErrorHandling(userRootDir, isDev, vikeVitePlug
|
|
|
105
105
|
if (!hasError) {
|
|
106
106
|
assert(ret);
|
|
107
107
|
assert(err === undefined);
|
|
108
|
-
|
|
108
|
+
isVikeConfigInvalid_set(false);
|
|
109
109
|
return ret;
|
|
110
110
|
}
|
|
111
111
|
else {
|
|
112
112
|
assert(ret === undefined);
|
|
113
113
|
assert(err);
|
|
114
|
-
|
|
114
|
+
isVikeConfigInvalid_set({ err });
|
|
115
115
|
if (!isDev) {
|
|
116
116
|
assert(getViteDevServer() === null);
|
|
117
117
|
throw err;
|
|
@@ -127,7 +127,7 @@ async function loadVikeConfig_withErrorHandling(userRootDir, isDev, vikeVitePlug
|
|
|
127
127
|
configDefinitions: {},
|
|
128
128
|
configValueSources: {}
|
|
129
129
|
},
|
|
130
|
-
global:
|
|
130
|
+
global: getPageConfigGlobalUserFriendly({ pageConfigGlobalValues: {} }),
|
|
131
131
|
pages: {}
|
|
132
132
|
};
|
|
133
133
|
return dummyData;
|
|
@@ -143,18 +143,12 @@ async function loadVikeConfig(userRootDir, vikeVitePluginOptions) {
|
|
|
143
143
|
// interop vike(options) in vite.config.js
|
|
144
144
|
temp_interopVikeVitePlugin(pageConfigGlobal, vikeVitePluginOptions, userRootDir);
|
|
145
145
|
// global
|
|
146
|
-
const
|
|
147
|
-
const global =
|
|
148
|
-
// TODO/now DEDUPE
|
|
146
|
+
const pageConfigGlobalValues = getConfigValues(pageConfigGlobal);
|
|
147
|
+
const global = getPageConfigGlobalUserFriendly({ pageConfigGlobalValues });
|
|
149
148
|
// pages
|
|
150
149
|
const pages = objectFromEntries(pageConfigs.map((pageConfig) => {
|
|
151
|
-
const
|
|
152
|
-
|
|
153
|
-
const page = {
|
|
154
|
-
...getPageConfigUserFriendlyNew({ configValues }),
|
|
155
|
-
route: pageConfig.routeFilesystem?.routeString ?? null
|
|
156
|
-
};
|
|
157
|
-
return [pageConfig.pageId, page];
|
|
150
|
+
const pageConfigValues = getConfigValues(pageConfig, true);
|
|
151
|
+
return getPageConfigUserFriendly(pageConfigGlobalValues, pageConfig, pageConfigValues);
|
|
158
152
|
}));
|
|
159
153
|
return { pageConfigs, pageConfigGlobal, global, pages };
|
|
160
154
|
}
|
|
@@ -219,13 +213,12 @@ function getPageConfigsBuildTime(configDefinitionsResolved, plusFilesAll, userRo
|
|
|
219
213
|
return;
|
|
220
214
|
configValueSources[configName] = sources;
|
|
221
215
|
});
|
|
222
|
-
const
|
|
216
|
+
const pageConfigRoute = determineRouteFilesystem(locationId, configValueSources);
|
|
223
217
|
applyEffectsAll(configValueSources, configDefinitionsLocal);
|
|
224
218
|
const configValuesComputed = getComputed(configValueSources, configDefinitionsLocal);
|
|
225
219
|
const pageConfig = {
|
|
226
220
|
pageId: locationId,
|
|
227
|
-
|
|
228
|
-
routeFilesystem,
|
|
221
|
+
...pageConfigRoute,
|
|
229
222
|
configDefinitions: configDefinitionsLocal,
|
|
230
223
|
plusFiles: plusFilesRelevant,
|
|
231
224
|
configValueSources,
|
|
@@ -359,8 +352,8 @@ function temp_interopVikeVitePlugin(pageConfigGlobal, vikeVitePluginOptions, use
|
|
|
359
352
|
locationId: '/',
|
|
360
353
|
plusFile: null,
|
|
361
354
|
isOverriden: configDef.cumulative ? false : sources.length > 0,
|
|
362
|
-
|
|
363
|
-
|
|
355
|
+
valueIsLoadedWithImport: false,
|
|
356
|
+
valueIsDefinedByPlusValueFile: false
|
|
364
357
|
});
|
|
365
358
|
});
|
|
366
359
|
}
|
|
@@ -424,20 +417,10 @@ function getPlusFilesOrdered(configName, plusFilesRelevant) {
|
|
|
424
417
|
const plusFilesConfig = plusFilesForConfigName.filter((plusFile) => plusFile.isConfigFile &&
|
|
425
418
|
// We consider extensions (e.g. vike-react) later (i.e. with less priority)
|
|
426
419
|
!plusFile.isExtensionConfig);
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
const plusFileWinner = plusFilesValue[0] ?? plusFilesConfig[0];
|
|
432
|
-
if (plusFileWinner) {
|
|
433
|
-
const plusFilesOverriden = [...plusFilesValue, ...plusFilesConfig].filter((f) => f !== plusFileWinner);
|
|
434
|
-
// A user-land conflict of plusFiles with the same `locationId` (we are iterating over `plusFilesRelevant: PlusFilesByLocationId`) means that the user has superfluously defined the config twice; the user should remove such redundancy as it makes things unnecessarily ambiguous.
|
|
435
|
-
assertOverwrittenConfigFile(plusFileWinner, plusFilesOverriden, configName);
|
|
436
|
-
[plusFileWinner, ...plusFilesOverriden].forEach((plusFile) => {
|
|
437
|
-
assert(plusFile.filePath.filePathAbsoluteUserRootDir); // ensure it's a user-land plus file
|
|
438
|
-
populate(plusFile);
|
|
439
|
-
});
|
|
440
|
-
}
|
|
420
|
+
[...plusFilesValue, ...plusFilesConfig].forEach((plusFile) => {
|
|
421
|
+
assert(plusFile.filePath.filePathAbsoluteUserRootDir); // ensure it's a user-land plus file
|
|
422
|
+
populate(plusFile);
|
|
423
|
+
});
|
|
441
424
|
}
|
|
442
425
|
// ==========================
|
|
443
426
|
// Side-effect configs (next)
|
|
@@ -489,8 +472,8 @@ function getConfigValueSource(configName, plusFile, configDef, userRootDir, isHi
|
|
|
489
472
|
let valueFilePath;
|
|
490
473
|
if (plusFile.isConfigFile) {
|
|
491
474
|
// Defined over pointer import
|
|
492
|
-
assert(confVal.
|
|
493
|
-
const pointerImport = resolvePointerImport(confVal.
|
|
475
|
+
assert(confVal.valueIsLoaded);
|
|
476
|
+
const pointerImport = resolvePointerImport(confVal.value, plusFile.filePath, userRootDir, configName);
|
|
494
477
|
const configDefinedAt = getConfigDefinedAt('Config', configName, definedAtFilePath_);
|
|
495
478
|
assertUsage(pointerImport, `${configDefinedAt} should be an import`);
|
|
496
479
|
valueFilePath = pointerImport.fileExportPath.filePathAbsoluteVite;
|
|
@@ -511,8 +494,8 @@ function getConfigValueSource(configName, plusFile, configDef, userRootDir, isHi
|
|
|
511
494
|
value: valueFilePath,
|
|
512
495
|
valueIsFilePath: true,
|
|
513
496
|
configEnv: configDef.env,
|
|
514
|
-
|
|
515
|
-
|
|
497
|
+
valueIsLoadedWithImport: false,
|
|
498
|
+
valueIsDefinedByPlusValueFile: false,
|
|
516
499
|
isOverriden,
|
|
517
500
|
definedAtFilePath
|
|
518
501
|
};
|
|
@@ -520,8 +503,7 @@ function getConfigValueSource(configName, plusFile, configDef, userRootDir, isHi
|
|
|
520
503
|
}
|
|
521
504
|
// +config.js
|
|
522
505
|
if (plusFile.isConfigFile) {
|
|
523
|
-
assert(confVal.
|
|
524
|
-
const { configValue } = confVal;
|
|
506
|
+
assert(confVal.valueIsLoaded);
|
|
525
507
|
// Defined over pointer import
|
|
526
508
|
const pointerImport = plusFile.pointerImportsByConfigName[configName];
|
|
527
509
|
if (pointerImport) {
|
|
@@ -537,8 +519,8 @@ function getConfigValueSource(configName, plusFile, configDef, userRootDir, isHi
|
|
|
537
519
|
...configValueSourceCommon,
|
|
538
520
|
...value,
|
|
539
521
|
configEnv: resolveConfigEnv(configDef.env, pointerImport.fileExportPath),
|
|
540
|
-
|
|
541
|
-
|
|
522
|
+
valueIsLoadedWithImport: true,
|
|
523
|
+
valueIsDefinedByPlusValueFile: false,
|
|
542
524
|
isOverriden,
|
|
543
525
|
definedAtFilePath: pointerImport.fileExportPath
|
|
544
526
|
};
|
|
@@ -548,10 +530,10 @@ function getConfigValueSource(configName, plusFile, configDef, userRootDir, isHi
|
|
|
548
530
|
const configValueSource = {
|
|
549
531
|
...configValueSourceCommon,
|
|
550
532
|
valueIsLoaded: true,
|
|
551
|
-
value:
|
|
533
|
+
value: confVal.value,
|
|
552
534
|
configEnv: configDef.env,
|
|
553
|
-
|
|
554
|
-
|
|
535
|
+
valueIsLoadedWithImport: false,
|
|
536
|
+
valueIsDefinedByPlusValueFile: false,
|
|
555
537
|
isOverriden,
|
|
556
538
|
definedAtFilePath: definedAtFilePath_
|
|
557
539
|
};
|
|
@@ -560,22 +542,13 @@ function getConfigValueSource(configName, plusFile, configDef, userRootDir, isHi
|
|
|
560
542
|
// Defined by value file, i.e. +{configName}.js
|
|
561
543
|
if (!plusFile.isConfigFile) {
|
|
562
544
|
const configEnvResolved = resolveConfigEnv(configDef.env, plusFile.filePath);
|
|
563
|
-
|
|
564
|
-
assert(valueAlreadyLoaded === !!configEnvResolved.config);
|
|
565
|
-
const value = valueAlreadyLoaded
|
|
566
|
-
? {
|
|
567
|
-
valueIsLoaded: true,
|
|
568
|
-
value: confVal.configValue
|
|
569
|
-
}
|
|
570
|
-
: {
|
|
571
|
-
valueIsLoaded: false
|
|
572
|
-
};
|
|
545
|
+
assert(confVal.valueIsLoaded === !!configEnvResolved.config);
|
|
573
546
|
const configValueSource = {
|
|
574
547
|
...configValueSourceCommon,
|
|
575
|
-
...
|
|
548
|
+
...confVal,
|
|
576
549
|
configEnv: configEnvResolved,
|
|
577
|
-
|
|
578
|
-
|
|
550
|
+
valueIsLoadedWithImport: !confVal.valueIsLoaded || !isJsonValue(confVal.value),
|
|
551
|
+
valueIsDefinedByPlusValueFile: true,
|
|
579
552
|
isOverriden,
|
|
580
553
|
definedAtFilePath: {
|
|
581
554
|
...plusFile.filePath,
|
|
@@ -589,14 +562,6 @@ function getConfigValueSource(configName, plusFile, configDef, userRootDir, isHi
|
|
|
589
562
|
}
|
|
590
563
|
assert(false);
|
|
591
564
|
}
|
|
592
|
-
function assertOverwrittenConfigFile(plusFileWinner, plusFilesOverriden, configName) {
|
|
593
|
-
plusFilesOverriden.forEach((plusFileLoser) => {
|
|
594
|
-
const loserFilePath = plusFileLoser.filePath.filePathToShowToUser;
|
|
595
|
-
const winnerFilePath = plusFileWinner.filePath.filePathToShowToUser;
|
|
596
|
-
const confName = pc.cyan(configName);
|
|
597
|
-
assertWarning(false, `The value of the config ${confName} defined at ${loserFilePath} is always overwritten by the value defined at ${winnerFilePath}, remove the superfluous value defined at ${loserFilePath}`, { onlyOnce: true });
|
|
598
|
-
});
|
|
599
|
-
}
|
|
600
565
|
function isDefiningPage(plusFiles) {
|
|
601
566
|
for (const plusFile of plusFiles) {
|
|
602
567
|
const configNames = getDefiningConfigNames(plusFile);
|
|
@@ -630,8 +595,8 @@ function getConfigDefinitions(plusFilesRelevant, filter) {
|
|
|
630
595
|
const confVal = getConfVal(plusFile, 'meta');
|
|
631
596
|
if (!confVal)
|
|
632
597
|
return;
|
|
633
|
-
assert(confVal.
|
|
634
|
-
const meta = confVal.
|
|
598
|
+
assert(confVal.valueIsLoaded);
|
|
599
|
+
const meta = confVal.value;
|
|
635
600
|
assertMetaUsage(meta, `Config ${pc.cyan('meta')} defined at ${plusFile.filePath.filePathToShowToUser}`);
|
|
636
601
|
// Set configDef._userEffectDefinedAtFilePath
|
|
637
602
|
Object.entries(meta).forEach(([configName, configDef]) => {
|
|
@@ -927,8 +892,8 @@ function getConfVal(plusFile, configName) {
|
|
|
927
892
|
if (!configNames.includes(configName))
|
|
928
893
|
return null;
|
|
929
894
|
if (plusFile.isNotLoaded)
|
|
930
|
-
return {
|
|
931
|
-
const confVal = {
|
|
895
|
+
return { valueIsLoaded: false };
|
|
896
|
+
const confVal = { value: plusFile.fileExportsByConfigName[configName], valueIsLoaded: true };
|
|
932
897
|
return confVal;
|
|
933
898
|
}
|
|
934
899
|
function resolveConfigEnv(configEnv, filePath) {
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
export { findPageFiles };
|
|
2
|
-
import glob from '
|
|
2
|
+
import { glob } from 'tinyglobby';
|
|
3
3
|
import { assertWarning, toPosixPath, scriptFileExtensions } from '../utils.js';
|
|
4
4
|
import pc from '@brillout/picocolors';
|
|
5
5
|
import { getOutDirs } from './getOutDirs.js';
|
|
@@ -7,11 +7,11 @@ async function findPageFiles(config, fileTypes, isDev) {
|
|
|
7
7
|
const cwd = config.root;
|
|
8
8
|
const { outDirRoot } = getOutDirs(config);
|
|
9
9
|
const timeBase = new Date().getTime();
|
|
10
|
-
let pageFiles = await glob(fileTypes.map((fileType) => `**/*${fileType}.${scriptFileExtensions}`), { ignore: ['**/node_modules/**', `${outDirRoot}/**`], cwd, dot: false });
|
|
10
|
+
let pageFiles = await glob(fileTypes.map((fileType) => `**/*${fileType}.${scriptFileExtensions}`), { ignore: ['**/node_modules/**', `${outDirRoot}/**`], cwd, dot: false, expandDirectories: false });
|
|
11
11
|
pageFiles = pageFiles.map((p) => '/' + toPosixPath(p));
|
|
12
12
|
const time = new Date().getTime() - timeBase;
|
|
13
13
|
if (isDev) {
|
|
14
|
-
// We only warn in dev, because while building it's expected to take a long time as
|
|
14
|
+
// We only warn in dev, because while building it's expected to take a long time as tinyglobby is competing for resources with other tasks
|
|
15
15
|
assertWarning(time < 1.5 * 1000, `Finding your page files ${pc.cyan('**/*.page.*')} took an unexpected long time (${time}ms). Reach out to the vike maintainer.`, {
|
|
16
16
|
onlyOnce: 'slow-page-files-search'
|
|
17
17
|
});
|