vike 0.4.217 → 0.4.218-commit-ed9b3d4
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 +9 -8
- package/dist/cjs/node/api/build.js +21 -12
- package/dist/cjs/node/api/context.js +5 -1
- package/dist/cjs/node/api/index.js +17 -7
- package/dist/cjs/node/api/prepareViteApiCall.js +128 -26
- package/dist/cjs/node/api/utils.js +2 -0
- package/dist/cjs/node/cli/entry.js +19 -7
- package/dist/cjs/node/plugin/index.js +6 -5
- package/dist/cjs/node/plugin/plugins/autoFullBuild.js +3 -4
- package/dist/cjs/node/plugin/plugins/baseUrls.js +20 -18
- package/dist/cjs/node/plugin/plugins/buildConfig.js +2 -2
- package/dist/cjs/node/plugin/plugins/{importBuild → buildEntry}/index.js +16 -17
- package/dist/cjs/node/plugin/plugins/commonConfig.js +6 -6
- package/dist/cjs/node/plugin/plugins/importUserCode/v1-design/getVikeConfig/configDefinitionsBuiltIn.js +2 -3
- package/dist/cjs/node/plugin/plugins/importUserCode/v1-design/getVikeConfig/crawlPlusFiles.js +22 -111
- package/dist/cjs/node/plugin/plugins/importUserCode/v1-design/getVikeConfig.js +189 -16
- package/dist/cjs/node/plugin/plugins/importUserCode/v1-design/getVirtualFilePageConfigs.js +2 -1
- package/dist/cjs/node/plugin/plugins/setGlobalContext.js +1 -1
- package/dist/cjs/node/plugin/plugins/{vite6HmrRegressionWorkaround.js → workaroundVite6HmrRegression.js} +3 -3
- package/dist/cjs/node/plugin/shared/getHttpRequestAsyncStore.js +17 -7
- package/dist/cjs/node/prerender/isPrerenderEnabled.js +8 -0
- package/dist/cjs/node/prerender/runPrerender.js +22 -35
- package/dist/cjs/node/runtime/globalContext.js +76 -29
- package/dist/cjs/node/runtime/html/injectAssets/getHtmlTags.js +2 -2
- package/dist/cjs/node/runtime/index-common.js +0 -15
- package/dist/cjs/node/runtime/onLoad.js +17 -3
- package/dist/cjs/node/runtime/renderPage/analyzePage.js +2 -2
- package/dist/cjs/node/runtime/renderPage/createHttpResponse/getCacheControl.js +2 -2
- package/dist/cjs/node/runtime/renderPage/loadUserFilesServerSide.js +1 -1
- package/dist/cjs/node/runtime/renderPage/renderPageAlreadyRouted.js +3 -3
- package/dist/cjs/node/runtime/utils.js +1 -0
- package/dist/cjs/node/runtime-dev/index.js +17 -7
- package/dist/cjs/node/shared/resolveBase.js +2 -2
- package/dist/cjs/shared/getPageFiles/analyzeClientSide.js +3 -3
- package/dist/cjs/shared/getPageFiles/{setPageFiles.js → getPageFiles.js} +2 -3
- package/dist/cjs/shared/getPageFiles.js +3 -9
- package/dist/cjs/shared/hooks/getHook.js +3 -3
- package/dist/cjs/shared/{getPageFiles/getExports.js → page-configs/getPageConfigUserFriendly.js} +113 -81
- package/dist/cjs/shared/page-configs/serialize/serializeConfigValues.js +79 -54
- package/dist/cjs/shared/route/loadPageRoutes.js +3 -3
- package/dist/cjs/shared/utils.js +1 -0
- package/dist/cjs/utils/PROJECT_VERSION.js +1 -1
- package/dist/cjs/utils/assert.js +4 -3
- package/dist/cjs/utils/debug.js +11 -6
- package/dist/cjs/utils/objectReplace.js +9 -0
- package/dist/esm/__internal/index.d.ts +3 -5
- package/dist/esm/__internal/index.js +4 -5
- package/dist/esm/client/client-routing-runtime/createPageContext.js +7 -1
- package/dist/esm/client/client-routing-runtime/entry.d.ts +1 -1
- package/dist/esm/client/client-routing-runtime/entry.js +0 -1
- package/dist/esm/client/client-routing-runtime/getPageContextCurrent.d.ts +2 -2
- 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/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 +2 -2
- package/dist/esm/client/server-routing-runtime/entry.d.ts +1 -1
- package/dist/esm/client/server-routing-runtime/entry.js +0 -1
- package/dist/esm/client/server-routing-runtime/getPageContext.d.ts +1 -1
- package/dist/esm/client/server-routing-runtime/getPageContext.js +8 -2
- package/dist/esm/client/shared/executeOnRenderClientHook.d.ts +2 -2
- 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/build.js +4 -5
- package/dist/esm/node/api/context.d.ts +3 -1
- package/dist/esm/node/api/context.js +6 -2
- package/dist/esm/node/api/prepareViteApiCall.d.ts +9 -3
- package/dist/esm/node/api/prepareViteApiCall.js +111 -22
- package/dist/esm/node/api/utils.d.ts +2 -0
- package/dist/esm/node/api/utils.js +2 -0
- package/dist/esm/node/cli/entry.js +2 -0
- package/dist/esm/node/cli/parseCli.d.ts +1 -1
- package/dist/esm/node/plugin/index.d.ts +1 -1
- package/dist/esm/node/plugin/index.js +6 -5
- package/dist/esm/node/plugin/plugins/autoFullBuild.js +3 -4
- package/dist/esm/node/plugin/plugins/baseUrls.d.ts +1 -2
- package/dist/esm/node/plugin/plugins/baseUrls.js +21 -19
- package/dist/esm/node/plugin/plugins/buildConfig.js +2 -2
- package/dist/esm/node/plugin/plugins/{importBuild → buildEntry}/getVikeManifest.d.ts +1 -1
- package/dist/esm/node/plugin/plugins/{importBuild → buildEntry}/index.d.ts +2 -2
- package/dist/esm/node/plugin/plugins/{importBuild → buildEntry}/index.js +16 -17
- package/dist/esm/node/plugin/plugins/commonConfig.d.ts +7 -1
- package/dist/esm/node/plugin/plugins/commonConfig.js +2 -2
- package/dist/esm/node/plugin/plugins/importUserCode/getVirtualFileImportUserCode.d.ts +1 -1
- package/dist/esm/node/plugin/plugins/importUserCode/v1-design/getVikeConfig/configDefinitionsBuiltIn.d.ts +1 -1
- package/dist/esm/node/plugin/plugins/importUserCode/v1-design/getVikeConfig/configDefinitionsBuiltIn.js +2 -3
- package/dist/esm/node/plugin/plugins/importUserCode/v1-design/getVikeConfig/crawlPlusFiles.d.ts +1 -1
- package/dist/esm/node/plugin/plugins/importUserCode/v1-design/getVikeConfig/crawlPlusFiles.js +23 -112
- package/dist/esm/node/plugin/plugins/importUserCode/v1-design/getVikeConfig.d.ts +99 -1
- package/dist/esm/node/plugin/plugins/importUserCode/v1-design/getVikeConfig.js +189 -16
- package/dist/esm/node/plugin/plugins/importUserCode/v1-design/getVirtualFilePageConfigs.js +2 -1
- package/dist/esm/node/plugin/plugins/setGlobalContext.js +1 -1
- package/dist/esm/node/plugin/plugins/workaroundVite6HmrRegression.d.ts +3 -0
- package/dist/esm/node/plugin/plugins/{vite6HmrRegressionWorkaround.js → workaroundVite6HmrRegression.js} +3 -3
- package/dist/esm/node/plugin/shared/getEnvVarObject.d.ts +1 -1
- package/dist/esm/node/prerender/isPrerenderEnabled.d.ts +3 -0
- package/dist/esm/node/prerender/isPrerenderEnabled.js +6 -0
- package/dist/esm/node/prerender/runPrerender.d.ts +1 -2
- package/dist/esm/node/prerender/runPrerender.js +4 -27
- package/dist/esm/node/runtime/globalContext.d.ts +6 -4
- package/dist/esm/node/runtime/globalContext.js +76 -29
- package/dist/esm/node/runtime/html/injectAssets/getHtmlTags.js +1 -1
- package/dist/esm/node/runtime/index-common.d.ts +0 -1
- package/dist/esm/node/runtime/index-common.js +0 -15
- package/dist/esm/node/runtime/index-deprecated.d.ts +1 -0
- package/dist/esm/node/runtime/onLoad.js +16 -2
- package/dist/esm/node/runtime/renderPage/analyzePage.js +1 -1
- package/dist/esm/node/runtime/renderPage/createHttpResponse/getCacheControl.js +1 -1
- package/dist/esm/node/runtime/renderPage/executeOnBeforeRenderAndDataHooks.d.ts +2 -2
- package/dist/esm/node/runtime/renderPage/loadUserFilesServerSide.d.ts +1 -1
- package/dist/esm/node/runtime/renderPage/loadUserFilesServerSide.js +2 -2
- package/dist/esm/node/runtime/renderPage/preparePageContextForUserConsumptionServerSide.d.ts +2 -2
- package/dist/esm/node/runtime/renderPage/renderPageAlreadyRouted.d.ts +5 -5
- package/dist/esm/node/runtime/renderPage/renderPageAlreadyRouted.js +3 -3
- package/dist/esm/node/runtime/utils.d.ts +1 -0
- package/dist/esm/node/runtime/utils.js +1 -0
- package/dist/esm/node/shared/resolveBase.js +2 -2
- package/dist/esm/shared/getPageFiles/analyzeClientSide.js +1 -1
- package/dist/esm/shared/getPageFiles/{setPageFiles.js → getPageFiles.js} +2 -3
- package/dist/esm/shared/getPageFiles.d.ts +2 -5
- package/dist/esm/shared/getPageFiles.js +1 -4
- 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 +8 -2
- package/dist/esm/shared/page-configs/PageConfig.d.ts +7 -3
- package/dist/esm/shared/{getPageFiles/getExports.d.ts → page-configs/getPageConfigUserFriendly.d.ts} +23 -12
- package/dist/esm/shared/{getPageFiles/getExports.js → page-configs/getPageConfigUserFriendly.js} +112 -80
- package/dist/esm/shared/page-configs/serialize/serializeConfigValues.d.ts +28 -4
- package/dist/esm/shared/page-configs/serialize/serializeConfigValues.js +79 -54
- 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 +1 -1
- package/dist/esm/shared/utils.d.ts +1 -0
- package/dist/esm/shared/utils.js +1 -0
- package/dist/esm/types/index.d.ts +1 -1
- 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 +4 -3
- package/dist/esm/utils/debug.d.ts +1 -1
- package/dist/esm/utils/debug.js +11 -6
- package/dist/esm/utils/objectReplace.d.ts +1 -0
- package/dist/esm/utils/objectReplace.js +6 -0
- package/dist/esm/utils/projectInfo.d.ts +1 -1
- package/package.json +3 -22
- package/__internal/loadImportBuild.js +0 -3
- package/__internal/setup.js +0 -3
- package/dist/cjs/node/plugin/plugins/commonConfig/pluginName.js +0 -4
- package/dist/cjs/node/plugin/plugins/importUserCode/v1-design/getVikeConfig/resolveVikeConfigGlobal.js +0 -128
- package/dist/cjs/node/runtime/globalContext/loadImportBuild.js +0 -25
- package/dist/cjs/node/runtime/page-files/getPageFilesExports.js +0 -22
- package/dist/cjs/node/runtime/page-files/setup.js +0 -5
- package/dist/esm/client/client-routing-runtime/pageFiles.d.ts +0 -1
- package/dist/esm/client/client-routing-runtime/pageFiles.js +0 -4
- package/dist/esm/client/server-routing-runtime/pageFiles.d.ts +0 -1
- package/dist/esm/client/server-routing-runtime/pageFiles.js +0 -4
- package/dist/esm/node/plugin/plugins/commonConfig/pluginName.d.ts +0 -1
- package/dist/esm/node/plugin/plugins/commonConfig/pluginName.js +0 -1
- package/dist/esm/node/plugin/plugins/importUserCode/v1-design/getVikeConfig/resolveVikeConfigGlobal.d.ts +0 -104
- package/dist/esm/node/plugin/plugins/importUserCode/v1-design/getVikeConfig/resolveVikeConfigGlobal.js +0 -123
- package/dist/esm/node/plugin/plugins/vite6HmrRegressionWorkaround.d.ts +0 -3
- package/dist/esm/node/runtime/globalContext/loadImportBuild.d.ts +0 -18
- package/dist/esm/node/runtime/globalContext/loadImportBuild.js +0 -23
- package/dist/esm/node/runtime/page-files/getPageFilesExports.d.ts +0 -2
- package/dist/esm/node/runtime/page-files/getPageFilesExports.js +0 -20
- package/dist/esm/node/runtime/page-files/setup.d.ts +0 -1
- package/dist/esm/node/runtime/page-files/setup.js +0 -3
- package/dist/cjs/node/plugin/plugins/{importBuild → buildEntry}/getVikeManifest.js +0 -0
- package/dist/cjs/shared/page-configs/{getConfigValue.js → getConfigValueRuntime.js} +0 -0
- package/dist/esm/node/plugin/plugins/{importBuild → buildEntry}/getVikeManifest.js +0 -0
- package/dist/esm/shared/getPageFiles/{setPageFiles.d.ts → getPageFiles.d.ts} +1 -1
- /package/dist/esm/shared/page-configs/{getConfigValue.d.ts → getConfigValueRuntime.d.ts} +0 -0
- /package/dist/esm/shared/page-configs/{getConfigValue.js → getConfigValueRuntime.js} +0 -0
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
export {
|
|
1
|
+
export { buildEntry };
|
|
2
2
|
export { set_ASSETS_MAP };
|
|
3
3
|
import type { Plugin, Rollup } from 'vite';
|
|
4
4
|
type Bundle = Rollup.OutputBundle;
|
|
5
5
|
type Options = Rollup.NormalizedOutputOptions;
|
|
6
|
-
declare function
|
|
6
|
+
declare function buildEntry(): Plugin[];
|
|
7
7
|
/** Set the value of the ASSETS_MAP constant inside dist/server/entry.js (or dist/server/index.js) */
|
|
8
8
|
declare function set_ASSETS_MAP(options: Options, bundle: Bundle): Promise<void>;
|
|
@@ -1,23 +1,23 @@
|
|
|
1
|
-
export {
|
|
1
|
+
export { buildEntry };
|
|
2
2
|
export { set_ASSETS_MAP };
|
|
3
3
|
import { serverProductionEntryPlugin } from '@brillout/vite-plugin-server-entry/plugin';
|
|
4
|
+
import { virtualFileIdImportUserCodeServer } from '../../../shared/virtual-files/virtualFileImportUserCode.js';
|
|
5
|
+
import { getVikeManifest } from './getVikeManifest.js';
|
|
6
|
+
import { getVikeConfig } from '../importUserCode/v1-design/getVikeConfig.js';
|
|
4
7
|
import { assert, getOutDirs, toPosixPath } from '../../utils.js';
|
|
8
|
+
import fs from 'fs/promises';
|
|
5
9
|
import path from 'path';
|
|
6
10
|
import { createRequire } from 'module';
|
|
7
|
-
import { getVikeManifest } from './getVikeManifest.js';
|
|
8
|
-
import fs from 'fs/promises';
|
|
9
|
-
import { virtualFileIdImportUserCodeServer } from '../../../shared/virtual-files/virtualFileImportUserCode.js';
|
|
10
|
-
import { getVikeConfig } from '../importUserCode/v1-design/getVikeConfig.js';
|
|
11
11
|
// @ts-ignore Shimmed by dist-cjs-fixup.js for CJS build.
|
|
12
12
|
const importMetaUrl = import.meta.url;
|
|
13
13
|
const require_ = createRequire(importMetaUrl);
|
|
14
14
|
const ASSETS_MAP = '__VITE_ASSETS_MAP__';
|
|
15
|
-
function
|
|
15
|
+
function buildEntry() {
|
|
16
16
|
let config;
|
|
17
17
|
let vikeConfigGlobal;
|
|
18
18
|
return [
|
|
19
19
|
{
|
|
20
|
-
name: 'vike:
|
|
20
|
+
name: 'vike:buildEntry',
|
|
21
21
|
enforce: 'post',
|
|
22
22
|
async configResolved(config_) {
|
|
23
23
|
config = config_;
|
|
@@ -38,17 +38,16 @@ function getServerProductionEntryCode(config, vikeConfigGlobal) {
|
|
|
38
38
|
const vikeManifest = getVikeManifest(vikeConfigGlobal, config);
|
|
39
39
|
// Let's eventually simplify and move everything to a single virtual module
|
|
40
40
|
const importerCode = [
|
|
41
|
-
` import {
|
|
41
|
+
` import { setGlobalContext_buildEntry } from '${importPath}';`,
|
|
42
42
|
` import * as pageFiles from '${virtualFileIdImportUserCodeServer}';`,
|
|
43
43
|
` {`,
|
|
44
44
|
// We first set the values to a variable because of a Rollup bug, and this workaround doesn't work: https://github.com/vikejs/vike/commit/d5f3a4f7aae5a8bc44192e6cbb2bcb9007be188d
|
|
45
45
|
` const assetsManifest = ${ASSETS_MAP};`,
|
|
46
46
|
` const pluginManifest = ${JSON.stringify(vikeManifest, null, 2)};`,
|
|
47
|
-
'
|
|
48
|
-
` pageFiles
|
|
49
|
-
`
|
|
50
|
-
|
|
51
|
-
` pluginManifest: () => pluginManifest,`,
|
|
47
|
+
' setGlobalContext_buildEntry({',
|
|
48
|
+
` pageFiles,`,
|
|
49
|
+
` assetsManifest,`,
|
|
50
|
+
` pluginManifest,`,
|
|
52
51
|
' });',
|
|
53
52
|
` }`,
|
|
54
53
|
''
|
|
@@ -85,12 +84,12 @@ function find_ASSETS_MAP(bundle) {
|
|
|
85
84
|
function getImportPath(config) {
|
|
86
85
|
// We resolve filePathAbsolute even if we don't use it: we use require.resolve() as an assertion that the relative path is correct
|
|
87
86
|
const filePathAbsolute = toPosixPath(
|
|
88
|
-
// [RELATIVE_PATH_FROM_DIST] Current file: node_modules/vike/dist/esm/node/plugin/plugins/
|
|
89
|
-
require_.resolve(`../../../../../../dist/esm/
|
|
87
|
+
// [RELATIVE_PATH_FROM_DIST] Current file: node_modules/vike/dist/esm/node/plugin/plugins/buildEntry/index.js
|
|
88
|
+
require_.resolve(`../../../../../../dist/esm/__internal/index.js`));
|
|
90
89
|
if (
|
|
91
|
-
// Let's implement a new config if a user needs the import to be a relative path instead of 'vike/__internal
|
|
90
|
+
// Let's implement a new config if a user needs the import to be a relative path instead of 'vike/__internal' (AFAIK a relative path is needed only if a framework has npm package 'vike' as direct dependency instead of a peer dependency and if the user of that framework uses pnpm)
|
|
92
91
|
true) {
|
|
93
|
-
return 'vike/__internal
|
|
92
|
+
return 'vike/__internal';
|
|
94
93
|
}
|
|
95
94
|
else {
|
|
96
95
|
const { outDirServer } = getOutDirs(config);
|
|
@@ -1,3 +1,9 @@
|
|
|
1
1
|
export { commonConfig };
|
|
2
2
|
import { type Plugin } from 'vite';
|
|
3
|
-
declare
|
|
3
|
+
declare module 'vite' {
|
|
4
|
+
interface UserConfig {
|
|
5
|
+
_isDev?: boolean;
|
|
6
|
+
_vikeVitePluginOptions?: unknown;
|
|
7
|
+
}
|
|
8
|
+
}
|
|
9
|
+
declare function commonConfig(vikeVitePluginOptions: unknown): Plugin[];
|
|
@@ -6,11 +6,11 @@ import { installRequireShim_setUserRootDir } from '@brillout/require-shim';
|
|
|
6
6
|
import pc from '@brillout/picocolors';
|
|
7
7
|
import path from 'path';
|
|
8
8
|
import { assertResolveAlias } from './commonConfig/assertResolveAlias.js';
|
|
9
|
-
import { pluginName } from './commonConfig/pluginName.js';
|
|
10
9
|
import { getEnvVarObject } from '../shared/getEnvVarObject.js';
|
|
11
10
|
import { isViteCliCall } from '../shared/isViteCliCall.js';
|
|
12
11
|
import { isVikeCliOrApi } from '../../api/context.js';
|
|
13
|
-
|
|
12
|
+
const pluginName = 'vike:commonConfig';
|
|
13
|
+
function commonConfig(vikeVitePluginOptions) {
|
|
14
14
|
return [
|
|
15
15
|
{
|
|
16
16
|
name: `${pluginName}:pre`,
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
export { getVirtualFileImportUserCode };
|
|
2
2
|
import type { ResolvedConfig } from 'vite';
|
|
3
|
-
import type { VikeConfigGlobal } from './v1-design/getVikeConfig
|
|
3
|
+
import type { VikeConfigGlobal } from './v1-design/getVikeConfig.js';
|
|
4
4
|
declare function getVirtualFileImportUserCode(id: string, options: {
|
|
5
5
|
ssr?: boolean;
|
|
6
6
|
} | undefined, vikeConfigGlobal: VikeConfigGlobal, config: ResolvedConfig, isDev: boolean): Promise<string>;
|
|
@@ -76,5 +76,5 @@ type ConfigDefinitions = Record<string, // configName
|
|
|
76
76
|
ConfigDefinitionInternal>;
|
|
77
77
|
type ConfigDefinitionsBuiltIn = Record<ConfigNameBuiltIn, ConfigDefinitionInternal>;
|
|
78
78
|
declare const configDefinitionsBuiltIn: ConfigDefinitionsBuiltIn;
|
|
79
|
-
type ConfigNameGlobal = 'onPrerenderStart' | 'onBeforeRoute' | 'prerender' | 'disableAutoFullBuild' | 'includeAssetsImportedByServer' | 'baseAssets' | 'baseServer' | 'redirects' | 'trailingSlash' | 'disableUrlNormalization';
|
|
79
|
+
type ConfigNameGlobal = 'onPrerenderStart' | 'onBeforeRoute' | 'prerender' | 'disableAutoFullBuild' | 'includeAssetsImportedByServer' | 'baseAssets' | 'baseServer' | 'redirects' | 'trailingSlash' | 'disableUrlNormalization' | 'vite';
|
|
80
80
|
declare const configDefinitionsBuiltInGlobal: Record<ConfigNameGlobal, ConfigDefinitionInternal>;
|
|
@@ -143,9 +143,8 @@ const configDefinitionsBuiltInGlobal = {
|
|
|
143
143
|
env: { server: true, client: 'if-client-routing' },
|
|
144
144
|
eager: true
|
|
145
145
|
},
|
|
146
|
-
prerender: {
|
|
147
|
-
|
|
148
|
-
},
|
|
146
|
+
prerender: { env: { config: true } },
|
|
147
|
+
vite: { env: { config: true }, cumulative: true },
|
|
149
148
|
disableAutoFullBuild: { env: { config: true } },
|
|
150
149
|
includeAssetsImportedByServer: { env: { config: true } },
|
|
151
150
|
baseAssets: { env: { config: true } },
|
package/dist/esm/node/plugin/plugins/importUserCode/v1-design/getVikeConfig/crawlPlusFiles.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
export { crawlPlusFiles };
|
|
2
|
-
declare function crawlPlusFiles(userRootDir: string, outDirAbsoluteFilesystem: null | string
|
|
2
|
+
declare function crawlPlusFiles(userRootDir: string, outDirAbsoluteFilesystem: null | string): Promise<{
|
|
3
3
|
filePathAbsoluteUserRootDir: string;
|
|
4
4
|
}[]>;
|
package/dist/esm/node/plugin/plugins/importUserCode/v1-design/getVikeConfig/crawlPlusFiles.js
CHANGED
|
@@ -1,17 +1,16 @@
|
|
|
1
1
|
export { crawlPlusFiles };
|
|
2
|
-
import { assertPosixPath, assert, scriptFileExtensions, assertIsSingleModuleInstance, assertIsNotProductionRuntime, isVersionOrAbove, isScriptFile } from '../../../../utils.js';
|
|
2
|
+
import { assertPosixPath, assert, scriptFileExtensions, assertIsSingleModuleInstance, assertIsNotProductionRuntime, isVersionOrAbove, isScriptFile, scriptFileExtensionList } from '../../../../utils.js';
|
|
3
3
|
import path from 'path';
|
|
4
|
-
import fs from 'fs/promises';
|
|
5
4
|
import glob from 'fast-glob';
|
|
6
5
|
import { exec } from 'child_process';
|
|
7
6
|
import { promisify } from 'util';
|
|
8
7
|
import { isTemporaryBuildFile } from './transpileAndExecuteFile.js';
|
|
8
|
+
import { getEnvVarObject } from '../../../../shared/getEnvVarObject.js';
|
|
9
9
|
const execA = promisify(exec);
|
|
10
|
-
const TOO_MANY_UNTRACKED_FILES = 5;
|
|
11
10
|
assertIsNotProductionRuntime();
|
|
12
11
|
assertIsSingleModuleInstance('crawlPlusFiles.ts');
|
|
13
12
|
let gitIsNotUsable = false;
|
|
14
|
-
async function crawlPlusFiles(userRootDir, outDirAbsoluteFilesystem
|
|
13
|
+
async function crawlPlusFiles(userRootDir, outDirAbsoluteFilesystem) {
|
|
15
14
|
assertPosixPath(userRootDir);
|
|
16
15
|
//*/
|
|
17
16
|
const outDirRelativeFromUserRootDir = null;
|
|
@@ -31,14 +30,13 @@ async function crawlPlusFiles(userRootDir, outDirAbsoluteFilesystem, crawlWithGi
|
|
|
31
30
|
//
|
|
32
31
|
!outDirRelativeFromUserRootDir.startsWith('../')));
|
|
33
32
|
// Crawl
|
|
34
|
-
let files
|
|
35
|
-
const res =
|
|
33
|
+
let files;
|
|
34
|
+
const res = !isGitCrawlDisabled() && (await gitLsFiles(userRootDir, outDirRelativeFromUserRootDir));
|
|
36
35
|
if (res &&
|
|
37
36
|
// 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.)
|
|
38
|
-
res.
|
|
39
|
-
files = res
|
|
37
|
+
res.length > 0) {
|
|
38
|
+
files = res;
|
|
40
39
|
// We cannot find files inside symlink directories with `$ git ls-files` => we use fast-glob
|
|
41
|
-
files.push(...(await crawlSymlinkDirs(res.symlinkDirs, userRootDir, outDirRelativeFromUserRootDir)));
|
|
42
40
|
}
|
|
43
41
|
else {
|
|
44
42
|
files = await fastGlob(userRootDir, outDirRelativeFromUserRootDir);
|
|
@@ -70,24 +68,21 @@ async function gitLsFiles(userRootDir, outDirRelativeFromUserRootDir) {
|
|
|
70
68
|
'git',
|
|
71
69
|
preserveUTF8,
|
|
72
70
|
'ls-files',
|
|
73
|
-
//
|
|
74
|
-
|
|
75
|
-
// - Performance gain seems negligible: https://github.com/vikejs/vike/pull/1688#issuecomment-2166206648
|
|
76
|
-
// ...scriptFileExtensionList.map((ext) => `"**/+*.${ext}"`),
|
|
71
|
+
// Performance gain seems negligible: https://github.com/vikejs/vike/pull/1688#issuecomment-2166206648
|
|
72
|
+
...scriptFileExtensionList.map((ext) => `"**/+*.${ext}"`),
|
|
77
73
|
// Performance gain is non-negligible.
|
|
78
74
|
// - https://github.com/vikejs/vike/pull/1688#issuecomment-2166206648
|
|
79
75
|
// - When node_modules/ is untracked the performance gain could be significant?
|
|
80
76
|
...ignoreAsPatterns.map((pattern) => `--exclude="${pattern}"`),
|
|
81
77
|
// --others --exclude-standard => list untracked files (--others) while using .gitignore (--exclude-standard)
|
|
82
78
|
// --cached => list tracked files
|
|
83
|
-
|
|
84
|
-
'--others --exclude-standard --cached --stage'
|
|
79
|
+
'--others --exclude-standard --cached'
|
|
85
80
|
].join(' ');
|
|
86
|
-
let
|
|
81
|
+
let filesAll;
|
|
87
82
|
let filesDeleted;
|
|
88
83
|
try {
|
|
89
84
|
;
|
|
90
|
-
[
|
|
85
|
+
[filesAll, filesDeleted] = await Promise.all([
|
|
91
86
|
// Main command
|
|
92
87
|
runCmd1(cmd, userRootDir),
|
|
93
88
|
// Get tracked but deleted files
|
|
@@ -101,40 +96,23 @@ async function gitLsFiles(userRootDir, outDirRelativeFromUserRootDir) {
|
|
|
101
96
|
}
|
|
102
97
|
throw err;
|
|
103
98
|
}
|
|
104
|
-
const filePaths = resultLines.map(parseGitLsResultLine);
|
|
105
|
-
// If there are too many files without mode we fallback to fast-glob
|
|
106
|
-
if (filePaths.filter((f) => !f.mode).length > TOO_MANY_UNTRACKED_FILES)
|
|
107
|
-
return null;
|
|
108
|
-
const symlinkDirs = [];
|
|
109
99
|
const files = [];
|
|
110
|
-
for (const
|
|
111
|
-
//
|
|
112
|
-
if (
|
|
100
|
+
for (const filePath of filesAll) {
|
|
101
|
+
// + file?
|
|
102
|
+
if (!path.posix.basename(filePath).startsWith('+'))
|
|
113
103
|
continue;
|
|
114
104
|
// We have to repeat the same exclusion logic here because the option --exclude of `$ git ls-files` only applies to untracked files. (We use --exclude only to speed up the `$ git ls-files` command.)
|
|
115
105
|
if (!ignoreAsFilterFn(filePath))
|
|
116
106
|
continue;
|
|
117
|
-
// Symlink directory?
|
|
118
|
-
{
|
|
119
|
-
const isSymlinkDir = await isSymlinkDirectory(mode, filePath, userRootDir);
|
|
120
|
-
if (isSymlinkDir) {
|
|
121
|
-
symlinkDirs.push(filePath);
|
|
122
|
-
continue;
|
|
123
|
-
}
|
|
124
|
-
// Skip deleted files and non-symlink directories
|
|
125
|
-
if (isSymlinkDir === null) {
|
|
126
|
-
continue;
|
|
127
|
-
}
|
|
128
|
-
}
|
|
129
|
-
// + file?
|
|
130
|
-
if (!path.posix.basename(filePath).startsWith('+'))
|
|
131
|
-
continue;
|
|
132
107
|
// JavaScript file?
|
|
133
108
|
if (!isScriptFile(filePath))
|
|
134
109
|
continue;
|
|
110
|
+
// Deleted?
|
|
111
|
+
if (filesDeleted.includes(filePath))
|
|
112
|
+
continue;
|
|
135
113
|
files.push(filePath);
|
|
136
114
|
}
|
|
137
|
-
return
|
|
115
|
+
return files;
|
|
138
116
|
}
|
|
139
117
|
// Same as gitLsFiles() but using fast-glob
|
|
140
118
|
async function fastGlob(userRootDir, outDirRelativeFromUserRootDir) {
|
|
@@ -204,77 +182,6 @@ async function isGitNotUsable(userRootDir) {
|
|
|
204
182
|
return false;
|
|
205
183
|
}
|
|
206
184
|
}
|
|
207
|
-
async function crawlSymlinkDirs(symlinkDirs, userRootDir, outDirRelativeFromUserRootDir) {
|
|
208
|
-
const filesInSymlinkDirs = (await Promise.all(symlinkDirs.map(async (symlinkDir) => (await fastGlob(path.posix.join(userRootDir, symlinkDir), outDirRelativeFromUserRootDir)).map((filePath) => path.posix.join(symlinkDir, filePath))))).flat();
|
|
209
|
-
return filesInSymlinkDirs;
|
|
210
|
-
}
|
|
211
|
-
// Parse:
|
|
212
|
-
// ```
|
|
213
|
-
// some/not/tracked/path
|
|
214
|
-
// 100644 f6928073402b241b468b199893ff6f4aed0b7195 0\tpages/index/+Page.tsx
|
|
215
|
-
// ```
|
|
216
|
-
function parseGitLsResultLine(resultLine) {
|
|
217
|
-
const [part1, part2, ...rest] = resultLine.split('\t');
|
|
218
|
-
assert(part1);
|
|
219
|
-
assert(rest.length === 0);
|
|
220
|
-
// Git doesn't provide the mode for untracked paths.
|
|
221
|
-
// `resultLine` is:
|
|
222
|
-
// ```
|
|
223
|
-
// some/not/tracked/path
|
|
224
|
-
// ```
|
|
225
|
-
if (part2 === undefined) {
|
|
226
|
-
return { filePath: part1, mode: null };
|
|
227
|
-
}
|
|
228
|
-
assert(part2);
|
|
229
|
-
// `resultLine` is:
|
|
230
|
-
// ```
|
|
231
|
-
// 100644 f6928073402b241b468b199893ff6f4aed0b7195 0\tpages/index/+Page.tsx
|
|
232
|
-
// ```
|
|
233
|
-
const [mode, _, __, ...rest2] = part1.split(' ');
|
|
234
|
-
assert(mode && _ && __ && rest2.length === 0);
|
|
235
|
-
return { filePath: part2, mode };
|
|
236
|
-
}
|
|
237
|
-
async function isSymlinkDirectory(mode, filePath, userRootDir) {
|
|
238
|
-
const filePathAbsolute = path.posix.join(userRootDir, filePath);
|
|
239
|
-
let stats = null;
|
|
240
|
-
let isSymlink = false;
|
|
241
|
-
if (mode === '120000') {
|
|
242
|
-
isSymlink = true;
|
|
243
|
-
}
|
|
244
|
-
else if (mode === null) {
|
|
245
|
-
// `$ git ls-files` doesn't provide the mode when Git doesn't track the path
|
|
246
|
-
stats = await getFileStats(filePathAbsolute);
|
|
247
|
-
if (stats === null)
|
|
248
|
-
return null;
|
|
249
|
-
isSymlink = stats.isSymbolicLink();
|
|
250
|
-
if (!isSymlink && stats.isDirectory())
|
|
251
|
-
return null;
|
|
252
|
-
}
|
|
253
|
-
else {
|
|
254
|
-
assert(mode);
|
|
255
|
-
}
|
|
256
|
-
if (!isSymlink)
|
|
257
|
-
return false;
|
|
258
|
-
if (!stats)
|
|
259
|
-
stats = await getFileStats(filePathAbsolute);
|
|
260
|
-
if (stats === null)
|
|
261
|
-
return null;
|
|
262
|
-
const isDirectory = stats.isDirectory();
|
|
263
|
-
return isDirectory;
|
|
264
|
-
}
|
|
265
|
-
async function getFileStats(filePathAbsolute) {
|
|
266
|
-
let stats;
|
|
267
|
-
try {
|
|
268
|
-
stats = await fs.lstat(filePathAbsolute);
|
|
269
|
-
}
|
|
270
|
-
catch (err) {
|
|
271
|
-
// File was deleted, usually a temporary file such as +config.js.build-j95xb988fpln.mjs
|
|
272
|
-
// ENOENT: no such file or directory
|
|
273
|
-
assert(err.code === 'ENOENT');
|
|
274
|
-
return null;
|
|
275
|
-
}
|
|
276
|
-
return stats;
|
|
277
|
-
}
|
|
278
185
|
async function runCmd1(cmd, cwd) {
|
|
279
186
|
const { stdout } = await execA(cmd, {
|
|
280
187
|
cwd,
|
|
@@ -299,3 +206,7 @@ async function runCmd2(cmd, cwd) {
|
|
|
299
206
|
stderr = stderr.toString().trim();
|
|
300
207
|
return { stdout, stderr };
|
|
301
208
|
}
|
|
209
|
+
function isGitCrawlDisabled() {
|
|
210
|
+
const crawSettings = getEnvVarObject('VIKE_CRAWL');
|
|
211
|
+
return crawSettings?.git === false;
|
|
212
|
+
}
|
|
@@ -8,11 +8,13 @@ export { getConfigValueInterfaceFile };
|
|
|
8
8
|
export type { VikeConfigObject };
|
|
9
9
|
export type { InterfaceValueFile };
|
|
10
10
|
export type { InterfaceFile };
|
|
11
|
+
export type { VikeConfigGlobal };
|
|
12
|
+
export type { VikeVitePluginOptions };
|
|
11
13
|
import type { PageConfigGlobalBuildTime, PageConfigBuildTime } from '../../../../../shared/page-configs/PageConfig.js';
|
|
12
14
|
import { type LocationId } from './getVikeConfig/filesystemRouting.js';
|
|
13
15
|
import type { ResolvedConfig } from 'vite';
|
|
14
16
|
import type { FilePathResolved } from '../../../../../shared/page-configs/FilePath.js';
|
|
15
|
-
import
|
|
17
|
+
import { getPageConfigUserFriendlyNew } from '../../../../../shared/page-configs/getPageConfigUserFriendly.js';
|
|
16
18
|
type InterfaceFile = InterfaceConfigFile | InterfaceValueFile;
|
|
17
19
|
type InterfaceFileCommons = {
|
|
18
20
|
locationId: LocationId;
|
|
@@ -37,6 +39,9 @@ type VikeConfigObject = {
|
|
|
37
39
|
pageConfigs: PageConfigBuildTime[];
|
|
38
40
|
pageConfigGlobal: PageConfigGlobalBuildTime;
|
|
39
41
|
vikeConfigGlobal: VikeConfigGlobal;
|
|
42
|
+
vikeConfigNew: {
|
|
43
|
+
global: ReturnType<typeof getPageConfigUserFriendlyNew>;
|
|
44
|
+
};
|
|
40
45
|
};
|
|
41
46
|
declare const vikeConfigDependencies: Set<string>;
|
|
42
47
|
declare function reloadVikeConfig(config: ResolvedConfig): void;
|
|
@@ -47,3 +52,96 @@ declare function getVikeConfig2(userRootDir: string, isDev: boolean, vikeVitePlu
|
|
|
47
52
|
declare function isV1Design(config: ResolvedConfig): Promise<boolean>;
|
|
48
53
|
declare function isVikeConfigFile(filePath: string): boolean;
|
|
49
54
|
declare function getConfigValueInterfaceFile(interfaceFile: InterfaceFile, configName: string): unknown;
|
|
55
|
+
type VikeConfigGlobal = {
|
|
56
|
+
prerender: false | {
|
|
57
|
+
noExtraDir: boolean;
|
|
58
|
+
parallel: boolean | number;
|
|
59
|
+
partial: boolean;
|
|
60
|
+
disableAutoRun: boolean;
|
|
61
|
+
};
|
|
62
|
+
disableAutoFullBuild: boolean | 'prerender' | null;
|
|
63
|
+
includeAssetsImportedByServer: boolean;
|
|
64
|
+
baseAssets: string | null;
|
|
65
|
+
baseServer: string | null;
|
|
66
|
+
redirects: Record<string, string>;
|
|
67
|
+
trailingSlash: boolean;
|
|
68
|
+
disableUrlNormalization: boolean;
|
|
69
|
+
};
|
|
70
|
+
type VikeVitePluginOptions = {
|
|
71
|
+
/**
|
|
72
|
+
* Enable pre-rendering.
|
|
73
|
+
*
|
|
74
|
+
* https://vike.dev/pre-rendering
|
|
75
|
+
*
|
|
76
|
+
* @default false
|
|
77
|
+
*/
|
|
78
|
+
prerender?: boolean | {
|
|
79
|
+
/**
|
|
80
|
+
* Don't create a new directory for each HTML file.
|
|
81
|
+
*
|
|
82
|
+
* For example, generate `dist/client/about.html` instead of `dist/client/about/index.html`.
|
|
83
|
+
*
|
|
84
|
+
* @default false
|
|
85
|
+
*/
|
|
86
|
+
noExtraDir?: boolean;
|
|
87
|
+
/**
|
|
88
|
+
* Number of concurrent pre-render jobs.
|
|
89
|
+
*
|
|
90
|
+
* Set to `false` to disable concurrency.
|
|
91
|
+
*
|
|
92
|
+
* @default os.cpus().length
|
|
93
|
+
*/
|
|
94
|
+
parallel?: boolean | number;
|
|
95
|
+
/**
|
|
96
|
+
* Allow only some of your pages to be pre-rendered.
|
|
97
|
+
*
|
|
98
|
+
* This setting doesn't affect the pre-rendering process: it merely suppresses the warnings when some of your pages cannot be pre-rendered.
|
|
99
|
+
|
|
100
|
+
* @default false
|
|
101
|
+
*/
|
|
102
|
+
partial?: boolean;
|
|
103
|
+
/**
|
|
104
|
+
* Disable the automatic initiation of the pre-rendering process when running `$ vike build`.
|
|
105
|
+
*
|
|
106
|
+
* Use this if you want to programmatically initiate the pre-rendering process instead.
|
|
107
|
+
*
|
|
108
|
+
* https://vike.dev/api#prerender
|
|
109
|
+
*
|
|
110
|
+
* @default false
|
|
111
|
+
*/
|
|
112
|
+
disableAutoRun?: boolean;
|
|
113
|
+
};
|
|
114
|
+
/** @deprecated See https://vike.dev/disableAutoFullBuild */
|
|
115
|
+
disableAutoFullBuild?: boolean | 'prerender';
|
|
116
|
+
/** The Base URL of your server.
|
|
117
|
+
*
|
|
118
|
+
* https://vike.dev/base-url
|
|
119
|
+
*/
|
|
120
|
+
baseServer?: string;
|
|
121
|
+
/** The Base URL of your static assets.
|
|
122
|
+
*
|
|
123
|
+
* https://vike.dev/base-url
|
|
124
|
+
*/
|
|
125
|
+
baseAssets?: string;
|
|
126
|
+
/** @deprecated It's now `true` by default. You can remove this option. */
|
|
127
|
+
includeAssetsImportedByServer?: boolean;
|
|
128
|
+
/** Permanent redirections (HTTP status code 301)
|
|
129
|
+
*
|
|
130
|
+
* https://vike.dev/redirects
|
|
131
|
+
*/
|
|
132
|
+
redirects?: Record<string, string>;
|
|
133
|
+
/** Whether URLs should end with a trailing slash.
|
|
134
|
+
*
|
|
135
|
+
* https://vike.dev/url-normalization
|
|
136
|
+
*
|
|
137
|
+
* @default false
|
|
138
|
+
*/
|
|
139
|
+
trailingSlash?: boolean;
|
|
140
|
+
/** Disable automatic URL normalization.
|
|
141
|
+
*
|
|
142
|
+
* https://vike.dev/url-normalization
|
|
143
|
+
*
|
|
144
|
+
* @default false
|
|
145
|
+
*/
|
|
146
|
+
disableUrlNormalization?: boolean;
|
|
147
|
+
};
|