vike 0.4.237-commit-85e89b1 → 0.4.237-commit-e549c30
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/runtime/html/injectAssets/getHtmlTags.js +1 -1
- package/dist/cjs/node/runtime/renderPage.js +12 -7
- package/dist/cjs/node/runtime/utils.js +1 -1
- package/dist/cjs/node/vite/plugins/pluginBuild/handleAssetsManifest.js +12 -11
- package/dist/cjs/node/vite/plugins/pluginBuild/pluginAutoFullBuild.js +8 -7
- package/dist/cjs/node/vite/plugins/pluginBuild/pluginBuildConfig.js +5 -5
- package/dist/cjs/node/vite/plugins/pluginBuild/pluginBuildEntry.js +1 -1
- package/dist/cjs/node/vite/plugins/pluginBuild/pluginDistPackageJsonFile.js +2 -2
- package/dist/cjs/node/vite/plugins/pluginBuild/pluginModuleBanner.js +2 -2
- package/dist/cjs/node/vite/plugins/pluginDev/determineFsAllowList.js +2 -2
- package/dist/cjs/node/vite/plugins/pluginEnvVars.js +2 -2
- package/dist/cjs/node/vite/plugins/pluginExtractAssets.js +3 -3
- package/dist/cjs/node/vite/plugins/pluginExtractExportNames.js +2 -2
- package/dist/cjs/node/vite/plugins/pluginNonRunnableDev.js +1 -1
- package/dist/cjs/node/vite/plugins/pluginReplaceConstants.js +2 -2
- package/dist/cjs/node/vite/plugins/pluginVirtualFiles/generateVirtualFileGlobalEntryWithOldDesign.js +2 -2
- package/dist/cjs/node/vite/shared/getClientEntrySrcDev.js +1 -1
- package/dist/cjs/node/vite/shared/getHttpRequestAsyncStore.js +8 -6
- package/dist/cjs/node/vite/shared/getOutDirs.js +9 -6
- package/dist/cjs/node/vite/shared/{isViteServerBuild.js → isViteServerSide.js} +18 -16
- package/dist/cjs/node/vite/shared/loggerVite/removeSuperfluousViteLog.js +6 -4
- package/dist/cjs/node/vite/shared/resolveVikeConfigInternal/crawlPlusFiles.js +5 -4
- package/dist/cjs/node/vite/shared/resolveVikeConfigInternal.js +42 -44
- package/dist/cjs/types/VikeGlobalInternal.js +2 -0
- package/dist/cjs/utils/PROJECT_VERSION.js +1 -1
- package/dist/cjs/utils/assertVersion.js +2 -0
- package/dist/cjs/utils/debug.js +4 -4
- package/dist/cjs/utils/getGlobalObject.js +8 -15
- package/dist/cjs/utils/isScriptFile.js +1 -1
- package/dist/cjs/utils/path.js +5 -5
- package/dist/cjs/utils/requireResolve.js +13 -12
- package/dist/esm/client/runtime-client-routing/renderPageClientSide.d.ts +2 -3
- package/dist/esm/node/runtime/html/injectAssets/getHtmlTags.js +1 -1
- package/dist/esm/node/runtime/renderPage.d.ts +7 -4
- package/dist/esm/node/runtime/renderPage.js +12 -7
- package/dist/esm/node/runtime/utils.d.ts +1 -1
- package/dist/esm/node/runtime/utils.js +1 -1
- package/dist/esm/node/vite/plugins/pluginBuild/handleAssetsManifest.js +13 -12
- package/dist/esm/node/vite/plugins/pluginBuild/pluginAutoFullBuild.js +9 -8
- package/dist/esm/node/vite/plugins/pluginBuild/pluginBuildConfig.js +6 -6
- package/dist/esm/node/vite/plugins/pluginBuild/pluginBuildEntry.js +2 -2
- package/dist/esm/node/vite/plugins/pluginBuild/pluginDistPackageJsonFile.js +2 -2
- package/dist/esm/node/vite/plugins/pluginBuild/pluginModuleBanner.js +2 -2
- package/dist/esm/node/vite/plugins/pluginDev/determineFsAllowList.js +3 -3
- package/dist/esm/node/vite/plugins/pluginEnvVars.js +2 -2
- package/dist/esm/node/vite/plugins/pluginExtractAssets.js +3 -3
- package/dist/esm/node/vite/plugins/pluginExtractExportNames.js +2 -2
- package/dist/esm/node/vite/plugins/pluginNonRunnableDev.js +2 -2
- package/dist/esm/node/vite/plugins/pluginReplaceConstants.js +2 -2
- package/dist/esm/node/vite/plugins/pluginVirtualFiles/generateVirtualFileGlobalEntryWithOldDesign.js +2 -2
- package/dist/esm/node/vite/shared/getClientEntrySrcDev.js +2 -2
- package/dist/esm/node/vite/shared/getHttpRequestAsyncStore.js +9 -7
- package/dist/esm/node/vite/shared/getOutDirs.d.ts +1 -1
- package/dist/esm/node/vite/shared/getOutDirs.js +9 -6
- package/dist/esm/node/vite/shared/isViteServerSide.d.ts +18 -0
- package/dist/esm/node/vite/shared/{isViteServerBuild.js → isViteServerSide.js} +18 -17
- package/dist/esm/node/vite/shared/loggerVite/removeSuperfluousViteLog.js +7 -5
- package/dist/esm/node/vite/shared/resolveVikeConfigInternal/crawlPlusFiles.js +6 -5
- package/dist/esm/node/vite/shared/resolveVikeConfigInternal.js +43 -45
- package/dist/esm/types/VikeGlobalInternal.d.ts +4 -0
- package/dist/esm/types/VikeGlobalInternal.js +1 -0
- package/dist/esm/utils/PROJECT_VERSION.d.ts +1 -1
- package/dist/esm/utils/PROJECT_VERSION.js +1 -1
- package/dist/esm/utils/assertVersion.js +2 -0
- package/dist/esm/utils/debug.js +3 -3
- package/dist/esm/utils/getGlobalObject.d.ts +6 -5
- package/dist/esm/utils/getGlobalObject.js +8 -15
- package/dist/esm/utils/isScriptFile.d.ts +1 -1
- package/dist/esm/utils/isScriptFile.js +1 -1
- package/dist/esm/utils/path.d.ts +2 -0
- package/dist/esm/utils/path.js +5 -5
- package/dist/esm/utils/requireResolve.d.ts +4 -4
- package/dist/esm/utils/requireResolve.js +13 -12
- package/package.json +1 -1
- package/dist/esm/node/vite/shared/isViteServerBuild.d.ts +0 -18
- /package/dist/cjs/utils/{getTerminWidth.js → getTerminalWidth.js} +0 -0
- /package/dist/esm/utils/{getTerminWidth.d.ts → getTerminalWidth.d.ts} +0 -0
- /package/dist/esm/utils/{getTerminWidth.js → getTerminalWidth.js} +0 -0
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
export { pluginBuildConfig };
|
|
2
2
|
export { assertRollupInput };
|
|
3
3
|
export { analyzeClientEntries };
|
|
4
|
-
import { assert, addOnBeforeLogHook, removeFileExtension, unique, assertUsage, injectRollupInputs, normalizeRollupInput, onSetupBuild, assertIsImportPathNpmPackage,
|
|
4
|
+
import { assert, addOnBeforeLogHook, removeFileExtension, unique, assertUsage, injectRollupInputs, normalizeRollupInput, onSetupBuild, assertIsImportPathNpmPackage, requireResolveDistFile, } from '../../utils.js';
|
|
5
5
|
import { getVikeConfigInternal } from '../../shared/resolveVikeConfigInternal.js';
|
|
6
6
|
import { findPageFiles } from '../../shared/findPageFiles.js';
|
|
7
7
|
import { generateVirtualFileId } from '../../../shared/virtualFileId.js';
|
|
@@ -9,7 +9,7 @@ import { extractAssetsAddQuery } from '../../../shared/extractAssetsQuery.js';
|
|
|
9
9
|
import { prependEntriesDir } from '../../../shared/prependEntriesDir.js';
|
|
10
10
|
import { getFilePathResolved } from '../../shared/getFilePath.js';
|
|
11
11
|
import { getConfigValueBuildTime } from '../../../../shared/page-configs/getConfigValueBuildTime.js';
|
|
12
|
-
import {
|
|
12
|
+
import { isViteServerSide_withoutEnv } from '../../shared/isViteServerSide.js';
|
|
13
13
|
import { resolveOutDir_configEnvironment } from '../../shared/getOutDirs.js';
|
|
14
14
|
import { handleAssetsManifest_assertUsageCssCodeSplit, handleAssetsManifest_getBuildConfig, } from './handleAssetsManifest.js';
|
|
15
15
|
import { resolveIncludeAssetsImportedByServer } from '../../../runtime/renderPage/getPageAssets/retrievePageAssetsProd.js';
|
|
@@ -66,7 +66,7 @@ async function getEntries(config) {
|
|
|
66
66
|
// TO-DO/next-major-release: remove
|
|
67
67
|
const pageFileEntries = await getPageFileEntries(config, resolveIncludeAssetsImportedByServer(vikeConfig.config));
|
|
68
68
|
assertUsage(Object.keys(pageFileEntries).length !== 0 || pageConfigs.length !== 0, 'At least one page should be defined, see https://vike.dev/add');
|
|
69
|
-
if (
|
|
69
|
+
if (isViteServerSide_withoutEnv(config)) {
|
|
70
70
|
const pageEntries = getPageEntries(pageConfigs);
|
|
71
71
|
const entries = {
|
|
72
72
|
...pageFileEntries,
|
|
@@ -85,8 +85,8 @@ async function getEntries(config) {
|
|
|
85
85
|
...clientEntries,
|
|
86
86
|
...pageFileEntries,
|
|
87
87
|
};
|
|
88
|
-
const clientRoutingEntry =
|
|
89
|
-
const serverRoutingEntry =
|
|
88
|
+
const clientRoutingEntry = requireResolveDistFile('dist/esm/client/runtime-client-routing/entry.js');
|
|
89
|
+
const serverRoutingEntry = requireResolveDistFile('dist/esm/client/runtime-server-routing/entry.js');
|
|
90
90
|
if (hasClientRouting) {
|
|
91
91
|
entries['entries/entry-client-routing'] = clientRoutingEntry;
|
|
92
92
|
}
|
|
@@ -139,7 +139,7 @@ function analyzeClientEntries(pageConfigs, config) {
|
|
|
139
139
|
// Ensure Rollup creates entries for each page file, see https://github.com/vikejs/vike/issues/350
|
|
140
140
|
// (Otherwise the page files may be missing in the client manifest.json)
|
|
141
141
|
async function getPageFileEntries(config, includeAssetsImportedByServer) {
|
|
142
|
-
const isForClientSide = !
|
|
142
|
+
const isForClientSide = !isViteServerSide_withoutEnv(config);
|
|
143
143
|
const fileTypes = isForClientSide ? ['.page', '.page.client'] : ['.page', '.page.server'];
|
|
144
144
|
if (isForClientSide && includeAssetsImportedByServer) {
|
|
145
145
|
fileTypes.push('.page.server');
|
|
@@ -2,7 +2,7 @@ export { pluginBuildEntry };
|
|
|
2
2
|
export { set_macro_ASSETS_MANIFEST };
|
|
3
3
|
import { serverProductionEntryPlugin } from '@brillout/vite-plugin-server-entry/plugin';
|
|
4
4
|
import { virtualFileIdGlobalEntryServer } from '../../../shared/virtualFileId.js';
|
|
5
|
-
import { assert, PROJECT_VERSION,
|
|
5
|
+
import { assert, PROJECT_VERSION, requireResolveDistFile } from '../../utils.js';
|
|
6
6
|
import fs from 'node:fs/promises';
|
|
7
7
|
import path from 'node:path';
|
|
8
8
|
import { isUsingClientRouter } from '../pluginExtractExportNames.js';
|
|
@@ -90,7 +90,7 @@ function find_ASSETS_MANIFEST(bundle) {
|
|
|
90
90
|
}
|
|
91
91
|
function getImportPath(config) {
|
|
92
92
|
// We resolve filePathAbsolute even if we don't use it: we use require.resolve() as an assertion that the relative path is correct
|
|
93
|
-
const filePathAbsolute =
|
|
93
|
+
const filePathAbsolute = requireResolveDistFile('dist/esm/__internal/index.js');
|
|
94
94
|
if (
|
|
95
95
|
// 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)
|
|
96
96
|
true) {
|
|
@@ -8,7 +8,7 @@
|
|
|
8
8
|
*/
|
|
9
9
|
export { pluginDistPackageJsonFile };
|
|
10
10
|
import { rollupIsEsm } from '../../shared/rollupIsEsm.js';
|
|
11
|
-
import {
|
|
11
|
+
import { isViteServerSide } from '../../shared/isViteServerSide.js';
|
|
12
12
|
function pluginDistPackageJsonFile() {
|
|
13
13
|
let config;
|
|
14
14
|
return {
|
|
@@ -18,7 +18,7 @@ function pluginDistPackageJsonFile() {
|
|
|
18
18
|
config = config_;
|
|
19
19
|
},
|
|
20
20
|
generateBundle(options, bundle) {
|
|
21
|
-
if (!
|
|
21
|
+
if (!isViteServerSide(config, this.environment))
|
|
22
22
|
return;
|
|
23
23
|
const isEsm = rollupIsEsm(options);
|
|
24
24
|
const fileName = 'package.json';
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
export { pluginModuleBanner };
|
|
2
2
|
import { removeVirtualFileIdPrefix } from '../../utils.js';
|
|
3
3
|
import { getMagicString } from '../../shared/getMagicString.js';
|
|
4
|
-
import {
|
|
4
|
+
import { isViteServerSide_extraSafe } from '../../shared/isViteServerSide.js';
|
|
5
5
|
// Rollup's banner feature doesn't work with Vite: https://github.com/vitejs/vite/issues/8412
|
|
6
6
|
// But, anyways, we want to prepend the banner at the beginning of each module, not at the beginning of each file (I believe that's what Rollup's banner feature does).
|
|
7
7
|
function pluginModuleBanner() {
|
|
@@ -16,7 +16,7 @@ function pluginModuleBanner() {
|
|
|
16
16
|
transform: {
|
|
17
17
|
order: 'post',
|
|
18
18
|
handler(code, id, options) {
|
|
19
|
-
if (!
|
|
19
|
+
if (!isViteServerSide_extraSafe(config, options, this.environment) &&
|
|
20
20
|
// Inject module banners if user sets `build.minify` to `false` for inspecting dist/client/
|
|
21
21
|
config.build.minify) {
|
|
22
22
|
return;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
export { determineFsAllowList };
|
|
2
2
|
import { searchForWorkspaceRoot } from 'vite';
|
|
3
3
|
import path from 'node:path';
|
|
4
|
-
import { assert, assertPosixPath,
|
|
4
|
+
import { assert, assertPosixPath, getPackageNodeModulesDirectory } from '../../utils.js';
|
|
5
5
|
import { fileURLToPath } from 'node:url';
|
|
6
6
|
// @ts-ignore import.meta.url is shimmed at dist/cjs by dist-cjs-fixup.js.
|
|
7
7
|
const importMetaUrl = import.meta.url;
|
|
@@ -18,6 +18,6 @@ async function determineFsAllowList(config) {
|
|
|
18
18
|
// We add it again just to be sure.
|
|
19
19
|
fsAllow.push(searchForWorkspaceRoot(process.cwd()));
|
|
20
20
|
// Add node_modules/vike/
|
|
21
|
-
const
|
|
22
|
-
fsAllow.push(
|
|
21
|
+
const packageNodeModulesDirectory = getPackageNodeModulesDirectory();
|
|
22
|
+
fsAllow.push(packageNodeModulesDirectory);
|
|
23
23
|
}
|
|
@@ -3,7 +3,7 @@ import { loadEnv } from 'vite';
|
|
|
3
3
|
import { assert, assertPosixPath, assertUsage, assertWarning, escapeRegex, isArray, isNotNullish, lowerFirst, } from '../utils.js';
|
|
4
4
|
import { getModuleFilePathAbsolute } from '../shared/getFilePath.js';
|
|
5
5
|
import { normalizeId } from '../shared/normalizeId.js';
|
|
6
|
-
import {
|
|
6
|
+
import { isViteServerSide_extraSafe } from '../shared/isViteServerSide.js';
|
|
7
7
|
import { getMagicString } from '../shared/getMagicString.js';
|
|
8
8
|
// TO-DO/eventually:
|
|
9
9
|
// - Make import.meta.env work inside +config.js
|
|
@@ -36,7 +36,7 @@ function pluginEnvVars() {
|
|
|
36
36
|
if (!code.includes('import.meta.env.'))
|
|
37
37
|
return;
|
|
38
38
|
const isBuild = config.command === 'build';
|
|
39
|
-
const isClientSide = !
|
|
39
|
+
const isClientSide = !isViteServerSide_extraSafe(config, options, this.environment);
|
|
40
40
|
const { magicString, getMagicStringResult } = getMagicString(code, id);
|
|
41
41
|
// Find & check
|
|
42
42
|
const replacements = Object.entries(envsAll)
|
|
@@ -15,7 +15,7 @@ import { handleAssetsManifest_isFixEnabled } from './pluginBuild/handleAssetsMan
|
|
|
15
15
|
import { getVikeConfigInternal } from '../shared/resolveVikeConfigInternal.js';
|
|
16
16
|
import { assertV1Design } from '../../shared/assertV1Design.js';
|
|
17
17
|
import { normalizeId } from '../shared/normalizeId.js';
|
|
18
|
-
import {
|
|
18
|
+
import { isViteServerSide_extraSafe } from '../shared/isViteServerSide.js';
|
|
19
19
|
import { resolveIncludeAssetsImportedByServer } from '../../runtime/renderPage/getPageAssets/retrievePageAssetsProd.js';
|
|
20
20
|
const extractAssetsRE = /(\?|&)extractAssets(?:&|$)/;
|
|
21
21
|
const rawRE = /(\?|&)raw(?:&|$)/;
|
|
@@ -45,7 +45,7 @@ function pluginExtractAssets() {
|
|
|
45
45
|
}
|
|
46
46
|
const includeAssetsImportedByServer = resolveIncludeAssetsImportedByServer(vikeConfig.config);
|
|
47
47
|
assert(includeAssetsImportedByServer);
|
|
48
|
-
assert(!
|
|
48
|
+
assert(!isViteServerSide_extraSafe(config, options, this.environment));
|
|
49
49
|
const importStatements = await getImportStatements(src);
|
|
50
50
|
const moduleNames = getImportedModules(importStatements);
|
|
51
51
|
const code = moduleNames.map((moduleName) => `import '${moduleName}';`).join('\n');
|
|
@@ -62,7 +62,7 @@ function pluginExtractAssets() {
|
|
|
62
62
|
// - Vite's `vite:resolve` plugin; https://github.com/vitejs/vite/blob/d649daba7682791178b711d9a3e44a6b5d00990c/packages/vite/src/node/plugins/resolve.ts#L105
|
|
63
63
|
enforce: 'pre',
|
|
64
64
|
async resolveId(source, importer, options) {
|
|
65
|
-
if (
|
|
65
|
+
if (isViteServerSide_extraSafe(config, options, this.environment)) {
|
|
66
66
|
// When building for the server, there should never be a `?extractAssets` query
|
|
67
67
|
assert(!extractAssetsRE.test(source));
|
|
68
68
|
assert(importer === undefined || !extractAssetsRE.test(importer));
|
|
@@ -4,7 +4,7 @@ export { extractExportNamesRE };
|
|
|
4
4
|
import { assert, getFileExtension, createDebugger, getGlobalObject, assertUsage, rollupSourceMapRemove, } from '../utils.js';
|
|
5
5
|
import { getExportNames } from '../shared/parseEsModule.js';
|
|
6
6
|
import { normalizeId } from '../shared/normalizeId.js';
|
|
7
|
-
import {
|
|
7
|
+
import { isViteServerSide_extraSafe } from '../shared/isViteServerSide.js';
|
|
8
8
|
const extractExportNamesRE = /(\?|&)extractExportNames(?:&|$)/;
|
|
9
9
|
const debug = createDebugger('vike:pluginExtractExportNames');
|
|
10
10
|
const globalObject = getGlobalObject('plugins/pluginExtractExportNames.ts', {});
|
|
@@ -16,7 +16,7 @@ function pluginExtractExportNames() {
|
|
|
16
16
|
enforce: 'post',
|
|
17
17
|
async transform(src, id, options) {
|
|
18
18
|
id = normalizeId(id);
|
|
19
|
-
const isClientSide = !
|
|
19
|
+
const isClientSide = !isViteServerSide_extraSafe(config, options, this.environment);
|
|
20
20
|
if (extractExportNamesRE.test(id)) {
|
|
21
21
|
const code = await getExtractExportNamesCode(src, isClientSide, !isDev, id);
|
|
22
22
|
debug('id ' + id, ['result:\n' + code.code.trim(), 'src:\n' + src.trim()]);
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
export { pluginNonRunnableDev };
|
|
2
|
-
import { createViteRPC, assertIsNotProductionRuntime,
|
|
2
|
+
import { createViteRPC, assertIsNotProductionRuntime, requireResolveDistFile, isRunnableDevEnvironment, } from '../utils.js';
|
|
3
3
|
import { retrievePageAssetsDev } from '../../runtime/renderPage/getPageAssets/retrievePageAssetsDev.js';
|
|
4
4
|
import { getViteConfigRuntime } from '../shared/getViteConfigRuntime.js';
|
|
5
5
|
import { getMagicString } from '../shared/getMagicString.js';
|
|
@@ -18,7 +18,7 @@ function getViteRpcFunctions(viteDevServer) {
|
|
|
18
18
|
};
|
|
19
19
|
}
|
|
20
20
|
function pluginNonRunnableDev() {
|
|
21
|
-
const runtimeGlobalContextFilePath =
|
|
21
|
+
const runtimeGlobalContextFilePath = requireResolveDistFile('dist/esm/node/runtime/globalContext.js');
|
|
22
22
|
let config;
|
|
23
23
|
return {
|
|
24
24
|
name: 'vike:pluginNonRunnableDev',
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
export { pluginReplaceConstants };
|
|
2
2
|
import { assert, assertPosixPath } from '../utils.js';
|
|
3
3
|
import { normalizeId } from '../shared/normalizeId.js';
|
|
4
|
-
import {
|
|
4
|
+
import { isViteServerSide_extraSafe } from '../shared/isViteServerSide.js';
|
|
5
5
|
import { getMagicString } from '../shared/getMagicString.js';
|
|
6
6
|
function pluginReplaceConstants() {
|
|
7
7
|
let config;
|
|
@@ -33,7 +33,7 @@ function pluginReplaceConstants() {
|
|
|
33
33
|
const constantsMap = [];
|
|
34
34
|
constantsMap.push({
|
|
35
35
|
constants: ['pageContext.isClientSide', 'globalContext.isClientSide', 'pageContext.globalContext.isClientSide'],
|
|
36
|
-
replacement: !
|
|
36
|
+
replacement: !isViteServerSide_extraSafe(config, options, this.environment),
|
|
37
37
|
});
|
|
38
38
|
constantsMap.forEach(({ constants, replacement }) => {
|
|
39
39
|
if (!constants.some((c) => code.includes(c)))
|
package/dist/esm/node/vite/plugins/pluginVirtualFiles/generateVirtualFileGlobalEntryWithOldDesign.js
CHANGED
|
@@ -7,13 +7,13 @@ import path from 'node:path';
|
|
|
7
7
|
import { generateVirtualFileGlobalEntry } from './generateVirtualFileGlobalEntry.js';
|
|
8
8
|
import { getVikeConfigInternal, isV1Design as isV1Design_ } from '../../shared/resolveVikeConfigInternal.js';
|
|
9
9
|
import { getOutDirs } from '../../shared/getOutDirs.js';
|
|
10
|
-
import {
|
|
10
|
+
import { isViteServerSide_extraSafe } from '../../shared/isViteServerSide.js';
|
|
11
11
|
import { resolveIncludeAssetsImportedByServer } from '../../../runtime/renderPage/getPageAssets/retrievePageAssetsProd.js';
|
|
12
12
|
async function generateVirtualFileGlobalEntryWithOldDesign(id, options, config, env, isDev) {
|
|
13
13
|
const idParsed = parseVirtualFileId(id);
|
|
14
14
|
assert(idParsed && idParsed.type === 'global-entry');
|
|
15
15
|
const { isForClientSide, isClientRouting } = idParsed;
|
|
16
|
-
assert(isForClientSide === !
|
|
16
|
+
assert(isForClientSide === !isViteServerSide_extraSafe(config, options, env));
|
|
17
17
|
const code = await getCode(config, isForClientSide, isClientRouting, isDev, id);
|
|
18
18
|
return code;
|
|
19
19
|
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
export { getClientEntrySrcDev };
|
|
2
|
-
import { assert, assertPosixPath, toPosixPath, pathJoin, assertIsImportPathNpmPackage, assertIsNotProductionRuntime, requireResolveNpmPackage,
|
|
2
|
+
import { assert, assertPosixPath, toPosixPath, pathJoin, assertIsImportPathNpmPackage, assertIsNotProductionRuntime, requireResolveNpmPackage, requireResolveDistFile, } from '../utils.js';
|
|
3
3
|
assertIsNotProductionRuntime();
|
|
4
4
|
function getClientEntrySrcDev(clientEntry, viteDevServer) {
|
|
5
5
|
let userRootDir = viteDevServer.config.root;
|
|
@@ -23,7 +23,7 @@ function getClientEntrySrcDev(clientEntry, viteDevServer) {
|
|
|
23
23
|
else {
|
|
24
24
|
if (clientEntry.startsWith('@@vike/')) {
|
|
25
25
|
assert(clientEntry.endsWith('.js'));
|
|
26
|
-
filePath =
|
|
26
|
+
filePath = requireResolveDistFile(`dist/esm/${clientEntry.replace('@@vike/dist/esm/', '')}`);
|
|
27
27
|
}
|
|
28
28
|
else {
|
|
29
29
|
assertIsImportPathNpmPackage(clientEntry);
|
|
@@ -9,13 +9,15 @@
|
|
|
9
9
|
export { getHttpRequestAsyncStore };
|
|
10
10
|
export { installHttpRequestAsyncStore };
|
|
11
11
|
import { renderPage_addAsyncHookwrapper } from '../../runtime/renderPage.js';
|
|
12
|
-
import { assert, assertIsNotProductionRuntime, isObject, unique } from '../utils.js';
|
|
12
|
+
import { assert, assertIsNotProductionRuntime, getGlobalObject, isObject, unique } from '../utils.js';
|
|
13
13
|
import { getConfigBuildErrorFormatted } from './resolveVikeConfigInternal/transpileAndExecuteFile.js';
|
|
14
14
|
import { logErrorDebugNote } from './loggerNotProd.js';
|
|
15
15
|
import { isEquivalentErrorWithCodeSnippet } from './loggerNotProd/errorWithCodeSnippet.js';
|
|
16
16
|
import { isDeepStrictEqual } from 'node:util';
|
|
17
17
|
assertIsNotProductionRuntime();
|
|
18
|
-
|
|
18
|
+
const globalObject = getGlobalObject('getHttpRequestAsyncStore.ts', {
|
|
19
|
+
asyncLocalStorage: null,
|
|
20
|
+
});
|
|
19
21
|
async function installHttpRequestAsyncStore() {
|
|
20
22
|
let mod;
|
|
21
23
|
try {
|
|
@@ -24,9 +26,9 @@ async function installHttpRequestAsyncStore() {
|
|
|
24
26
|
catch {
|
|
25
27
|
return;
|
|
26
28
|
}
|
|
27
|
-
asyncLocalStorage = new mod.AsyncLocalStorage();
|
|
29
|
+
globalObject.asyncLocalStorage = new mod.AsyncLocalStorage();
|
|
28
30
|
renderPage_addAsyncHookwrapper(async (httpRequestId, renderPage) => {
|
|
29
|
-
assert(asyncLocalStorage);
|
|
31
|
+
assert(globalObject.asyncLocalStorage);
|
|
30
32
|
const loggedErrors = new Set();
|
|
31
33
|
const markErrorAsLogged = (err) => {
|
|
32
34
|
loggedErrors.add(err);
|
|
@@ -49,15 +51,15 @@ async function installHttpRequestAsyncStore() {
|
|
|
49
51
|
shouldErrorBeSwallowed,
|
|
50
52
|
errorDebugNoteAlreadyShown: false,
|
|
51
53
|
};
|
|
52
|
-
const pageContextReturn = await asyncLocalStorage.run(store, renderPage);
|
|
54
|
+
const pageContextReturn = await globalObject.asyncLocalStorage.run(store, renderPage);
|
|
53
55
|
return { pageContextReturn };
|
|
54
56
|
});
|
|
55
57
|
return;
|
|
56
58
|
}
|
|
57
59
|
function getHttpRequestAsyncStore() {
|
|
58
|
-
if (asyncLocalStorage === null)
|
|
60
|
+
if (globalObject.asyncLocalStorage === null)
|
|
59
61
|
return null;
|
|
60
|
-
const store = asyncLocalStorage.getStore();
|
|
62
|
+
const store = globalObject.asyncLocalStorage.getStore();
|
|
61
63
|
assert(store === undefined || isObject(store));
|
|
62
64
|
return store;
|
|
63
65
|
}
|
|
@@ -3,7 +3,7 @@ export { resolveOutDir };
|
|
|
3
3
|
export { resolveOutDir_configEnvironment };
|
|
4
4
|
export type { OutDirs };
|
|
5
5
|
import type { UserConfig, ResolvedConfig, EnvironmentOptions } from 'vite';
|
|
6
|
-
import { ViteEnv } from './
|
|
6
|
+
import { ViteEnv } from './isViteServerSide.js';
|
|
7
7
|
type OutDirs = {
|
|
8
8
|
/** Absolute path to `outDir` */
|
|
9
9
|
outDirRoot: string;
|
|
@@ -3,19 +3,22 @@ export { resolveOutDir };
|
|
|
3
3
|
export { resolveOutDir_configEnvironment };
|
|
4
4
|
import pc from '@brillout/picocolors';
|
|
5
5
|
import { assert, assertPosixPath, assertUsage, createDebugger, pathJoin, toPosixPath } from '../utils.js';
|
|
6
|
-
import {
|
|
6
|
+
import { isViteServerSide, isViteServerSide_withoutEnv } from './isViteServerSide.js';
|
|
7
7
|
const debug = createDebugger('vike:outDir');
|
|
8
8
|
function getOutDirs(configGlobal, viteEnv) {
|
|
9
9
|
debug('getOutDirs()', new Error().stack);
|
|
10
10
|
const outDir = getOutDirFromResolvedConfig(configGlobal);
|
|
11
11
|
assertOutDirResolved(outDir, configGlobal, viteEnv);
|
|
12
12
|
const outDirs = getOutDirsAll(outDir, configGlobal.root);
|
|
13
|
+
assertNormalization(outDirs.outDirRoot);
|
|
14
|
+
assertNormalization(outDirs.outDirClient);
|
|
15
|
+
assertNormalization(outDirs.outDirServer);
|
|
13
16
|
return outDirs;
|
|
14
17
|
}
|
|
15
18
|
function resolveOutDir_configEnvironment(configGlobal, envName, configEnv) {
|
|
16
19
|
assert(configGlobal && envName && configEnv);
|
|
17
20
|
const viteEnv = { name: envName, config: configEnv };
|
|
18
|
-
const isServerSide =
|
|
21
|
+
const isServerSide = isViteServerSide(configGlobal, viteEnv);
|
|
19
22
|
return resolveOutDir(configEnv, isServerSide);
|
|
20
23
|
}
|
|
21
24
|
/** Appends `client/` or `server/` to `config.build.outDir` */
|
|
@@ -90,9 +93,9 @@ function getOutDirsAllFromRootNormalized(outDirRoot, root) {
|
|
|
90
93
|
}
|
|
91
94
|
function assertNormalization(outDirAny) {
|
|
92
95
|
assertPosixPath(outDirAny);
|
|
93
|
-
assert(outDirIsAbsolutePath(outDirAny));
|
|
94
|
-
assert(outDirAny.endsWith('/'));
|
|
95
|
-
assert(!outDirAny.endsWith('//'));
|
|
96
|
+
assert(outDirIsAbsolutePath(outDirAny), outDirAny);
|
|
97
|
+
assert(outDirAny.endsWith('/'), outDirAny);
|
|
98
|
+
assert(!outDirAny.endsWith('//'), outDirAny);
|
|
96
99
|
}
|
|
97
100
|
function isOutDirRoot(outDirRot) {
|
|
98
101
|
const p = outDirRot.split('/').filter(Boolean);
|
|
@@ -111,7 +114,7 @@ function assertOutDirResolved(outDir, configGlobal, viteEnv) {
|
|
|
111
114
|
assert('/client'.length === '/server'.length);
|
|
112
115
|
const outDirCorrected = outDir.slice(0, -1 * '/client'.length);
|
|
113
116
|
const wrongUsage = `You've set Vite's config.build.outDir to ${pc.cyan(outDir)} but you should set it to ${pc.cyan(outDirCorrected)} instead.`;
|
|
114
|
-
if (
|
|
117
|
+
if (isViteServerSide_withoutEnv(configGlobal, viteEnv)) {
|
|
115
118
|
assertUsage(outDir.endsWith('/server'), wrongUsage);
|
|
116
119
|
}
|
|
117
120
|
else {
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
export { isViteServerSide };
|
|
2
|
+
export { isViteClientSide };
|
|
3
|
+
export { isViteServerSide_withoutEnv };
|
|
4
|
+
export { isViteServerSide_onlySsrEnv };
|
|
5
|
+
export { isViteServerSide_extraSafe };
|
|
6
|
+
export type { ViteEnv };
|
|
7
|
+
import type { Environment, EnvironmentOptions, ResolvedConfig, UserConfig } from 'vite';
|
|
8
|
+
type ViteEnv = {
|
|
9
|
+
name?: string;
|
|
10
|
+
config: EnvironmentOptions | Environment['config'];
|
|
11
|
+
};
|
|
12
|
+
declare function isViteServerSide_withoutEnv(configGlobal: ResolvedConfig | UserConfig, viteEnv?: ViteEnv): boolean;
|
|
13
|
+
declare function isViteServerSide(configGlobal: ResolvedConfig | UserConfig, viteEnv: ViteEnv): boolean;
|
|
14
|
+
declare function isViteClientSide(configGlobal: ResolvedConfig, viteEnv: ViteEnv): boolean;
|
|
15
|
+
declare function isViteServerSide_onlySsrEnv(configGlobal: ResolvedConfig, viteEnv: ViteEnv): boolean;
|
|
16
|
+
declare function isViteServerSide_extraSafe(config: ResolvedConfig, options: {
|
|
17
|
+
ssr?: boolean;
|
|
18
|
+
} | undefined, viteEnv: ViteEnv): boolean;
|
|
@@ -1,11 +1,10 @@
|
|
|
1
|
-
|
|
2
|
-
export {
|
|
3
|
-
export {
|
|
4
|
-
export {
|
|
5
|
-
export {
|
|
6
|
-
export { isViteServerBuild_extraSafe };
|
|
1
|
+
export { isViteServerSide };
|
|
2
|
+
export { isViteClientSide };
|
|
3
|
+
export { isViteServerSide_withoutEnv };
|
|
4
|
+
export { isViteServerSide_onlySsrEnv };
|
|
5
|
+
export { isViteServerSide_extraSafe };
|
|
7
6
|
import { assert } from '../../../utils/assert.js';
|
|
8
|
-
function
|
|
7
|
+
function isViteServerSide_withoutEnv(configGlobal, viteEnv) {
|
|
9
8
|
assert(!('consumer' in configGlobal)); // make sure configGlobal isn't viteEnv.config
|
|
10
9
|
const isServerSide1 = !viteEnv?.config.consumer ? null : viteEnv.config.consumer !== 'client';
|
|
11
10
|
const isServerSide2 = !viteEnv?.name ? null : viteEnv.name !== 'client'; // I can't think of a use case for creating another client-side environment
|
|
@@ -24,7 +23,9 @@ function isViteServerBuild_withoutEnv(configGlobal, viteEnv) {
|
|
|
24
23
|
};
|
|
25
24
|
if (isServerSide1 !== null) {
|
|
26
25
|
assert(isServerSide1 === isServerSide2 || isServerSide2 === null, debug);
|
|
27
|
-
|
|
26
|
+
/* This assertion can fail, seems to be a Vite bug?
|
|
27
|
+
assert(isServerSide1 === isServerSide3, debug)
|
|
28
|
+
*/
|
|
28
29
|
return isServerSide1;
|
|
29
30
|
}
|
|
30
31
|
if (isServerSide2 !== null) {
|
|
@@ -38,23 +39,23 @@ function isViteServerBuild_withoutEnv(configGlobal, viteEnv) {
|
|
|
38
39
|
}
|
|
39
40
|
return isServerSide4;
|
|
40
41
|
}
|
|
41
|
-
function
|
|
42
|
-
return
|
|
42
|
+
function isViteServerSide(configGlobal, viteEnv) {
|
|
43
|
+
return isViteServerSide_withoutEnv(configGlobal, viteEnv);
|
|
43
44
|
}
|
|
44
|
-
function
|
|
45
|
-
return !
|
|
45
|
+
function isViteClientSide(configGlobal, viteEnv) {
|
|
46
|
+
return !isViteServerSide(configGlobal, viteEnv);
|
|
46
47
|
}
|
|
47
48
|
// Only `ssr` env: for example don't include `vercel_edge` nor `vercel_node`.
|
|
48
|
-
function
|
|
49
|
-
return viteEnv ? viteEnv.name === 'ssr' :
|
|
49
|
+
function isViteServerSide_onlySsrEnv(configGlobal, viteEnv) {
|
|
50
|
+
return viteEnv.name ? viteEnv.name === 'ssr' : isViteServerSide(configGlobal, viteEnv);
|
|
50
51
|
}
|
|
51
52
|
// Vite is quite messy about setting config.build.ssr — for security purposes, we use an extra safe implementation with lots of assertions, which is needed for the .client.js and .server.js guarantee.
|
|
52
|
-
function
|
|
53
|
+
function isViteServerSide_extraSafe(config, options, viteEnv) {
|
|
53
54
|
if (config.command === 'build') {
|
|
54
55
|
const res = config.build.ssr;
|
|
55
56
|
assert(typeof res === 'boolean');
|
|
56
57
|
assert(res === options?.ssr || options?.ssr === undefined);
|
|
57
|
-
assert(res ===
|
|
58
|
+
assert(res === isViteServerSide(config, viteEnv));
|
|
58
59
|
return res;
|
|
59
60
|
}
|
|
60
61
|
else {
|
|
@@ -63,7 +64,7 @@ function isViteServerBuild_extraSafe(config, options, viteEnv) {
|
|
|
63
64
|
/* This assertion can fail, seems to be a Vite bug? It's very unexpected.
|
|
64
65
|
if (typeof config.build.ssr === 'boolean') assert(res === config.build.ssr)
|
|
65
66
|
*/
|
|
66
|
-
assert(res ===
|
|
67
|
+
assert(res === isViteServerSide(config, viteEnv));
|
|
67
68
|
return res;
|
|
68
69
|
}
|
|
69
70
|
}
|
|
@@ -1,11 +1,13 @@
|
|
|
1
1
|
export { removeSuperfluousViteLog };
|
|
2
2
|
export { removeSuperfluousViteLog_enable };
|
|
3
3
|
export { removeSuperfluousViteLog_disable };
|
|
4
|
-
import { assert } from '../../utils.js';
|
|
4
|
+
import { assert, getGlobalObject } from '../../utils.js';
|
|
5
|
+
const globalObject = getGlobalObject('removeSuperfluousViteLog.ts', {
|
|
6
|
+
enabled: false,
|
|
7
|
+
});
|
|
5
8
|
const superfluousLog = 'Forced re-optimization of dependencies';
|
|
6
|
-
let enabled = false;
|
|
7
9
|
function removeSuperfluousViteLog(msg) {
|
|
8
|
-
if (!enabled) {
|
|
10
|
+
if (!globalObject.enabled) {
|
|
9
11
|
return false;
|
|
10
12
|
}
|
|
11
13
|
if (msg.toLowerCase().includes('forced') && msg.toLowerCase().includes('optimization')) {
|
|
@@ -15,8 +17,8 @@ function removeSuperfluousViteLog(msg) {
|
|
|
15
17
|
return false;
|
|
16
18
|
}
|
|
17
19
|
function removeSuperfluousViteLog_enable() {
|
|
18
|
-
enabled = true;
|
|
20
|
+
globalObject.enabled = true;
|
|
19
21
|
}
|
|
20
22
|
function removeSuperfluousViteLog_disable() {
|
|
21
|
-
enabled = false;
|
|
23
|
+
globalObject.enabled = false;
|
|
22
24
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
export { crawlPlusFiles };
|
|
2
2
|
export { isPlusFile };
|
|
3
3
|
export { getPlusFileValueConfigName };
|
|
4
|
-
import { assertPosixPath, assert, scriptFileExtensionPattern,
|
|
4
|
+
import { assertPosixPath, assert, scriptFileExtensionPattern, assertIsNotProductionRuntime, isVersionOrAbove, isScriptFile, scriptFileExtensionList, createDebugger, deepEqual, assertUsage, assertFilePathAbsoluteFilesystem, assertWarning, hasProp, isNotNullish, getGlobalObject, } from '../../utils.js';
|
|
5
5
|
import path from 'node:path';
|
|
6
6
|
import { glob } from 'tinyglobby';
|
|
7
7
|
import { exec } from 'node:child_process';
|
|
@@ -14,8 +14,9 @@ import { ignorePatternsBuiltIn } from './crawlPlusFiles/ignorePatternsBuiltIn.js
|
|
|
14
14
|
const execA = promisify(exec);
|
|
15
15
|
const debug = createDebugger('vike:crawl');
|
|
16
16
|
assertIsNotProductionRuntime();
|
|
17
|
-
|
|
18
|
-
|
|
17
|
+
const globalObject = getGlobalObject('getVikeConfig/crawlPlusFiles.ts', {
|
|
18
|
+
gitIsNotUsable: false,
|
|
19
|
+
});
|
|
19
20
|
async function crawlPlusFiles(userRootDir) {
|
|
20
21
|
assertPosixPath(userRootDir);
|
|
21
22
|
assertFilePathAbsoluteFilesystem(userRootDir);
|
|
@@ -48,7 +49,7 @@ async function crawlPlusFiles(userRootDir) {
|
|
|
48
49
|
}
|
|
49
50
|
// Same as tinyglobby() but using `$ git ls-files`
|
|
50
51
|
async function gitLsFiles(userRootDir, ignorePatterns, ignoreMatchers) {
|
|
51
|
-
if (gitIsNotUsable)
|
|
52
|
+
if (globalObject.gitIsNotUsable)
|
|
52
53
|
return null;
|
|
53
54
|
// Preserve UTF-8 file paths.
|
|
54
55
|
// https://github.com/vikejs/vike/issues/1658
|
|
@@ -82,7 +83,7 @@ async function gitLsFiles(userRootDir, ignorePatterns, ignoreMatchers) {
|
|
|
82
83
|
}
|
|
83
84
|
catch (err) {
|
|
84
85
|
if (await isGitNotUsable(userRootDir)) {
|
|
85
|
-
gitIsNotUsable = true;
|
|
86
|
+
globalObject.gitIsNotUsable = true;
|
|
86
87
|
return null;
|
|
87
88
|
}
|
|
88
89
|
throw err;
|