vike 0.4.166 → 0.4.167-commit-14e4b5e
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/plugin/plugins/buildConfig.js +11 -6
- package/dist/cjs/node/plugin/plugins/commonConfig/assertResolveAlias.js +2 -1
- package/dist/cjs/node/plugin/plugins/devConfig/determineOptimizeDeps.js +17 -22
- package/dist/cjs/node/plugin/plugins/envVars.js +3 -2
- package/dist/cjs/node/plugin/plugins/extractAssetsPlugin.js +11 -13
- package/dist/cjs/node/plugin/plugins/extractExportNamesPlugin.js +2 -4
- package/dist/cjs/node/plugin/plugins/fileEnv.js +6 -3
- package/dist/cjs/node/plugin/plugins/importUserCode/index.js +6 -2
- package/dist/cjs/node/plugin/plugins/importUserCode/v1-design/getConfigFileExport.js +3 -3
- package/dist/cjs/node/plugin/plugins/importUserCode/v1-design/getVikeConfig/crawlPlusFiles.js +2 -0
- package/dist/cjs/node/plugin/plugins/importUserCode/v1-design/getVikeConfig/loadFileAtConfigTime.js +5 -1
- package/dist/cjs/node/plugin/plugins/importUserCode/v1-design/getVikeConfig/resolveImportPath.js +21 -17
- package/dist/cjs/node/plugin/plugins/importUserCode/v1-design/getVikeConfig/transpileAndExecuteFile.js +34 -23
- package/dist/cjs/node/plugin/plugins/importUserCode/v1-design/getVikeConfig.js +7 -3
- package/dist/cjs/node/plugin/shared/getFilePath.js +83 -29
- package/dist/cjs/node/plugin/shared/isErrorDebug.js +1 -1
- package/dist/cjs/node/plugin/shared/loggerNotProd/errorWithCodeSnippet.js +3 -8
- package/dist/cjs/node/plugin/shared/loggerNotProd.js +2 -1
- package/dist/cjs/node/plugin/utils.js +1 -1
- package/dist/cjs/node/prerender/runPrerender.js +6 -7
- package/dist/cjs/node/prerender/utils.js +2 -1
- package/dist/cjs/node/runtime/html/stream.js +5 -5
- package/dist/cjs/node/runtime/renderPage/analyzePage.js +1 -1
- package/dist/cjs/node/runtime/renderPage/executeOnBeforeRenderAndDataHooks.js +3 -3
- package/dist/cjs/node/runtime/renderPage/executeOnRenderHtmlHook.js +2 -1
- package/dist/cjs/node/runtime/renderPage/getPageAssets/getManifestEntry.js +5 -9
- package/dist/cjs/node/runtime/renderPage/getPageAssets/retrieveAssetsProd.js +9 -8
- package/dist/cjs/node/runtime/renderPage/getPageAssets.js +6 -12
- package/dist/cjs/node/runtime/renderPage/logErrorHint.js +13 -1
- package/dist/cjs/node/runtime/utils.js +0 -1
- package/dist/cjs/shared/page-configs/assertPlusFileExport.js +1 -3
- package/dist/cjs/shared/route/abort.js +2 -1
- package/dist/cjs/shared/route/executeGuardHook.js +2 -1
- package/dist/cjs/shared/route/executeOnBeforeRouteHook.js +2 -1
- package/dist/cjs/shared/route/index.js +2 -3
- package/dist/cjs/shared/route/utils.js +0 -1
- package/dist/cjs/utils/assertIsNotProductionRuntime.js +5 -5
- package/dist/cjs/utils/assertPathIsFilesystemAbsolute.js +1 -0
- package/dist/cjs/utils/debug.js +48 -14
- package/dist/cjs/utils/isNpmPackage.js +11 -2
- package/dist/cjs/utils/projectInfo.js +1 -1
- package/dist/cjs/utils/trackLogs.js +1 -1
- package/dist/esm/client/client-routing-runtime/renderPageClientSide.js +31 -24
- package/dist/esm/node/plugin/plugins/buildConfig.js +12 -7
- package/dist/esm/node/plugin/plugins/commonConfig/assertResolveAlias.js +2 -1
- package/dist/esm/node/plugin/plugins/devConfig/determineOptimizeDeps.js +18 -23
- package/dist/esm/node/plugin/plugins/envVars.js +4 -3
- package/dist/esm/node/plugin/plugins/extractAssetsPlugin.js +12 -14
- package/dist/esm/node/plugin/plugins/extractExportNamesPlugin.js +3 -5
- package/dist/esm/node/plugin/plugins/fileEnv.js +7 -4
- package/dist/esm/node/plugin/plugins/importUserCode/index.js +7 -3
- package/dist/esm/node/plugin/plugins/importUserCode/v1-design/debug.d.ts +1 -1
- package/dist/esm/node/plugin/plugins/importUserCode/v1-design/getConfigFileExport.js +4 -4
- package/dist/esm/node/plugin/plugins/importUserCode/v1-design/getVikeConfig/crawlPlusFiles.js +2 -0
- package/dist/esm/node/plugin/plugins/importUserCode/v1-design/getVikeConfig/loadFileAtConfigTime.js +5 -1
- package/dist/esm/node/plugin/plugins/importUserCode/v1-design/getVikeConfig/resolveImportPath.js +21 -17
- package/dist/esm/node/plugin/plugins/importUserCode/v1-design/getVikeConfig/transpileAndExecuteFile.d.ts +2 -2
- package/dist/esm/node/plugin/plugins/importUserCode/v1-design/getVikeConfig/transpileAndExecuteFile.js +33 -22
- package/dist/esm/node/plugin/plugins/importUserCode/v1-design/getVikeConfig.js +8 -4
- package/dist/esm/node/plugin/shared/getFilePath.d.ts +10 -9
- package/dist/esm/node/plugin/shared/getFilePath.js +83 -29
- package/dist/esm/node/plugin/shared/isErrorDebug.js +2 -2
- package/dist/esm/node/plugin/shared/loggerNotProd/errorWithCodeSnippet.js +4 -9
- package/dist/esm/node/plugin/shared/loggerNotProd.js +2 -1
- package/dist/esm/node/plugin/utils.d.ts +1 -1
- package/dist/esm/node/plugin/utils.js +1 -1
- package/dist/esm/node/prerender/runPrerender.js +2 -3
- package/dist/esm/node/prerender/utils.d.ts +2 -1
- package/dist/esm/node/prerender/utils.js +2 -1
- package/dist/esm/node/runtime/html/stream.js +5 -5
- package/dist/esm/node/runtime/renderPage/analyzePage.js +1 -1
- package/dist/esm/node/runtime/renderPage/executeOnBeforeRenderAndDataHooks.js +1 -1
- package/dist/esm/node/runtime/renderPage/executeOnRenderHtmlHook.js +2 -1
- package/dist/esm/node/runtime/renderPage/getPageAssets/getManifestEntry.js +6 -10
- package/dist/esm/node/runtime/renderPage/getPageAssets/retrieveAssetsProd.js +9 -8
- package/dist/esm/node/runtime/renderPage/getPageAssets.js +7 -13
- package/dist/esm/node/runtime/renderPage/logErrorHint.js +13 -1
- package/dist/esm/node/runtime/utils.d.ts +0 -1
- package/dist/esm/node/runtime/utils.js +0 -1
- package/dist/esm/shared/addUrlComputedProps.d.ts +2 -2
- package/dist/esm/shared/page-configs/FilePath.d.ts +41 -29
- package/dist/esm/shared/page-configs/assertPlusFileExport.js +1 -3
- package/dist/esm/shared/route/abort.js +2 -1
- package/dist/esm/shared/route/executeGuardHook.js +2 -1
- package/dist/esm/shared/route/executeOnBeforeRouteHook.js +2 -1
- package/dist/esm/shared/route/index.js +2 -3
- package/dist/esm/shared/route/utils.d.ts +0 -1
- package/dist/esm/shared/route/utils.js +0 -1
- package/dist/esm/utils/assertIsNotProductionRuntime.js +5 -5
- package/dist/esm/utils/assertPathIsFilesystemAbsolute.js +1 -0
- package/dist/esm/utils/debug.d.ts +5 -4
- package/dist/esm/utils/debug.js +45 -14
- package/dist/esm/utils/debugGlob.d.ts +1 -1
- package/dist/esm/utils/isNpmPackage.d.ts +5 -1
- package/dist/esm/utils/isNpmPackage.js +10 -1
- package/dist/esm/utils/projectInfo.d.ts +2 -2
- package/dist/esm/utils/projectInfo.js +1 -1
- package/dist/esm/utils/trackLogs.js +2 -2
- package/package.json +1 -1
- package/dist/cjs/node/runtime/renderPage/getPageAssets/assertClientEntryId.js +0 -19
- package/dist/cjs/utils/getFilePathAbsolute.js +0 -70
- package/dist/esm/node/runtime/renderPage/getPageAssets/assertClientEntryId.d.ts +0 -2
- package/dist/esm/node/runtime/renderPage/getPageAssets/assertClientEntryId.js +0 -16
- package/dist/esm/utils/getFilePathAbsolute.d.ts +0 -5
- package/dist/esm/utils/getFilePathAbsolute.js +0 -64
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
export { getConfigFileExport };
|
|
2
2
|
import pc from '@brillout/picocolors';
|
|
3
3
|
import { assertPlusFileExport } from '../../../../../shared/page-configs/assertPlusFileExport.js';
|
|
4
|
-
import {
|
|
4
|
+
import { assertUsage, isObject } from '../../../utils.js';
|
|
5
5
|
function getConfigFileExport(fileExports, filePathToShowToUser) {
|
|
6
6
|
assertPlusFileExport(fileExports, filePathToShowToUser, 'config');
|
|
7
|
-
const
|
|
8
|
-
|
|
9
|
-
const exportName = pc.cyan(
|
|
7
|
+
const usesNamedExport = !!fileExports.config;
|
|
8
|
+
const fileExport = usesNamedExport ? fileExports.config : fileExports.default;
|
|
9
|
+
const exportName = pc.cyan(usesNamedExport ? 'export { config }' : 'export default');
|
|
10
10
|
assertUsage(isObject(fileExport), `The ${exportName} of ${filePathToShowToUser} should be an object (but it's ${pc.cyan(`typeof exportedValue === ${JSON.stringify(typeof fileExport)}`)} instead)`);
|
|
11
11
|
return fileExport;
|
|
12
12
|
}
|
package/dist/esm/node/plugin/plugins/importUserCode/v1-design/getVikeConfig/crawlPlusFiles.js
CHANGED
|
@@ -5,6 +5,7 @@ import glob from 'fast-glob';
|
|
|
5
5
|
import { exec } from 'child_process';
|
|
6
6
|
import { promisify } from 'util';
|
|
7
7
|
import pc from '@brillout/picocolors';
|
|
8
|
+
import { isTemporaryBuildFile } from './transpileAndExecuteFile.js';
|
|
8
9
|
const execA = promisify(exec);
|
|
9
10
|
assertIsNotProductionRuntime();
|
|
10
11
|
assertIsSingleModuleInstance('crawlPlusFiles.ts');
|
|
@@ -29,6 +30,7 @@ async function crawlPlusFiles(userRootDir, outDirAbsoluteFilesystem, isDev) {
|
|
|
29
30
|
else {
|
|
30
31
|
files = await fastGlob(userRootDir, outDirRelativeFromUserRootDir);
|
|
31
32
|
}
|
|
33
|
+
files = files.filter((file) => !isTemporaryBuildFile(file));
|
|
32
34
|
{
|
|
33
35
|
const timeAfter = new Date().getTime();
|
|
34
36
|
const timeSpent = timeAfter - timeBefore;
|
package/dist/esm/node/plugin/plugins/importUserCode/v1-design/getVikeConfig/loadFileAtConfigTime.js
CHANGED
|
@@ -76,7 +76,11 @@ async function loadExtendsConfigs(configFileExports, configFilePath, userRootDir
|
|
|
76
76
|
return { extendsConfigs, extendsFilePaths };
|
|
77
77
|
}
|
|
78
78
|
function warnUserLandExtension(importPath, configFilePath) {
|
|
79
|
-
|
|
79
|
+
// We preserve this feature because we may need it for eject
|
|
80
|
+
assertWarning(isNpmPackageImport(importPath, {
|
|
81
|
+
// Vike config files don't support path aliases. (If they do one day, then Vike will/should be able to resolve path aliases.)
|
|
82
|
+
cannotBePathAlias: true
|
|
83
|
+
}) || importPath.includes('/node_modules/'), `${configFilePath.filePathToShowToUser} uses ${pc.cyan('extends')} to inherit from ${pc.cyan(importPath)} which is a user-land file: this is experimental and may be remove at any time. Reach out to a maintainer if you need this.`, { onlyOnce: true });
|
|
80
84
|
}
|
|
81
85
|
function getExtendsImportData(configFileExports, configFilePath) {
|
|
82
86
|
const { filePathToShowToUser } = configFilePath;
|
package/dist/esm/node/plugin/plugins/importUserCode/v1-design/getVikeConfig/resolveImportPath.js
CHANGED
|
@@ -18,6 +18,7 @@ function resolveImport(configValue, importerFilePath, userRootDir, configEnv, co
|
|
|
18
18
|
const filePathAbsoluteFilesystem = resolveImportPath(importData, importerFilePath);
|
|
19
19
|
assertFileEnv(filePathAbsoluteFilesystem ?? importPath, configEnv, configName);
|
|
20
20
|
const fileExportPathToShowToUser = exportName === 'default' || exportName === configName ? [] : [exportName];
|
|
21
|
+
let filePath;
|
|
21
22
|
if (importPath.startsWith('.')) {
|
|
22
23
|
// We need to resolve relative paths into absolute paths. Because the import paths are included in virtual files:
|
|
23
24
|
// ```
|
|
@@ -25,28 +26,30 @@ function resolveImport(configValue, importerFilePath, userRootDir, configEnv, co
|
|
|
25
26
|
// ```
|
|
26
27
|
assertImportPath(filePathAbsoluteFilesystem, importData, importerFilePath);
|
|
27
28
|
const filePathAbsoluteUserRootDir = resolveImportPath_absoluteUserRootDir(filePathAbsoluteFilesystem, importData, importerFilePath, userRootDir);
|
|
28
|
-
|
|
29
|
-
return {
|
|
30
|
-
...filePath,
|
|
31
|
-
fileExportName: exportName,
|
|
32
|
-
fileExportPathToShowToUser
|
|
33
|
-
};
|
|
29
|
+
filePath = getFilePathResolved({ filePathAbsoluteUserRootDir, userRootDir });
|
|
34
30
|
}
|
|
35
31
|
else {
|
|
36
32
|
// importPath can be:
|
|
37
33
|
// - an npm package import
|
|
38
34
|
// - a path alias
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
35
|
+
if (filePathAbsoluteFilesystem) {
|
|
36
|
+
filePath = getFilePathResolved({
|
|
37
|
+
userRootDir,
|
|
38
|
+
filePathAbsoluteFilesystem,
|
|
39
|
+
importPathAbsolute: importPath
|
|
40
|
+
});
|
|
41
|
+
}
|
|
42
|
+
else {
|
|
43
|
+
filePath = getFilePathUnresolved({
|
|
44
|
+
importPathAbsolute: importPath
|
|
45
|
+
});
|
|
46
|
+
}
|
|
49
47
|
}
|
|
48
|
+
return {
|
|
49
|
+
...filePath,
|
|
50
|
+
fileExportName: exportName,
|
|
51
|
+
fileExportPathToShowToUser
|
|
52
|
+
};
|
|
50
53
|
}
|
|
51
54
|
function resolveImportPath_absoluteUserRootDir(filePathAbsoluteFilesystem, importData, configFilePath, userRootDir) {
|
|
52
55
|
assertPosixPath(userRootDir);
|
|
@@ -74,7 +77,8 @@ function resolveImportPath(importData, importerFilePath) {
|
|
|
74
77
|
const importerFilePathAbsolute = importerFilePath.filePathAbsoluteFilesystem;
|
|
75
78
|
assertPosixPath(importerFilePathAbsolute);
|
|
76
79
|
const cwd = path.posix.dirname(importerFilePathAbsolute);
|
|
77
|
-
// We can't use import.meta.resolve() as of Junary 2023 (and probably for a lot longer)
|
|
80
|
+
// We can't use import.meta.resolve() as of Junary 2023 (and probably for a lot longer)
|
|
81
|
+
// https://stackoverflow.com/questions/54977743/do-require-resolve-for-es-modules#comment137174954_62272600:~:text=But%20the%20argument%20parent%20(aka%20cwd)%20still%20requires%20a%20flag
|
|
78
82
|
// filePathAbsoluteFilesystem is expected to be null when importData.importPath is a Vite path alias
|
|
79
83
|
const filePathAbsoluteFilesystem = requireResolve(importData.importPath, cwd);
|
|
80
84
|
return filePathAbsoluteFilesystem;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
export { transpileAndExecuteFile };
|
|
2
2
|
export { getConfigBuildErrorFormatted };
|
|
3
3
|
export { getConfigExecutionErrorIntroMsg };
|
|
4
|
-
export {
|
|
4
|
+
export { isTemporaryBuildFile };
|
|
5
5
|
import 'source-map-support/register.js';
|
|
6
6
|
import type { FilePathResolved } from '../../../../../../shared/page-configs/FilePath.js';
|
|
7
7
|
declare function transpileAndExecuteFile(filePath: FilePathResolved, userRootDir: string, isConfigFile: boolean | 'is-extension-config'): Promise<{
|
|
@@ -9,4 +9,4 @@ declare function transpileAndExecuteFile(filePath: FilePathResolved, userRootDir
|
|
|
9
9
|
}>;
|
|
10
10
|
declare function getConfigBuildErrorFormatted(err: unknown): null | string;
|
|
11
11
|
declare function getConfigExecutionErrorIntroMsg(err: unknown): string | null;
|
|
12
|
-
declare function
|
|
12
|
+
declare function isTemporaryBuildFile(filePath: string): boolean;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
export { transpileAndExecuteFile };
|
|
2
2
|
export { getConfigBuildErrorFormatted };
|
|
3
3
|
export { getConfigExecutionErrorIntroMsg };
|
|
4
|
-
export {
|
|
4
|
+
export { isTemporaryBuildFile };
|
|
5
5
|
import { build, formatMessages } from 'esbuild';
|
|
6
6
|
import fs from 'fs';
|
|
7
7
|
import path from 'path';
|
|
@@ -37,10 +37,10 @@ async function transpileFile(filePath, transformImports, userRootDir) {
|
|
|
37
37
|
const { filePathAbsoluteFilesystem, filePathToShowToUserResolved } = filePath;
|
|
38
38
|
assertPosixPath(filePathAbsoluteFilesystem);
|
|
39
39
|
vikeConfigDependencies.add(filePathAbsoluteFilesystem);
|
|
40
|
-
if (debug.
|
|
40
|
+
if (debug.isActivated)
|
|
41
41
|
debug('transpile', filePathToShowToUserResolved);
|
|
42
42
|
let { code, pointerImports } = await transpileWithEsbuild(filePath, userRootDir, transformImports);
|
|
43
|
-
if (debug.
|
|
43
|
+
if (debug.isActivated)
|
|
44
44
|
debug(`code, post esbuild (${filePathToShowToUserResolved})`, code);
|
|
45
45
|
let isImportTransformed = false;
|
|
46
46
|
if (transformImports) {
|
|
@@ -48,12 +48,12 @@ async function transpileFile(filePath, transformImports, userRootDir) {
|
|
|
48
48
|
if (codeMod) {
|
|
49
49
|
code = codeMod;
|
|
50
50
|
isImportTransformed = true;
|
|
51
|
-
if (debug.
|
|
51
|
+
if (debug.isActivated)
|
|
52
52
|
debug(`code, post transformImports() (${filePathToShowToUserResolved})`, code);
|
|
53
53
|
}
|
|
54
54
|
}
|
|
55
55
|
if (!isImportTransformed) {
|
|
56
|
-
if (debug.
|
|
56
|
+
if (debug.isActivated)
|
|
57
57
|
debug(`code, no transformImports() (${filePathToShowToUserResolved})`);
|
|
58
58
|
}
|
|
59
59
|
return code;
|
|
@@ -70,7 +70,7 @@ async function transpileWithEsbuild(filePath, userRootDir, transformImports) {
|
|
|
70
70
|
outfile: path.posix.join(
|
|
71
71
|
// Needed for correct inline source map
|
|
72
72
|
entryFileDir,
|
|
73
|
-
// `write: false` => no file is actually
|
|
73
|
+
// `write: false` => no file is actually emitted
|
|
74
74
|
'NEVER_EMITTED.js'),
|
|
75
75
|
logLevel: 'silent',
|
|
76
76
|
format: 'esm',
|
|
@@ -90,9 +90,11 @@ async function transpileWithEsbuild(filePath, userRootDir, transformImports) {
|
|
|
90
90
|
else {
|
|
91
91
|
const pointerImports_ = (pointerImports = {});
|
|
92
92
|
options.plugins = [
|
|
93
|
-
// Determine
|
|
93
|
+
// Determine whether an import should be:
|
|
94
|
+
// - A pointer import
|
|
95
|
+
// - Externalized
|
|
94
96
|
{
|
|
95
|
-
name: 'vike
|
|
97
|
+
name: 'vike-esbuild-plugin',
|
|
96
98
|
setup(build) {
|
|
97
99
|
// https://github.com/evanw/esbuild/issues/3095#issuecomment-1546916366
|
|
98
100
|
const useEsbuildResolver = 'useEsbuildResolver';
|
|
@@ -102,10 +104,19 @@ async function transpileWithEsbuild(filePath, userRootDir, transformImports) {
|
|
|
102
104
|
return;
|
|
103
105
|
if (args.pluginData?.[useEsbuildResolver])
|
|
104
106
|
return;
|
|
105
|
-
const isImportAbsolute = !args.path.startsWith('.');
|
|
106
107
|
const { path, ...opts } = args;
|
|
107
108
|
opts.pluginData = { [useEsbuildResolver]: true };
|
|
108
109
|
const resolved = await build.resolve(path, opts);
|
|
110
|
+
if (resolved.errors.length > 0) {
|
|
111
|
+
/* We could do the following to let Node.js throw the error, but we don't because the error shown by esbuild is prettier: the Node.js error refers to the transpiled [build-f7i251e0iwnw]+config.ts.mjs file which isn't that nice, whereas esbuild refers to the source +config.ts file.
|
|
112
|
+
pointerImports_[args.path] = false
|
|
113
|
+
return { external: true }
|
|
114
|
+
*/
|
|
115
|
+
// Let esbuild throw the error. (It throws a nice & pretty error.)
|
|
116
|
+
return resolved;
|
|
117
|
+
}
|
|
118
|
+
assert(resolved.path);
|
|
119
|
+
resolved.path = toPosixPath(resolved.path);
|
|
109
120
|
// vike-{react,vue,solid} follow the convention that their config export resolves to a file named +config.js
|
|
110
121
|
// - This is temporary, see comment below.
|
|
111
122
|
const isVikeExtensionConfigImport = resolved.path.endsWith('+config.js');
|
|
@@ -120,14 +131,15 @@ async function transpileWithEsbuild(filePath, userRootDir, transformImports) {
|
|
|
120
131
|
// - For example if esbuild cannot resolve a path alias while Vite can.
|
|
121
132
|
// - When tsconfig.js#compilerOptions.paths is set, then esbuild is able to resolve the path alias.
|
|
122
133
|
resolved.errors.length > 0;
|
|
123
|
-
pointerImports_[
|
|
134
|
+
pointerImports_[resolved.path] = isPointerImport;
|
|
135
|
+
assertPosixPath(resolved.path);
|
|
124
136
|
const isExternal = isPointerImport ||
|
|
125
|
-
// npm package imports that aren't pointer imports
|
|
126
|
-
|
|
127
|
-
if (debug.
|
|
137
|
+
// Performance: npm package imports that aren't pointer imports can be externalized. For example, if Vike eventually adds support for setting Vite configs in the vike.config.js file, then the user may import a Vite plugin in his vike.config.js file. (We could as well let esbuild always transpile /node_modules/ code but it would be useless and would unnecessarily slow down transpilation.)
|
|
138
|
+
resolved.path.includes('/node_modules/');
|
|
139
|
+
if (debug.isActivated)
|
|
128
140
|
debug('onResolved()', { args, resolved, isPointerImport, isExternal });
|
|
129
141
|
if (isExternal) {
|
|
130
|
-
return { external: true, path:
|
|
142
|
+
return { external: true, path: resolved.path };
|
|
131
143
|
}
|
|
132
144
|
else {
|
|
133
145
|
return resolved;
|
|
@@ -185,7 +197,7 @@ async function executeTranspiledFile(filePath, code) {
|
|
|
185
197
|
const { filePathAbsoluteFilesystem } = filePath;
|
|
186
198
|
// Alternative to using a temporary file: https://github.com/vitejs/vite/pull/13269
|
|
187
199
|
// - But seems to break source maps, so I don't think it's worth it
|
|
188
|
-
const filePathTmp =
|
|
200
|
+
const filePathTmp = getTemporaryBuildFilePath(filePathAbsoluteFilesystem);
|
|
189
201
|
fs.writeFileSync(filePathTmp, code);
|
|
190
202
|
const clean = () => fs.unlinkSync(filePathTmp);
|
|
191
203
|
let fileExports = {};
|
|
@@ -242,20 +254,19 @@ function getConfigExecutionErrorIntroMsg(err) {
|
|
|
242
254
|
const errIntroMsg = execErrIntroMsg.get(err);
|
|
243
255
|
return errIntroMsg ?? null;
|
|
244
256
|
}
|
|
245
|
-
|
|
246
|
-
function getFilePathTmp(filePathAbsoluteFilesystem) {
|
|
257
|
+
function getTemporaryBuildFilePath(filePathAbsoluteFilesystem) {
|
|
247
258
|
assertPosixPath(filePathAbsoluteFilesystem);
|
|
248
259
|
const dirname = path.posix.dirname(filePathAbsoluteFilesystem);
|
|
249
260
|
const filename = path.posix.basename(filePathAbsoluteFilesystem);
|
|
250
|
-
// Syntax with semicolon `
|
|
251
|
-
const
|
|
252
|
-
|
|
261
|
+
// Syntax with semicolon `build:${/*...*/}` doesn't work on Windows: https://github.com/vikejs/vike/issues/800#issuecomment-1517329455
|
|
262
|
+
const filePathTmp = path.posix.join(dirname, `${filename}.build-${getRandomId(12)}.mjs`);
|
|
263
|
+
assert(isTemporaryBuildFile(filePathTmp));
|
|
253
264
|
return filePathTmp;
|
|
254
265
|
}
|
|
255
|
-
function
|
|
266
|
+
function isTemporaryBuildFile(filePath) {
|
|
256
267
|
assertPosixPath(filePath);
|
|
257
268
|
const fileName = path.posix.basename(filePath);
|
|
258
|
-
return fileName
|
|
269
|
+
return /\.build-[a-z0-9]{12}\.mjs$/.test(fileName);
|
|
259
270
|
}
|
|
260
271
|
function isHeaderFile(filePath) {
|
|
261
272
|
assertPosixPath(filePath);
|
|
@@ -7,7 +7,7 @@ import { assertPosixPath, assert, isObject, assertUsage, assertWarning, objectEn
|
|
|
7
7
|
import path from 'path';
|
|
8
8
|
import { configDefinitionsBuiltIn, configDefinitionsBuiltInGlobal } from './getVikeConfig/configDefinitionsBuiltIn.js';
|
|
9
9
|
import { getLocationId, getFilesystemRouteString, getFilesystemRouteDefinedBy, isInherited, sortAfterInheritanceOrder, isGlobalLocation, applyFilesystemRoutingRootEffect } from './getVikeConfig/filesystemRouting.js';
|
|
10
|
-
import {
|
|
10
|
+
import { isTemporaryBuildFile } from './getVikeConfig/transpileAndExecuteFile.js';
|
|
11
11
|
import { isConfigInvalid, isConfigInvalid_set } from '../../../../runtime/renderPage/isConfigInvalid.js';
|
|
12
12
|
import { getViteDevServer } from '../../../../runtime/globalContext.js';
|
|
13
13
|
import { logConfigError, logConfigErrorRecover } from '../../../shared/loggerNotProd.js';
|
|
@@ -740,12 +740,12 @@ function getComputed(configValueSources, configDefinitions) {
|
|
|
740
740
|
}
|
|
741
741
|
async function findPlusFiles(userRootDir, outDirRoot, isDev) {
|
|
742
742
|
const files = await crawlPlusFiles(userRootDir, outDirRoot, isDev);
|
|
743
|
-
const plusFiles = files.map(({ filePathAbsoluteUserRootDir }) => getFilePathResolved({ filePathAbsoluteUserRootDir, userRootDir
|
|
743
|
+
const plusFiles = files.map(({ filePathAbsoluteUserRootDir }) => getFilePathResolved({ filePathAbsoluteUserRootDir, userRootDir }));
|
|
744
744
|
return plusFiles;
|
|
745
745
|
}
|
|
746
746
|
function getConfigName(filePath) {
|
|
747
747
|
assertPosixPath(filePath);
|
|
748
|
-
if (
|
|
748
|
+
if (isTemporaryBuildFile(filePath))
|
|
749
749
|
return null;
|
|
750
750
|
const fileName = path.posix.basename(filePath);
|
|
751
751
|
// assertNoUnexpectedPlusSign(filePath, fileName)
|
|
@@ -1007,7 +1007,11 @@ function sortConfigValueSources(configValueSources, locationIdPage) {
|
|
|
1007
1007
|
// Sort after whether the config value was defined by an npm package
|
|
1008
1008
|
.sort(makeFirst(([, [source]]) => {
|
|
1009
1009
|
const { importPathAbsolute } = source.definedAt;
|
|
1010
|
-
return !!importPathAbsolute &&
|
|
1010
|
+
return (!!importPathAbsolute &&
|
|
1011
|
+
isNpmPackageImport(importPathAbsolute, {
|
|
1012
|
+
// Vike config files don't support path aliases. (If they do one day, then Vike will/should be able to resolve path aliases.)
|
|
1013
|
+
cannotBePathAlias: true
|
|
1014
|
+
}));
|
|
1011
1015
|
}))
|
|
1012
1016
|
// Sort after the filesystem inheritance of the config value
|
|
1013
1017
|
.sort(([, [source1]], [, [source2]]) => reverse(sortAfterInheritanceOrder(source1.locationId, source2.locationId, locationIdPage))));
|
|
@@ -1,20 +1,21 @@
|
|
|
1
1
|
export { getFilePathResolved };
|
|
2
2
|
export { getFilePathUnresolved };
|
|
3
|
+
export { getModuleFilePath };
|
|
4
|
+
export { getFilePathToShowToUserFromUnkown };
|
|
5
|
+
export { cleanFilePathUnkown };
|
|
3
6
|
import type { FilePath, FilePathResolved } from '../../../shared/page-configs/FilePath.js';
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
filePathAbsoluteUserRootDir: string | null;
|
|
7
|
-
importPathAbsolute: string | null;
|
|
8
|
-
} & ({
|
|
9
|
-
filePathAbsoluteUserRootDir: string;
|
|
10
|
-
} | {
|
|
7
|
+
import type { ResolvedConfig } from 'vite';
|
|
8
|
+
declare function getFilePathUnresolved({ importPathAbsolute }: {
|
|
11
9
|
importPathAbsolute: string;
|
|
12
|
-
})
|
|
10
|
+
}): FilePath;
|
|
13
11
|
declare function getFilePathResolved(args: {
|
|
14
12
|
userRootDir: string;
|
|
15
|
-
importPathAbsolute
|
|
13
|
+
importPathAbsolute?: string;
|
|
16
14
|
} & ({
|
|
17
15
|
filePathAbsoluteFilesystem: string;
|
|
18
16
|
} | {
|
|
19
17
|
filePathAbsoluteUserRootDir: string;
|
|
20
18
|
})): FilePathResolved;
|
|
19
|
+
declare function getModuleFilePath(moduleId: string, config: ResolvedConfig): string;
|
|
20
|
+
declare function getFilePathToShowToUserFromUnkown(filePathUnkown: string, userRootDir: string): string;
|
|
21
|
+
declare function cleanFilePathUnkown(filePathUnknown: string): string;
|
|
@@ -1,26 +1,16 @@
|
|
|
1
1
|
export { getFilePathResolved };
|
|
2
2
|
export { getFilePathUnresolved };
|
|
3
|
+
export { getModuleFilePath };
|
|
4
|
+
export { getFilePathToShowToUserFromUnkown };
|
|
5
|
+
export { cleanFilePathUnkown };
|
|
3
6
|
import path from 'path';
|
|
4
|
-
import { assert, assertPosixPath,
|
|
5
|
-
function getFilePathUnresolved(
|
|
6
|
-
|
|
7
|
-
let filePathAbsoluteVite;
|
|
8
|
-
if (args.filePathAbsoluteUserRootDir !== null) {
|
|
9
|
-
filePathAbsoluteVite = args.filePathAbsoluteUserRootDir;
|
|
10
|
-
}
|
|
11
|
-
else {
|
|
12
|
-
assert(args.importPathAbsolute !== null); // Help TS
|
|
13
|
-
filePathAbsoluteVite = args.importPathAbsolute;
|
|
14
|
-
}
|
|
15
|
-
return {
|
|
16
|
-
...args,
|
|
17
|
-
filePathAbsoluteVite,
|
|
18
|
-
filePathToShowToUser: filePathAbsoluteVite,
|
|
19
|
-
filePathToShowToUserResolved: filePathAbsoluteUserRootDir || filePathAbsoluteFilesystem
|
|
20
|
-
};
|
|
7
|
+
import { assert, assertPathIsFilesystemAbsolute, assertPosixPath, toPosixPath } from '../utils.js';
|
|
8
|
+
function getFilePathUnresolved({ importPathAbsolute }) {
|
|
9
|
+
return getFilePath({ importPathAbsolute, filePathAbsoluteUserRootDir: null });
|
|
21
10
|
}
|
|
22
11
|
function getFilePathResolved(args) {
|
|
23
|
-
const { userRootDir
|
|
12
|
+
const { userRootDir } = args;
|
|
13
|
+
const importPathAbsolute = args.importPathAbsolute ?? null;
|
|
24
14
|
let filePathAbsoluteFilesystem;
|
|
25
15
|
let filePathAbsoluteUserRootDir;
|
|
26
16
|
if ('filePathAbsoluteFilesystem' in args) {
|
|
@@ -31,40 +21,67 @@ function getFilePathResolved(args) {
|
|
|
31
21
|
filePathAbsoluteUserRootDir = args.filePathAbsoluteUserRootDir;
|
|
32
22
|
filePathAbsoluteFilesystem = getFilePathAbsoluteUserFilesystem({ filePathAbsoluteUserRootDir, userRootDir });
|
|
33
23
|
}
|
|
34
|
-
let
|
|
24
|
+
let filePath;
|
|
35
25
|
const common = {
|
|
36
26
|
filePathAbsoluteUserRootDir,
|
|
37
|
-
filePathAbsoluteFilesystem,
|
|
38
27
|
importPathAbsolute,
|
|
39
28
|
userRootDir
|
|
40
29
|
};
|
|
41
30
|
if (importPathAbsolute) {
|
|
42
|
-
|
|
31
|
+
filePath = getFilePath({
|
|
43
32
|
...common,
|
|
44
33
|
importPathAbsolute
|
|
45
34
|
});
|
|
46
35
|
}
|
|
47
36
|
else {
|
|
48
37
|
assert(filePathAbsoluteUserRootDir);
|
|
49
|
-
|
|
38
|
+
filePath = getFilePath({
|
|
50
39
|
...common,
|
|
51
40
|
filePathAbsoluteUserRootDir
|
|
52
41
|
});
|
|
53
42
|
}
|
|
54
43
|
assert(filePathAbsoluteFilesystem);
|
|
55
|
-
|
|
56
|
-
|
|
44
|
+
assertPathIsFilesystemAbsolute(filePathAbsoluteFilesystem);
|
|
45
|
+
const filePathToShowToUserResolved = filePathAbsoluteUserRootDir || filePathAbsoluteFilesystem;
|
|
46
|
+
assert(filePathToShowToUserResolved);
|
|
47
|
+
const filePathResolved = {
|
|
48
|
+
...filePath,
|
|
49
|
+
filePathAbsoluteFilesystem,
|
|
50
|
+
filePathToShowToUserResolved
|
|
51
|
+
};
|
|
57
52
|
return filePathResolved;
|
|
58
53
|
}
|
|
54
|
+
function getFilePath(args) {
|
|
55
|
+
let filePathAbsoluteVite;
|
|
56
|
+
if (args.filePathAbsoluteUserRootDir !== null) {
|
|
57
|
+
filePathAbsoluteVite = args.filePathAbsoluteUserRootDir;
|
|
58
|
+
}
|
|
59
|
+
else {
|
|
60
|
+
assert(args.importPathAbsolute !== null); // Help TS
|
|
61
|
+
filePathAbsoluteVite = args.importPathAbsolute;
|
|
62
|
+
}
|
|
63
|
+
const filePathToShowToUser = filePathAbsoluteVite;
|
|
64
|
+
assert(filePathToShowToUser);
|
|
65
|
+
return {
|
|
66
|
+
...args,
|
|
67
|
+
filePathAbsoluteFilesystem: null,
|
|
68
|
+
filePathAbsoluteVite,
|
|
69
|
+
filePathToShowToUser
|
|
70
|
+
};
|
|
71
|
+
}
|
|
59
72
|
function getFilePathAbsoluteUserFilesystem({ filePathAbsoluteUserRootDir, userRootDir }) {
|
|
60
73
|
assertPosixPath(filePathAbsoluteUserRootDir);
|
|
61
74
|
assertPosixPath(userRootDir);
|
|
75
|
+
assertPathIsFilesystemAbsolute(userRootDir);
|
|
62
76
|
const filePathAbsoluteFilesystem = path.posix.join(userRootDir, filePathAbsoluteUserRootDir);
|
|
77
|
+
assertPathIsFilesystemAbsolute(userRootDir);
|
|
63
78
|
return filePathAbsoluteFilesystem;
|
|
64
79
|
}
|
|
65
80
|
function getFilePathAbsoluteUserRootDir({ filePathAbsoluteFilesystem, userRootDir }) {
|
|
66
81
|
assertPosixPath(filePathAbsoluteFilesystem);
|
|
67
82
|
assertPosixPath(userRootDir);
|
|
83
|
+
assertPathIsFilesystemAbsolute(filePathAbsoluteFilesystem);
|
|
84
|
+
assertPathIsFilesystemAbsolute(userRootDir);
|
|
68
85
|
const filePathRelative = path.posix.relative(userRootDir, filePathAbsoluteFilesystem);
|
|
69
86
|
if (!filePathAbsoluteFilesystem.startsWith(userRootDir)) {
|
|
70
87
|
assert(filePathRelative.startsWith('../'));
|
|
@@ -72,11 +89,48 @@ function getFilePathAbsoluteUserRootDir({ filePathAbsoluteFilesystem, userRootDi
|
|
|
72
89
|
}
|
|
73
90
|
assert(!filePathRelative.startsWith('.') && !filePathRelative.startsWith('/'));
|
|
74
91
|
const filePathAbsoluteUserRootDir = `/${filePathRelative}`;
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
92
|
+
assert(filePathAbsoluteUserRootDir === getFilePathAbsoluteUserRootDir2(filePathAbsoluteFilesystem, userRootDir));
|
|
93
|
+
return filePathAbsoluteUserRootDir;
|
|
94
|
+
}
|
|
95
|
+
function getModuleFilePath(moduleId, config) {
|
|
96
|
+
const userRootDir = config.root;
|
|
97
|
+
assertPosixPath(moduleId);
|
|
98
|
+
assertPosixPath(userRootDir);
|
|
99
|
+
const filePathAbsoluteFilesystem = cleanModuleId(moduleId);
|
|
100
|
+
assertPathIsFilesystemAbsolute(filePathAbsoluteFilesystem);
|
|
101
|
+
const filePath = getFilePathResolved({ filePathAbsoluteFilesystem, userRootDir });
|
|
102
|
+
return filePath.filePathToShowToUserResolved;
|
|
103
|
+
}
|
|
104
|
+
function getFilePathToShowToUserFromUnkown(
|
|
105
|
+
// We don't have any guarentee about filePath, e.g. about whether is filePathAbsoluteFilesystem or filePathAbsoluteUserRootDir
|
|
106
|
+
filePathUnkown, userRootDir) {
|
|
107
|
+
assertPosixPath(userRootDir);
|
|
108
|
+
assertPathIsFilesystemAbsolute(userRootDir);
|
|
109
|
+
filePathUnkown = cleanFilePathUnkown(filePathUnkown);
|
|
110
|
+
if (!filePathUnkown.startsWith(userRootDir)) {
|
|
111
|
+
return filePathUnkown;
|
|
80
112
|
}
|
|
113
|
+
else {
|
|
114
|
+
return getFilePathAbsoluteUserRootDir2(filePathUnkown, userRootDir);
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
function getFilePathAbsoluteUserRootDir2(filePathAbsoluteFilesystem, userRootDir) {
|
|
118
|
+
assert(filePathAbsoluteFilesystem.startsWith(userRootDir));
|
|
119
|
+
let filePathAbsoluteUserRootDir = filePathAbsoluteFilesystem.slice(userRootDir.length);
|
|
120
|
+
if (!filePathAbsoluteUserRootDir.startsWith('/'))
|
|
121
|
+
filePathAbsoluteUserRootDir = '/' + filePathAbsoluteUserRootDir;
|
|
81
122
|
return filePathAbsoluteUserRootDir;
|
|
82
123
|
}
|
|
124
|
+
function cleanFilePathUnkown(filePathUnknown) {
|
|
125
|
+
filePathUnknown = toPosixPath(filePathUnknown);
|
|
126
|
+
filePathUnknown = cleanModuleId(filePathUnknown);
|
|
127
|
+
return filePathUnknown;
|
|
128
|
+
}
|
|
129
|
+
function cleanModuleId(moduleId) {
|
|
130
|
+
// remove query
|
|
131
|
+
const parts = moduleId.split('?');
|
|
132
|
+
if (parts.length > 1)
|
|
133
|
+
parts.pop();
|
|
134
|
+
assert(parts.length >= 1);
|
|
135
|
+
return parts.join('?');
|
|
136
|
+
}
|
|
@@ -7,7 +7,8 @@ export { isEquivalentErrorWithCodeSnippet };
|
|
|
7
7
|
export { getPrettyErrMessage };
|
|
8
8
|
// Copied & adapted from https://github.com/vitejs/vite/blob/9c114c5c72a6af87e3330d5573362554b4511265/packages/vite/src/node/server/middlewares/error.ts
|
|
9
9
|
import pc from '@brillout/picocolors';
|
|
10
|
-
import { assert, escapeRegex,
|
|
10
|
+
import { assert, escapeRegex, isObject, removeEmptyLines, stripAnsi } from '../../utils.js';
|
|
11
|
+
import { cleanFilePathUnkown, getFilePathToShowToUserFromUnkown } from '../getFilePath.js';
|
|
11
12
|
function isErrorWithCodeSnippet(err) {
|
|
12
13
|
if (!isObject(err)) {
|
|
13
14
|
return false;
|
|
@@ -46,7 +47,7 @@ function getPrettyErrorWithCodeSnippet(err, userRootDir) {
|
|
|
46
47
|
let { id, frame } = err;
|
|
47
48
|
const msgFirstLine = [
|
|
48
49
|
pc.red('Failed to transpile'),
|
|
49
|
-
pc.bold(pc.red(
|
|
50
|
+
pc.bold(pc.red(getFilePathToShowToUserFromUnkown(id, userRootDir))),
|
|
50
51
|
pc.red('because:')
|
|
51
52
|
].join(' ');
|
|
52
53
|
const errMsg = getPrettyErrMessage(err);
|
|
@@ -85,7 +86,7 @@ function getPrettyErrMessage(err) {
|
|
|
85
86
|
// Remove "/home/rom/code/vike/examples/react-full/components/Counter.tsx:1:8:" (redundant since we already print the filename)
|
|
86
87
|
const pos = /(?:\:\d+|)/;
|
|
87
88
|
errMsg = errMsg.split(reg([id, pos, pos, trail], 'gi')).join('');
|
|
88
|
-
errMsg = errMsg.split(reg([
|
|
89
|
+
errMsg = errMsg.split(reg([cleanFilePathUnkown(id), pos, pos, trail], 'gi')).join('');
|
|
89
90
|
// Remove "ERROR:" (useless)
|
|
90
91
|
errMsg = errMsg.split(reg(['ERROR:', trail])).join('');
|
|
91
92
|
// Remove "Internal server error:" (useless)
|
|
@@ -155,9 +156,3 @@ function isEquivalentErrorWithCodeSnippet(err1, err2) {
|
|
|
155
156
|
function isDefinedAndSame(val1, val2) {
|
|
156
157
|
return val1 && val1 === val2;
|
|
157
158
|
}
|
|
158
|
-
function normalizeId(id) {
|
|
159
|
-
id = toPosixPath(id);
|
|
160
|
-
// remove query
|
|
161
|
-
id = id.split('?')[0];
|
|
162
|
-
return id;
|
|
163
|
-
}
|
|
@@ -14,7 +14,7 @@ export { clearLogs };
|
|
|
14
14
|
import { isAbortError } from '../../../shared/route/abort.js';
|
|
15
15
|
import { getViteConfig } from '../../runtime/globalContext.js';
|
|
16
16
|
import { overwriteRuntimeProductionLogger } from '../../runtime/renderPage/loggerRuntime.js';
|
|
17
|
-
import { assert, assertIsNotProductionRuntime, formatHintLog, getAssertErrMsg,
|
|
17
|
+
import { assert, assertIsNotProductionRuntime, formatHintLog, getAssertErrMsg, overwriteAssertProductionLogger, stripAnsi, warnIfErrorIsNotObject } from '../utils.js';
|
|
18
18
|
import { getHttpRequestAsyncStore } from './getHttpRequestAsyncStore.js';
|
|
19
19
|
import { isErrorDebug } from './isErrorDebug.js';
|
|
20
20
|
import { isErrorWithCodeSnippet, getPrettyErrorWithCodeSnippet } from './loggerNotProd/errorWithCodeSnippet.js';
|
|
@@ -24,6 +24,7 @@ import pc from '@brillout/picocolors';
|
|
|
24
24
|
import { setAlreadyLogged } from '../../runtime/renderPage/isNewError.js';
|
|
25
25
|
import { isConfigInvalid } from '../../runtime/renderPage/isConfigInvalid.js';
|
|
26
26
|
import { onRuntimeError } from '../../runtime/renderPage/loggerProd.js';
|
|
27
|
+
import { isUserHookError } from '../../../shared/hooks/executeHook.js';
|
|
27
28
|
assertIsNotProductionRuntime();
|
|
28
29
|
overwriteRuntimeProductionLogger(logRuntimeError, logRuntimeInfo);
|
|
29
30
|
overwriteAssertProductionLogger(assertLogger);
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
export * from '../runtime/utils.js';
|
|
2
2
|
export * from '../../utils/viteIsSSR.js';
|
|
3
|
-
export * from '../../utils/getFilePathAbsolute.js';
|
|
4
3
|
export * from '../../utils/requireResolve.js';
|
|
5
4
|
export * from '../../utils/arrayIncludes.js';
|
|
6
5
|
export * from '../../utils/isDev.js';
|
|
@@ -20,3 +19,4 @@ export * from '../../utils/injectRollupInputs.js';
|
|
|
20
19
|
export * from '../../utils/humanizeTime.js';
|
|
21
20
|
export * from '../../utils/pLimit.js';
|
|
22
21
|
export * from '../../utils/assertVersion.js';
|
|
22
|
+
export * from '../../utils/assertPathIsFilesystemAbsolute.js';
|
|
@@ -6,7 +6,6 @@ onLoad();
|
|
|
6
6
|
export * from '../runtime/utils.js';
|
|
7
7
|
// Utils only needed by `plugin/*`
|
|
8
8
|
export * from '../../utils/viteIsSSR.js';
|
|
9
|
-
export * from '../../utils/getFilePathAbsolute.js';
|
|
10
9
|
export * from '../../utils/requireResolve.js';
|
|
11
10
|
export * from '../../utils/arrayIncludes.js';
|
|
12
11
|
export * from '../../utils/isDev.js';
|
|
@@ -26,3 +25,4 @@ export * from '../../utils/injectRollupInputs.js';
|
|
|
26
25
|
export * from '../../utils/humanizeTime.js';
|
|
27
26
|
export * from '../../utils/pLimit.js';
|
|
28
27
|
export * from '../../utils/assertVersion.js';
|
|
28
|
+
export * from '../../utils/assertPathIsFilesystemAbsolute.js';
|
|
@@ -5,8 +5,7 @@ export { runPrerender_forceExit };
|
|
|
5
5
|
import '../runtime/page-files/setup.js';
|
|
6
6
|
import path from 'path';
|
|
7
7
|
import { route } from '../../shared/route/index.js';
|
|
8
|
-
import { assert, assertUsage, assertWarning, hasProp, projectInfo, objectAssign, isObjectWithKeys, isCallable, getOutDirs, isPropertyGetter, assertPosixPath, urlToFile,
|
|
9
|
-
import { pLimit } from '../../utils/pLimit.js';
|
|
8
|
+
import { assert, assertUsage, assertWarning, hasProp, projectInfo, objectAssign, isObjectWithKeys, isCallable, getOutDirs, isPropertyGetter, assertPosixPath, urlToFile, isPlainObject, handleNodeEnv_prerender, pLimit, assertPathIsFilesystemAbsolute } from './utils.js';
|
|
10
9
|
import { prerenderPage, prerender404Page, getRenderContext, getPageContextInitEnhanced } from '../runtime/renderPage/renderPageAlreadyRouted.js';
|
|
11
10
|
import pc from '@brillout/picocolors';
|
|
12
11
|
import { cpus } from 'os';
|
|
@@ -20,13 +19,13 @@ import { getConfigValue, getConfigValueFilePathToShowToUser } from '../../shared
|
|
|
20
19
|
import { loadConfigValues } from '../../shared/page-configs/loadConfigValues.js';
|
|
21
20
|
import { isErrorPage } from '../../shared/error-page.js';
|
|
22
21
|
import { addUrlComputedProps } from '../../shared/addUrlComputedProps.js';
|
|
23
|
-
import { assertPathIsFilesystemAbsolute } from '../../utils/assertPathIsFilesystemAbsolute.js';
|
|
24
22
|
import { isAbortError } from '../../shared/route/abort.js';
|
|
25
23
|
import { loadUserFilesServerSide } from '../runtime/renderPage/loadUserFilesServerSide.js';
|
|
26
24
|
import { getHookFromPageConfig, getHookFromPageConfigGlobal, getHookTimeoutDefault, setIsPrerenderering } from '../../shared/hooks/getHook.js';
|
|
27
25
|
import { noRouteMatch } from '../../shared/route/noRouteMatch.js';
|
|
28
26
|
import { getVikeConfig } from '../plugin/plugins/importUserCode/v1-design/getVikeConfig.js';
|
|
29
27
|
import { logErrorHint } from '../runtime/renderPage/logErrorHint.js';
|
|
28
|
+
import { executeHook, isUserHookError } from '../../shared/hooks/executeHook.js';
|
|
30
29
|
async function runPrerenderFromAPI(options = {}) {
|
|
31
30
|
await runPrerender(options, 'prerender()');
|
|
32
31
|
// - We purposely propagate the error to the user land, so that the error interrupts the user land. It's also, I guess, a nice-to-have that the user has control over the error.
|
|
@@ -8,6 +8,7 @@ export * from '../../utils/getOutDirs.js';
|
|
|
8
8
|
export * from '../../utils/isPropertyGetter.js';
|
|
9
9
|
export * from '../../utils/filesystemPathHandling.js';
|
|
10
10
|
export * from '../../utils/urlToFile.js';
|
|
11
|
-
export * from '../../shared/hooks/executeHook.js';
|
|
12
11
|
export * from '../../utils/isPlainObject.js';
|
|
13
12
|
export * from '../../utils/assertNodeEnv.js';
|
|
13
|
+
export * from '../../utils/pLimit.js';
|
|
14
|
+
export * from '../../utils/assertPathIsFilesystemAbsolute.js';
|
|
@@ -10,6 +10,7 @@ export * from '../../utils/getOutDirs.js';
|
|
|
10
10
|
export * from '../../utils/isPropertyGetter.js';
|
|
11
11
|
export * from '../../utils/filesystemPathHandling.js';
|
|
12
12
|
export * from '../../utils/urlToFile.js';
|
|
13
|
-
export * from '../../shared/hooks/executeHook.js';
|
|
14
13
|
export * from '../../utils/isPlainObject.js';
|
|
15
14
|
export * from '../../utils/assertNodeEnv.js';
|
|
15
|
+
export * from '../../utils/pLimit.js';
|
|
16
|
+
export * from '../../utils/assertPathIsFilesystemAbsolute.js';
|