vike 0.4.223 → 0.4.224-commit-00ed9fe
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/node/api/build.js +4 -37
- package/dist/cjs/node/api/prepareViteApiCall.js +9 -3
- package/dist/cjs/node/plugin/index.js +8 -20
- package/dist/cjs/node/plugin/plugins/baseUrls.js +3 -1
- package/dist/cjs/node/plugin/plugins/{buildConfig/fixServerAssets.js → build/handleAssetsManifest.js} +130 -52
- package/dist/cjs/node/plugin/plugins/build/pluginAutoFullBuild.js +145 -0
- package/dist/cjs/node/plugin/plugins/build/pluginBuildApp.js +52 -0
- package/dist/cjs/node/plugin/plugins/{buildConfig.js → build/pluginBuildConfig.js} +22 -84
- package/dist/cjs/node/plugin/plugins/{buildEntry/index.js → build/pluginBuildEntry.js} +9 -9
- package/dist/cjs/node/plugin/plugins/{distFileNames.js → build/pluginDistFileNames.js} +7 -7
- package/dist/cjs/node/plugin/plugins/{packageJsonFile.js → build/pluginDistPackageJsonFile.js} +6 -6
- package/dist/cjs/node/plugin/plugins/{suppressRollupWarning.js → build/pluginSuppressRollupWarning.js} +3 -3
- package/dist/cjs/node/plugin/plugins/build.js +21 -0
- package/dist/cjs/node/plugin/plugins/commonConfig.js +22 -4
- package/dist/cjs/node/plugin/plugins/devConfig/determineFsAllowList.js +1 -1
- package/dist/cjs/node/plugin/plugins/devConfig/determineOptimizeDeps.js +5 -5
- package/dist/cjs/node/plugin/plugins/devConfig/index.js +1 -1
- package/dist/cjs/node/plugin/plugins/envVars.js +2 -2
- package/dist/cjs/node/plugin/plugins/extractAssetsPlugin.js +9 -9
- package/dist/cjs/node/plugin/plugins/extractExportNamesPlugin.js +2 -2
- package/dist/cjs/node/plugin/plugins/fileEnv.js +5 -2
- package/dist/cjs/node/plugin/plugins/importUserCode/getVirtualFileImportUserCode.js +3 -3
- package/dist/cjs/node/plugin/plugins/importUserCode/index.js +2 -5
- package/dist/cjs/node/plugin/plugins/importUserCode/v1-design/getVikeConfig/assertExtensions.js +5 -5
- package/dist/cjs/node/plugin/plugins/importUserCode/v1-design/getVikeConfig/configDefinitionsBuiltIn.js +7 -2
- package/dist/cjs/node/plugin/plugins/importUserCode/v1-design/getVikeConfig/crawlPlusFiles/ignorePatternsBuiltIn.js +16 -0
- package/dist/cjs/node/plugin/plugins/importUserCode/v1-design/getVikeConfig/crawlPlusFiles.js +50 -64
- package/dist/cjs/node/plugin/plugins/importUserCode/v1-design/getVikeConfig/filesystemRouting.js +2 -1
- package/dist/cjs/node/plugin/plugins/importUserCode/v1-design/getVikeConfig/getPlusFilesAll.js +3 -3
- package/dist/cjs/node/plugin/plugins/importUserCode/v1-design/getVikeConfig/transpileAndExecuteFile.js +19 -7
- package/dist/cjs/node/plugin/plugins/importUserCode/v1-design/getVikeConfig.js +277 -212
- package/dist/cjs/node/plugin/plugins/importUserCode/v1-design/virtual-files/getVirtualFilePageConfigValuesAll.js +4 -4
- package/dist/cjs/node/plugin/plugins/previewConfig.js +12 -7
- package/dist/cjs/node/plugin/shared/addSsrMiddleware.js +5 -1
- package/dist/cjs/node/plugin/shared/findPageFiles.js +3 -3
- package/dist/cjs/node/plugin/shared/getOutDirs.js +8 -7
- package/dist/cjs/node/plugin/shared/isViteServerBuild.js +47 -0
- package/dist/cjs/node/plugin/shared/resolveClientEntriesDev.js +1 -1
- package/dist/cjs/node/plugin/utils.js +1 -0
- package/dist/cjs/node/prerender/context.js +3 -8
- package/dist/cjs/node/prerender/resolvePrerenderConfig.js +30 -21
- package/dist/cjs/node/prerender/runPrerender.js +28 -30
- package/dist/cjs/node/prerender/utils.js +1 -0
- package/dist/cjs/node/runtime/html/stream.js +7 -0
- package/dist/cjs/node/runtime/renderPage/createHttpResponse/assertNoInfiniteHttpRedirect.js +13 -5
- package/dist/cjs/node/runtime/renderPage/createHttpResponse.js +2 -4
- package/dist/cjs/node/runtime/renderPage/logErrorHint.js +13 -2
- package/dist/cjs/node/runtime/renderPage.js +6 -10
- package/dist/cjs/shared/getPageContextUrlComputed.js +1 -1
- package/dist/cjs/shared/page-configs/getConfigValueBuildTime.js +2 -5
- package/dist/cjs/shared/page-configs/serialize/parsePageConfigs.js +3 -1
- package/dist/cjs/shared/page-configs/serialize/serializeConfigValues.js +20 -9
- package/dist/cjs/utils/PROJECT_VERSION.js +1 -1
- package/dist/cjs/utils/debug.js +2 -1
- package/dist/cjs/utils/findFile.js +1 -1
- package/dist/cjs/utils/findPackageJson.js +1 -1
- package/dist/cjs/utils/isFilePathAbsoluteFilesystem.js +10 -4
- package/dist/cjs/utils/parseUrl-extras.js +1 -0
- package/dist/cjs/utils/path.js +1 -0
- package/dist/cjs/utils/requireResolve.js +11 -4
- package/dist/cjs/utils/sorter.js +0 -3
- package/dist/esm/client/client-routing-runtime/index.d.ts +1 -0
- package/dist/esm/client/client-routing-runtime/index.js +1 -0
- package/dist/esm/client/client-routing-runtime/renderPageClientSide.d.ts +8 -0
- package/dist/esm/client/client-routing-runtime/renderPageClientSide.js +10 -1
- package/dist/esm/node/api/build.js +4 -4
- package/dist/esm/node/api/prepareViteApiCall.js +9 -3
- package/dist/esm/node/plugin/index.d.ts +2 -1
- package/dist/esm/node/plugin/index.js +4 -17
- package/dist/esm/node/plugin/plugins/baseUrls.js +3 -1
- package/dist/esm/node/plugin/plugins/build/handleAssetsManifest.d.ts +18 -0
- package/dist/esm/node/plugin/plugins/{buildConfig/fixServerAssets.js → build/handleAssetsManifest.js} +131 -53
- package/dist/esm/node/plugin/plugins/build/pluginAutoFullBuild.d.ts +5 -0
- package/dist/esm/node/plugin/plugins/build/pluginAutoFullBuild.js +140 -0
- package/dist/esm/node/plugin/plugins/build/pluginBuildApp.d.ts +3 -0
- package/dist/esm/node/plugin/plugins/build/pluginBuildApp.js +50 -0
- package/dist/esm/node/plugin/plugins/{buildConfig.d.ts → build/pluginBuildConfig.d.ts} +3 -3
- package/dist/esm/node/plugin/plugins/{buildConfig.js → build/pluginBuildConfig.js} +22 -81
- package/dist/esm/node/plugin/plugins/build/pluginBuildEntry.d.ts +7 -0
- package/dist/esm/node/plugin/plugins/{buildEntry/index.js → build/pluginBuildEntry.js} +9 -9
- package/dist/esm/node/plugin/plugins/build/pluginDistFileNames.d.ts +3 -0
- package/dist/esm/node/plugin/plugins/{distFileNames.js → build/pluginDistFileNames.js} +7 -7
- package/dist/esm/node/plugin/plugins/build/pluginDistPackageJsonFile.d.ts +3 -0
- package/dist/esm/node/plugin/plugins/{packageJsonFile.js → build/pluginDistPackageJsonFile.js} +7 -6
- package/dist/esm/node/plugin/plugins/build/pluginSuppressRollupWarning.d.ts +3 -0
- package/dist/esm/node/plugin/plugins/{suppressRollupWarning.js → build/pluginSuppressRollupWarning.js} +3 -3
- package/dist/esm/node/plugin/plugins/build.d.ts +3 -0
- package/dist/esm/node/plugin/plugins/build.js +19 -0
- package/dist/esm/node/plugin/plugins/commonConfig.d.ts +16 -6
- package/dist/esm/node/plugin/plugins/commonConfig.js +22 -4
- package/dist/esm/node/plugin/plugins/devConfig/determineFsAllowList.js +1 -1
- package/dist/esm/node/plugin/plugins/devConfig/determineOptimizeDeps.js +5 -5
- package/dist/esm/node/plugin/plugins/devConfig/index.js +1 -1
- package/dist/esm/node/plugin/plugins/envVars.js +2 -2
- package/dist/esm/node/plugin/plugins/extractAssetsPlugin.js +10 -10
- package/dist/esm/node/plugin/plugins/extractExportNamesPlugin.js +2 -2
- package/dist/esm/node/plugin/plugins/fileEnv.js +5 -2
- package/dist/esm/node/plugin/plugins/importUserCode/getVirtualFileImportUserCode.js +3 -3
- package/dist/esm/node/plugin/plugins/importUserCode/index.js +2 -5
- package/dist/esm/node/plugin/plugins/importUserCode/v1-design/getVikeConfig/assertExtensions.js +5 -5
- package/dist/esm/node/plugin/plugins/importUserCode/v1-design/getVikeConfig/configDefinitionsBuiltIn.js +7 -2
- package/dist/esm/node/plugin/plugins/importUserCode/v1-design/getVikeConfig/crawlPlusFiles/ignorePatternsBuiltIn.d.ts +1 -0
- package/dist/esm/node/plugin/plugins/importUserCode/v1-design/getVikeConfig/crawlPlusFiles/ignorePatternsBuiltIn.js +13 -0
- 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 +50 -64
- package/dist/esm/node/plugin/plugins/importUserCode/v1-design/getVikeConfig/filesystemRouting.js +2 -1
- package/dist/esm/node/plugin/plugins/importUserCode/v1-design/getVikeConfig/getPlusFilesAll.js +3 -3
- package/dist/esm/node/plugin/plugins/importUserCode/v1-design/getVikeConfig/transpileAndExecuteFile.d.ts +0 -1
- package/dist/esm/node/plugin/plugins/importUserCode/v1-design/getVikeConfig/transpileAndExecuteFile.js +20 -8
- package/dist/esm/node/plugin/plugins/importUserCode/v1-design/getVikeConfig.d.ts +8 -6
- package/dist/esm/node/plugin/plugins/importUserCode/v1-design/getVikeConfig.js +279 -214
- package/dist/esm/node/plugin/plugins/importUserCode/v1-design/virtual-files/getVirtualFilePageConfigValuesAll.js +4 -4
- package/dist/esm/node/plugin/plugins/previewConfig.js +12 -7
- package/dist/esm/node/plugin/shared/addSsrMiddleware.d.ts +1 -1
- package/dist/esm/node/plugin/shared/addSsrMiddleware.js +5 -1
- package/dist/esm/node/plugin/shared/findPageFiles.js +3 -3
- package/dist/esm/node/plugin/shared/getHttpRequestAsyncStore.js +1 -3
- package/dist/esm/node/plugin/shared/getOutDirs.d.ts +2 -2
- package/dist/esm/node/plugin/shared/getOutDirs.js +8 -7
- package/dist/esm/node/plugin/shared/isViteServerBuild.d.ts +15 -0
- package/dist/esm/node/plugin/shared/isViteServerBuild.js +45 -0
- package/dist/esm/node/plugin/shared/resolveClientEntriesDev.js +1 -1
- package/dist/esm/node/plugin/utils.d.ts +1 -0
- package/dist/esm/node/plugin/utils.js +1 -0
- package/dist/esm/node/prerender/context.d.ts +0 -2
- package/dist/esm/node/prerender/context.js +4 -9
- package/dist/esm/node/prerender/resolvePrerenderConfig.d.ts +11 -6
- package/dist/esm/node/prerender/resolvePrerenderConfig.js +31 -22
- package/dist/esm/node/prerender/runPrerender.d.ts +7 -25
- package/dist/esm/node/prerender/runPrerender.js +29 -31
- package/dist/esm/node/prerender/utils.d.ts +1 -0
- package/dist/esm/node/prerender/utils.js +1 -0
- package/dist/esm/node/runtime/globalContext.d.ts +3 -2
- package/dist/esm/node/runtime/html/stream.js +7 -0
- package/dist/esm/node/runtime/renderPage/createHttpResponse/assertNoInfiniteHttpRedirect.d.ts +3 -1
- package/dist/esm/node/runtime/renderPage/createHttpResponse/assertNoInfiniteHttpRedirect.js +14 -6
- package/dist/esm/node/runtime/renderPage/createHttpResponse.d.ts +3 -1
- package/dist/esm/node/runtime/renderPage/createHttpResponse.js +2 -4
- package/dist/esm/node/runtime/renderPage/logErrorHint.js +13 -2
- package/dist/esm/node/runtime/renderPage/renderPageAlreadyRouted.d.ts +165 -5
- package/dist/esm/node/runtime/renderPage.js +7 -11
- package/dist/esm/shared/getPageContextUrlComputed.js +1 -1
- package/dist/esm/shared/page-configs/Config.d.ts +12 -2
- package/dist/esm/shared/page-configs/PageConfig.d.ts +5 -5
- package/dist/esm/shared/page-configs/getConfigValueBuildTime.js +2 -5
- package/dist/esm/shared/page-configs/serialize/parsePageConfigs.js +3 -1
- package/dist/esm/shared/page-configs/serialize/serializeConfigValues.d.ts +2 -0
- package/dist/esm/shared/page-configs/serialize/serializeConfigValues.js +20 -9
- package/dist/esm/types/index.d.ts +2 -0
- package/dist/esm/utils/PROJECT_VERSION.d.ts +1 -1
- package/dist/esm/utils/PROJECT_VERSION.js +1 -1
- package/dist/esm/utils/debug.js +2 -1
- package/dist/esm/utils/findFile.js +1 -1
- package/dist/esm/utils/findPackageJson.js +1 -1
- package/dist/esm/utils/isFilePathAbsoluteFilesystem.js +8 -2
- package/dist/esm/utils/parseUrl-extras.js +1 -0
- package/dist/esm/utils/path.js +1 -0
- package/dist/esm/utils/projectInfo.d.ts +1 -1
- package/dist/esm/utils/requireResolve.js +11 -4
- package/dist/esm/utils/sorter.d.ts +18 -5
- package/dist/esm/utils/sorter.js +0 -3
- package/package.json +9 -16
- package/dist/cjs/node/plugin/plugins/autoFullBuild.js +0 -119
- package/dist/cjs/node/plugin/plugins/buildApp.js +0 -76
- package/dist/cjs/node/plugin/plugins/removeRequireHookPlugin.js +0 -17
- package/dist/cjs/node/plugin/shared/getFullBuildInlineConfig.js +0 -20
- package/dist/cjs/node/plugin/shared/viteIsSSR.js +0 -31
- package/dist/esm/node/plugin/plugins/autoFullBuild.d.ts +0 -3
- package/dist/esm/node/plugin/plugins/autoFullBuild.js +0 -114
- package/dist/esm/node/plugin/plugins/buildApp.d.ts +0 -3
- package/dist/esm/node/plugin/plugins/buildApp.js +0 -74
- package/dist/esm/node/plugin/plugins/buildConfig/fixServerAssets.d.ts +0 -20
- package/dist/esm/node/plugin/plugins/buildEntry/index.d.ts +0 -8
- package/dist/esm/node/plugin/plugins/distFileNames.d.ts +0 -3
- package/dist/esm/node/plugin/plugins/packageJsonFile.d.ts +0 -3
- package/dist/esm/node/plugin/plugins/removeRequireHookPlugin.d.ts +0 -3
- package/dist/esm/node/plugin/plugins/removeRequireHookPlugin.js +0 -15
- package/dist/esm/node/plugin/plugins/suppressRollupWarning.d.ts +0 -3
- package/dist/esm/node/plugin/shared/getFullBuildInlineConfig.d.ts +0 -2
- package/dist/esm/node/plugin/shared/getFullBuildInlineConfig.js +0 -17
- package/dist/esm/node/plugin/shared/viteIsSSR.d.ts +0 -11
- package/dist/esm/node/plugin/shared/viteIsSSR.js +0 -29
- package/dist-cjs-fixup.mjs +0 -41
|
@@ -29,9 +29,7 @@ function getConfigValue(pageConfig, configName) {
|
|
|
29
29
|
if (!configDef.cumulative) {
|
|
30
30
|
const configValueSource = sources[0];
|
|
31
31
|
(0, utils_js_1.assert)(configValueSource);
|
|
32
|
-
(0, utils_js_1.assert)(configValueSource.
|
|
33
|
-
(0, utils_js_1.assert)(sources.slice(1).every((s) => s.isOverriden === true));
|
|
34
|
-
(0, utils_js_1.assert)('value' in configValueSource);
|
|
32
|
+
(0, utils_js_1.assert)(configValueSource.valueIsLoaded);
|
|
35
33
|
return {
|
|
36
34
|
type: 'standard',
|
|
37
35
|
value: configValueSource.value,
|
|
@@ -52,9 +50,8 @@ function mergeCumulative(configValueSources) {
|
|
|
52
50
|
const value = [];
|
|
53
51
|
const definedAtData = [];
|
|
54
52
|
configValueSources.forEach((configValueSource) => {
|
|
55
|
-
(0, utils_js_1.assert)(configValueSource.isOverriden === false);
|
|
56
53
|
(0, utils_js_1.assert)(configValueSource.configEnv.config === true);
|
|
57
|
-
(0, utils_js_1.assert)(
|
|
54
|
+
(0, utils_js_1.assert)(configValueSource.valueIsLoaded);
|
|
58
55
|
value.push(configValueSource.value);
|
|
59
56
|
definedAtData.push(getDefinedAtFile(configValueSource));
|
|
60
57
|
});
|
|
@@ -66,7 +66,9 @@ function parseConfigValuesSerialized_tmp(configValuesSerialized) {
|
|
|
66
66
|
const { valueSerialized, ...common } = configValueSeriliazed;
|
|
67
67
|
const { value, sideExports } = parseValueSerialized(valueSerialized, configName, () => {
|
|
68
68
|
(0, utils_js_1.assert)(configValueSeriliazed.type !== 'computed');
|
|
69
|
-
|
|
69
|
+
const { definedAtData } = configValueSeriliazed;
|
|
70
|
+
const definedAtFile = Array.isArray(definedAtData) ? definedAtData[0] : definedAtData;
|
|
71
|
+
return definedAtFile;
|
|
70
72
|
});
|
|
71
73
|
addSideExports(sideExports);
|
|
72
74
|
configValue = { value, ...common };
|
|
@@ -5,12 +5,15 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
6
|
exports.serializeConfigValues = serializeConfigValues;
|
|
7
7
|
exports.getConfigValuesBase = getConfigValuesBase;
|
|
8
|
+
exports.isJsonValue = isJsonValue;
|
|
8
9
|
const assertSetup_js_1 = require("../../../utils/assertSetup.js");
|
|
9
10
|
const utils_js_1 = require("../../../node/plugin/utils.js");
|
|
10
11
|
const transformPointerImports_js_1 = require("../../../node/plugin/plugins/importUserCode/v1-design/getVikeConfig/transformPointerImports.js");
|
|
11
12
|
const helpers_js_1 = require("../helpers.js");
|
|
12
13
|
const stringify_1 = require("@brillout/json-serializer/stringify");
|
|
13
14
|
const picocolors_1 = __importDefault(require("@brillout/picocolors"));
|
|
15
|
+
const getVikeConfig_js_1 = require("../../../node/plugin/plugins/importUserCode/v1-design/getVikeConfig.js");
|
|
16
|
+
const stringifyOptions = { forbidReactElements: true };
|
|
14
17
|
const REPLACE_ME_BEFORE = '__VIKE__REPLACE_ME_BEFORE__';
|
|
15
18
|
const REPLACE_ME_AFTER = '__VIKE__REPLACE_ME_AFTER__';
|
|
16
19
|
// This file is never loaded on the client-side but we save it under the vike/shared/ directory in order to collocate it with parsePageConfigs()
|
|
@@ -47,9 +50,8 @@ function serializeConfigValues(pageConfig, importStatements, filesEnv, isEnvMatc
|
|
|
47
50
|
return lines;
|
|
48
51
|
}
|
|
49
52
|
function getValueSerializedFromSource(configValueSource, configName, importStatements, filesEnv) {
|
|
50
|
-
(0, utils_js_1.assert)(configValueSource.isOverriden === false);
|
|
51
53
|
let valueData;
|
|
52
|
-
if (
|
|
54
|
+
if (configValueSource.valueIsLoaded && !configValueSource.valueIsLoadedWithImport) {
|
|
53
55
|
valueData = getValueSerializedWithJson(configValueSource.value, configName, configValueSource.definedAtFilePath, importStatements, filesEnv, configValueSource.configEnv);
|
|
54
56
|
}
|
|
55
57
|
else {
|
|
@@ -101,14 +103,13 @@ function serializeConfigValue(configValueBase, valueData, configName, lines, tab
|
|
|
101
103
|
}
|
|
102
104
|
function getValueSerializedWithImport(configValueSource, importStatements, filesEnv, configName) {
|
|
103
105
|
(0, utils_js_1.assert)(!configValueSource.valueIsFilePath);
|
|
104
|
-
const {
|
|
105
|
-
(0, utils_js_1.assert)(valueIsImportedAtRuntime);
|
|
106
|
+
const { valueIsDefinedByPlusValueFile, definedAtFilePath, configEnv } = configValueSource;
|
|
106
107
|
const { filePathAbsoluteVite, fileExportName } = definedAtFilePath;
|
|
107
|
-
if (
|
|
108
|
+
if (valueIsDefinedByPlusValueFile)
|
|
108
109
|
(0, utils_js_1.assert)(fileExportName === undefined);
|
|
109
110
|
const { importName } = addImportStatement(importStatements, filePathAbsoluteVite, fileExportName || '*', filesEnv, configEnv, configName);
|
|
110
111
|
return {
|
|
111
|
-
type:
|
|
112
|
+
type: valueIsDefinedByPlusValueFile ? 'plus-file' : 'pointer-import',
|
|
112
113
|
valueAsJsCode: importName
|
|
113
114
|
};
|
|
114
115
|
}
|
|
@@ -125,7 +126,7 @@ function valueToJson(value, configName, definedAtData, importStatements, filesEn
|
|
|
125
126
|
try {
|
|
126
127
|
configValueSerialized = (0, stringify_1.stringify)(value, {
|
|
127
128
|
valueName,
|
|
128
|
-
|
|
129
|
+
...stringifyOptions,
|
|
129
130
|
// Replace import strings with import variables.
|
|
130
131
|
// - We don't need this anymore and could remove it.
|
|
131
132
|
// - We temporarily needed it for nested document configs (`config.document.{title,description,favicon}`), but we finally decided to go for flat document configs instead (`config.{title,description,favicon}`).
|
|
@@ -152,6 +153,15 @@ function valueToJson(value, configName, definedAtData, importStatements, filesEn
|
|
|
152
153
|
(0, utils_js_1.assert)(!configValueSerialized.includes(REPLACE_ME_AFTER));
|
|
153
154
|
return configValueSerialized;
|
|
154
155
|
}
|
|
156
|
+
function isJsonValue(value) {
|
|
157
|
+
try {
|
|
158
|
+
(0, stringify_1.stringify)(value, stringifyOptions);
|
|
159
|
+
}
|
|
160
|
+
catch (err) {
|
|
161
|
+
return false;
|
|
162
|
+
}
|
|
163
|
+
return true;
|
|
164
|
+
}
|
|
155
165
|
function logJsonSerializeError(err, configName, definedAtData) {
|
|
156
166
|
/*
|
|
157
167
|
// import { isJsonSerializerError } from '@brillout/json-serializer/stringify'
|
|
@@ -191,7 +201,6 @@ function getConfigValuesBase(pageConfig, isEnvMatch, isEager) {
|
|
|
191
201
|
if (!configDef.cumulative) {
|
|
192
202
|
const source = sources[0];
|
|
193
203
|
(0, utils_js_1.assert)(source);
|
|
194
|
-
(0, utils_js_1.assert)(sources.slice(1).every((s) => s.isOverriden === true));
|
|
195
204
|
if (!isEnvMatch(source.configEnv))
|
|
196
205
|
return 'SKIP';
|
|
197
206
|
const definedAtFile = getDefinedAtFileSource(source);
|
|
@@ -202,7 +211,9 @@ function getConfigValuesBase(pageConfig, isEnvMatch, isEager) {
|
|
|
202
211
|
return { configValueBase, sourceRelevant: source, configName };
|
|
203
212
|
}
|
|
204
213
|
else {
|
|
205
|
-
const sourcesRelevant = sources
|
|
214
|
+
const sourcesRelevant = sources
|
|
215
|
+
.filter((source) => !(0, getVikeConfig_js_1.isOverriden)(source, configName, pageConfig))
|
|
216
|
+
.filter((source) => isEnvMatch(source.configEnv));
|
|
206
217
|
if (sourcesRelevant.length === 0)
|
|
207
218
|
return 'SKIP';
|
|
208
219
|
const definedAtData = [];
|
package/dist/cjs/utils/debug.js
CHANGED
|
@@ -16,6 +16,8 @@ const isArray_js_1 = require("./isArray.js");
|
|
|
16
16
|
// Avoid this to be loaded in the browser. For isomorphic code: instead of `import { createDebugger } from './utils.js'`, use `globalThis.createDebugger()`.
|
|
17
17
|
(0, assert_js_1.assert)(!(0, isBrowser_js_1.isBrowser)());
|
|
18
18
|
globalThis.__brillout_debug_createDebugger = createDebugger;
|
|
19
|
+
// We purposely read process.env.DEBUG early, in order to avoid users from the temptation to set process.env.DEBUG with JavaScript, since reading & writing process.env.DEBUG dynamically leads to inconsistencies: for example https://github.com/vikejs/vike/issues/2239
|
|
20
|
+
const DEBUG = getDEBUG() ?? '';
|
|
19
21
|
const flags = [
|
|
20
22
|
'vike:crawl',
|
|
21
23
|
'vike:error',
|
|
@@ -150,7 +152,6 @@ function assertFlagsActivated() {
|
|
|
150
152
|
});
|
|
151
153
|
}
|
|
152
154
|
function getFlagsActivated() {
|
|
153
|
-
const DEBUG = getDEBUG() ?? '';
|
|
154
155
|
const flagsActivated = DEBUG.match(flagRegex) ?? [];
|
|
155
156
|
const all = DEBUG.includes('vike:*');
|
|
156
157
|
return { flagsActivated, all };
|
|
@@ -8,7 +8,7 @@ const path_1 = __importDefault(require("path"));
|
|
|
8
8
|
const fs_1 = __importDefault(require("fs"));
|
|
9
9
|
const isArray_js_1 = require("./isArray.js");
|
|
10
10
|
const path_js_1 = require("./path.js");
|
|
11
|
-
// We need to be able to crawl the filesystem, regardless of Vike's `$ git ls-files` command call, because we need to fallback if the user didn't setup Git (e.g. we cannot remove the
|
|
11
|
+
// We need to be able to crawl the filesystem, regardless of Vike's `$ git ls-files` command call, because we need to fallback if the user didn't setup Git (e.g. we cannot remove the tinyglobby fallback).
|
|
12
12
|
function findFile(arg, cwd) {
|
|
13
13
|
(0, path_js_1.assertPosixPath)(cwd);
|
|
14
14
|
const filenames = (0, isArray_js_1.isArray)(arg) ? arg : [arg];
|
|
@@ -3,7 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.findPackageJson = findPackageJson;
|
|
4
4
|
const findFile_js_1 = require("./findFile.js");
|
|
5
5
|
const module_1 = require("module");
|
|
6
|
-
// @ts-ignore
|
|
6
|
+
// @ts-ignore `file://${__filename}` is shimmed at dist/cjs by dist-cjs-fixup.js.
|
|
7
7
|
const importMetaUrl = `file://${__filename}`;
|
|
8
8
|
const require_ = (0, module_1.createRequire)(importMetaUrl);
|
|
9
9
|
function findPackageJson(cwd) {
|
|
@@ -5,9 +5,14 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
6
|
exports.assertFilePathAbsoluteFilesystem = assertFilePathAbsoluteFilesystem;
|
|
7
7
|
exports.isFilePathAbsolute = isFilePathAbsolute;
|
|
8
|
-
const
|
|
8
|
+
const node_path_1 = __importDefault(require("node:path"));
|
|
9
9
|
const assert_js_1 = require("./assert.js");
|
|
10
10
|
const path_js_1 = require("./path.js");
|
|
11
|
+
const assertIsNotBrowser_js_1 = require("./assertIsNotBrowser.js");
|
|
12
|
+
const assertSetup_js_1 = require("./assertSetup.js");
|
|
13
|
+
(0, assertIsNotBrowser_js_1.assertIsNotBrowser)();
|
|
14
|
+
// Server runtime shouldn't depend on node:path
|
|
15
|
+
(0, assertSetup_js_1.assertIsNotProductionRuntime)();
|
|
11
16
|
/**
|
|
12
17
|
* Asserts that `filePath` is an absolute file path starting from the filesystem root.
|
|
13
18
|
*
|
|
@@ -18,6 +23,7 @@ function assertFilePathAbsoluteFilesystem(filePath) {
|
|
|
18
23
|
// - For Windows users, the assert is correct.
|
|
19
24
|
// - For Linux users assertFilePathAbsoluteFilesystem() will erroneously succeed if `p` is a path absolute from the user root dir.
|
|
20
25
|
// - But that's okay because the assertion will eventually fail for Windows users.
|
|
26
|
+
// - On Linux there doesn't seem to be a way to distinguish between an absolute path starting from the filesystem root or starting from the user root directory, see comment at isFilePathAbsoluteFilesystem()
|
|
21
27
|
(0, assert_js_1.assert)(isFilePathAbsoluteFilesystem(filePath));
|
|
22
28
|
(0, path_js_1.assertPosixPath)(filePath);
|
|
23
29
|
}
|
|
@@ -33,11 +39,11 @@ function isFilePathAbsoluteFilesystem(filePath) {
|
|
|
33
39
|
// - File path absolute starting from filesystem root, e.g. /home/rom/code/my-app/pages/about/+Page.js
|
|
34
40
|
// - File path absolute starting from user root dir (Vite's `config.root`), e.g. /pages/about/+Page.js
|
|
35
41
|
// - Checking whether `p` starts with the first directory of process.cwd() (or `userRootDir`) can be erroneous, most notably when using docker: https://github.com/vikejs/vike/issues/703
|
|
36
|
-
// - Using require.resolve() would be a solution but
|
|
42
|
+
// - Using require.resolve() or node:fs to check wehther the file/dir exsits would be a solution, but maybe too slow?
|
|
37
43
|
return filePath.startsWith('/');
|
|
38
44
|
}
|
|
39
45
|
else {
|
|
40
|
-
const yes =
|
|
46
|
+
const yes = node_path_1.default.win32.isAbsolute(filePath);
|
|
41
47
|
// Ensure isFilePathAbsoluteFilesystem() returns `false` if path is absolute starting from the user root dir (see comments above).
|
|
42
48
|
if (yes)
|
|
43
49
|
(0, assert_js_1.assert)(!filePath.startsWith('/'));
|
|
@@ -55,5 +61,5 @@ function isFilePathAbsolute(filePath) {
|
|
|
55
61
|
if (filePath.startsWith('/'))
|
|
56
62
|
return true;
|
|
57
63
|
// Seems to be reliable: https://nodejs.org/api/path.html#pathisabsolutepath
|
|
58
|
-
return
|
|
64
|
+
return node_path_1.default.isAbsolute(filePath);
|
|
59
65
|
}
|
|
@@ -94,6 +94,7 @@ function modifyUrlPathname(url, modifier) {
|
|
|
94
94
|
function removeUrlOrigin(url) {
|
|
95
95
|
const { origin, pathnameOriginal, searchOriginal, hashOriginal } = (0, parseUrl_js_1.parseUrl)(url, '/');
|
|
96
96
|
const urlModified = (0, parseUrl_js_1.createUrlFromComponents)(null, pathnameOriginal, searchOriginal, hashOriginal);
|
|
97
|
+
(0, assert_js_1.assert)(urlModified.startsWith('/'));
|
|
97
98
|
return { urlModified, origin };
|
|
98
99
|
}
|
|
99
100
|
function setUrlOrigin(url, origin) {
|
package/dist/cjs/utils/path.js
CHANGED
|
@@ -9,6 +9,7 @@ exports.assertPosixPath = assertPosixPath;
|
|
|
9
9
|
// - Robust shim reference: https://github.com/unjs/pathe
|
|
10
10
|
const assert_js_1 = require("./assert.js");
|
|
11
11
|
const assertIsNotBrowser_js_1 = require("./assertIsNotBrowser.js");
|
|
12
|
+
// While this path shim also works on the client-side, let's try to not use it on the client-side in order to minimize KBs sent to the browser.
|
|
12
13
|
(0, assertIsNotBrowser_js_1.assertIsNotBrowser)();
|
|
13
14
|
/**********************/
|
|
14
15
|
/****** SHIMS *********/
|
|
@@ -7,7 +7,7 @@ const assertSetup_js_1 = require("./assertSetup.js");
|
|
|
7
7
|
const path_js_1 = require("./path.js");
|
|
8
8
|
const isScriptFile_js_1 = require("./isScriptFile.js");
|
|
9
9
|
const module_1 = require("module");
|
|
10
|
-
// @ts-ignore
|
|
10
|
+
// @ts-ignore `file://${__filename}` is shimmed at dist/cjs by dist-cjs-fixup.js.
|
|
11
11
|
const importMetaUrl = `file://${__filename}`;
|
|
12
12
|
const require_ = (0, module_1.createRequire)(importMetaUrl);
|
|
13
13
|
(0, assertIsNotBrowser_js_1.assertIsNotBrowser)();
|
|
@@ -34,6 +34,13 @@ function requireResolve(importPath, cwd) {
|
|
|
34
34
|
return importedFile;
|
|
35
35
|
}
|
|
36
36
|
function removeFileExtention(importPath) {
|
|
37
|
+
// Skip for Bun: https://github.com/vikejs/vike/issues/2204
|
|
38
|
+
//@ts-ignore
|
|
39
|
+
if (typeof Bun !== 'undefined') {
|
|
40
|
+
// https://bun.sh/guides/util/detect-bun
|
|
41
|
+
(0, assert_js_1.assert)(process.versions.bun);
|
|
42
|
+
return importPath;
|
|
43
|
+
}
|
|
37
44
|
for (const ext of isScriptFile_js_1.scriptFileExtensionList) {
|
|
38
45
|
const suffix = `.${ext}`;
|
|
39
46
|
if (importPath.endsWith(suffix)) {
|
|
@@ -47,14 +54,14 @@ function addFileExtensionsToRequireResolve() {
|
|
|
47
54
|
isScriptFile_js_1.scriptFileExtensionList.forEach((ext) => {
|
|
48
55
|
(0, assert_js_1.assert)(!ext.includes('.'));
|
|
49
56
|
ext = `.${ext}`;
|
|
50
|
-
if (!
|
|
51
|
-
|
|
57
|
+
if (!require_.extensions[ext]) {
|
|
58
|
+
require_.extensions[ext] = require_.extensions['.js'];
|
|
52
59
|
added.push(ext);
|
|
53
60
|
}
|
|
54
61
|
});
|
|
55
62
|
const clean = () => {
|
|
56
63
|
added.forEach((ext) => {
|
|
57
|
-
delete
|
|
64
|
+
delete require_.extensions[ext];
|
|
58
65
|
});
|
|
59
66
|
};
|
|
60
67
|
return clean;
|
package/dist/cjs/utils/sorter.js
CHANGED
|
@@ -6,9 +6,6 @@ exports.makeFirst = makeFirst;
|
|
|
6
6
|
exports.makeLast = makeLast;
|
|
7
7
|
exports.reverse = reverse;
|
|
8
8
|
const assert_js_1 = require("./assert.js");
|
|
9
|
-
// -1 => element1 first (i.e. `indexOf(element1) < indexOf(element2)`)
|
|
10
|
-
// +1 => element2 first (i.e. `indexOf(element2) < indexOf(element1)`)
|
|
11
|
-
// 0 => keep original order of element1 and element2
|
|
12
9
|
/**
|
|
13
10
|
* ```js
|
|
14
11
|
* let arr = [
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
export { navigate, reload } from './navigate.js';
|
|
2
2
|
export { prefetch } from './prefetch.js';
|
|
3
|
+
export { getPageContextClient } from './renderPageClientSide.js';
|
|
3
4
|
export { PROJECT_VERSION as version } from './utils.js';
|
|
4
5
|
import type { PageContextBuiltInClientWithClientRouting } from '../../shared/types.js';
|
|
5
6
|
/** @deprecated
|
|
@@ -5,4 +5,5 @@
|
|
|
5
5
|
// Use package.json#exports to make the imports isomorphic.
|
|
6
6
|
export { navigate, reload } from './navigate.js';
|
|
7
7
|
export { prefetch } from './prefetch.js';
|
|
8
|
+
export { getPageContextClient } from './renderPageClientSide.js';
|
|
8
9
|
export { PROJECT_VERSION as version } from './utils.js';
|
|
@@ -2,8 +2,10 @@ export { renderPageClientSide };
|
|
|
2
2
|
export { getRenderCount };
|
|
3
3
|
export { disableClientRouting };
|
|
4
4
|
export { firstRenderStartPromise };
|
|
5
|
+
export { getPageContextClient };
|
|
5
6
|
import { type PageContextFromRewrite } from '../../shared/route/abort.js';
|
|
6
7
|
import { type ScrollTarget } from './setScrollPosition.js';
|
|
8
|
+
import type { PageContextClient } from '../../shared/types.js';
|
|
7
9
|
declare const firstRenderStartPromise: Promise<void>;
|
|
8
10
|
type RenderArgs = {
|
|
9
11
|
scrollTarget: ScrollTarget;
|
|
@@ -24,3 +26,9 @@ declare global {
|
|
|
24
26
|
}
|
|
25
27
|
declare function disableClientRouting(err: unknown, log: boolean): void;
|
|
26
28
|
declare function getRenderCount(): number;
|
|
29
|
+
/**
|
|
30
|
+
* Get the `pageContext` object on the client-side.
|
|
31
|
+
*
|
|
32
|
+
* https://vike.dev/getPageContextClient
|
|
33
|
+
*/
|
|
34
|
+
declare function getPageContextClient(): PageContextClient | null;
|
|
@@ -2,6 +2,7 @@ export { renderPageClientSide };
|
|
|
2
2
|
export { getRenderCount };
|
|
3
3
|
export { disableClientRouting };
|
|
4
4
|
export { firstRenderStartPromise };
|
|
5
|
+
export { getPageContextClient };
|
|
5
6
|
import { assert, isSameErrorMessage, objectAssign, redirectHard, getGlobalObject, executeHook, hasProp, augmentType, genPromise, isCallable, catchInfiniteLoop } from './utils.js';
|
|
6
7
|
import { getPageContextFromClientHooks, getPageContextFromServerHooks, getPageContextFromHooks_isHydration, getPageContextFromHooks_serialized, setPageContextInitIsPassedToClient } from './getPageContextFromHooks.js';
|
|
7
8
|
import { createPageContext } from './createPageContext.js';
|
|
@@ -23,7 +24,6 @@ import { getCurrentUrl } from '../shared/getCurrentUrl.js';
|
|
|
23
24
|
const globalObject = getGlobalObject('client-routing-runtime/renderPageClientSide.ts', (() => {
|
|
24
25
|
const { promise: firstRenderStartPromise, resolve: firstRenderStartPromiseResolve } = genPromise();
|
|
25
26
|
return {
|
|
26
|
-
previousPageContext: null,
|
|
27
27
|
renderCounter: 0,
|
|
28
28
|
firstRenderStartPromise,
|
|
29
29
|
firstRenderStartPromiseResolve
|
|
@@ -484,6 +484,7 @@ async function renderPageClientSide(renderArgs) {
|
|
|
484
484
|
// Add link prefetch handlers
|
|
485
485
|
addLinkPrefetchHandlers_watch();
|
|
486
486
|
addLinkPrefetchHandlers();
|
|
487
|
+
globalObject.renderedPageContext = pageContext;
|
|
487
488
|
stampFinished(urlOriginal);
|
|
488
489
|
}
|
|
489
490
|
}
|
|
@@ -595,3 +596,11 @@ function areKeysEqual(key1, key2) {
|
|
|
595
596
|
return false;
|
|
596
597
|
return key1.length === key2.length && key1.every((_, i) => key1[i] === key2[i]);
|
|
597
598
|
}
|
|
599
|
+
/**
|
|
600
|
+
* Get the `pageContext` object on the client-side.
|
|
601
|
+
*
|
|
602
|
+
* https://vike.dev/getPageContextClient
|
|
603
|
+
*/
|
|
604
|
+
function getPageContextClient() {
|
|
605
|
+
return globalObject.renderedPageContext ?? null;
|
|
606
|
+
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
export { build };
|
|
2
2
|
import { prepareViteApiCall } from './prepareViteApiCall.js';
|
|
3
|
-
import { build as buildVite, version } from 'vite';
|
|
3
|
+
import { build as buildVite, version, createBuilder } from 'vite';
|
|
4
4
|
import assert from 'assert';
|
|
5
5
|
import { isVikeCli } from '../cli/context.js';
|
|
6
6
|
import { isPrerendering } from '../prerender/context.js';
|
|
@@ -12,13 +12,13 @@ import { assertVersion } from './utils.js';
|
|
|
12
12
|
*/
|
|
13
13
|
async function build(options = {}) {
|
|
14
14
|
const { viteConfigEnhanced, vikeConfig } = await prepareViteApiCall(options.viteConfig, 'build');
|
|
15
|
-
// Pass it to
|
|
15
|
+
// Pass it to pluginAutoFullBuild()
|
|
16
16
|
if (viteConfigEnhanced)
|
|
17
17
|
viteConfigEnhanced._viteConfigEnhanced = viteConfigEnhanced;
|
|
18
|
-
if (vikeConfig.global.config.
|
|
18
|
+
if (vikeConfig.global.config.vite6BuilderApp) {
|
|
19
19
|
assertVersion('Vite', version, '6.0.0');
|
|
20
|
-
const { createBuilder } = await import('vite');
|
|
21
20
|
const builder = await createBuilder(viteConfigEnhanced);
|
|
21
|
+
// See Vite plugin vike:build:pluginBuildApp
|
|
22
22
|
await builder.buildApp();
|
|
23
23
|
}
|
|
24
24
|
else {
|
|
@@ -2,7 +2,6 @@ export { prepareViteApiCall };
|
|
|
2
2
|
export { getViteRoot };
|
|
3
3
|
export { assertViteRoot };
|
|
4
4
|
export { normalizeViteRoot };
|
|
5
|
-
// TODO: enable Vike extensions to add Vite plugins
|
|
6
5
|
import { loadConfigFromFile, mergeConfig, resolveConfig } from 'vite';
|
|
7
6
|
import { clearContextApiOperation, setContextApiOperation } from './context.js';
|
|
8
7
|
import { getVikeConfig2 } from '../plugin/plugins/importUserCode/v1-design/getVikeConfig.js';
|
|
@@ -50,7 +49,10 @@ async function getViteRoot(operation) {
|
|
|
50
49
|
}
|
|
51
50
|
async function getInfoFromVite(viteConfigFromOptions, operation) {
|
|
52
51
|
const viteConfigFromUserViteFile = await loadViteConfigFile(viteConfigFromOptions, operation);
|
|
53
|
-
const root = normalizeViteRoot(
|
|
52
|
+
const root = normalizeViteRoot(
|
|
53
|
+
// `viteConfigFromOptions.root` before `viteConfigFromUserViteFile.root` replicates Vite's precedence:
|
|
54
|
+
// https://github.com/vitejs/vite/blob/4f5845a3182fc950eb9cd76d7161698383113b18/packages/vite/src/node/config.ts#L1001
|
|
55
|
+
viteConfigFromOptions?.root ?? viteConfigFromUserViteFile?.root ?? process.cwd());
|
|
54
56
|
globalObject.root = root;
|
|
55
57
|
let vikeVitePluginOptions;
|
|
56
58
|
let viteConfigEnhanced = viteConfigFromOptions;
|
|
@@ -116,7 +118,11 @@ function getResolveConfigArgs(viteConfig = {}, operation) {
|
|
|
116
118
|
return [inlineConfig, command, defaultMode, defaultNodeEnv, isPreview];
|
|
117
119
|
}
|
|
118
120
|
function normalizeViteRoot(root) {
|
|
119
|
-
|
|
121
|
+
// `path.resolve(viteConfigFromUserViteFile.configFile, root)` could be more intuitive than `path.resolve(process.cwd(), root)` but we replicate Vite's behavior (`vite.config.js` should follow Vite's API), see:
|
|
122
|
+
// https://github.com/vitejs/vite/blob/4f5845a3182fc950eb9cd76d7161698383113b18/packages/vite/src/node/config.ts#L1063
|
|
123
|
+
return toPosixPath(
|
|
124
|
+
// Equivalent to `path.resolve(process.cwd(), root)`
|
|
125
|
+
path.resolve(root));
|
|
120
126
|
}
|
|
121
127
|
const errMsg = `A Vite plugin is modifying Vite's setting ${pc.cyan('root')} which is forbidden`;
|
|
122
128
|
async function assertViteRoot2(root, viteConfigEnhanced, operation) {
|
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
export default plugin;
|
|
2
2
|
export { plugin };
|
|
3
3
|
export { plugin as ssr };
|
|
4
|
+
export { getVikeConfigPublic as getVikeConfig } from './plugins/commonConfig.js';
|
|
5
|
+
export { PROJECT_VERSION as version } from './utils.js';
|
|
4
6
|
export type { VikeVitePluginOptions as UserConfig };
|
|
5
7
|
export type { VikeVitePluginOptions };
|
|
6
|
-
export { PROJECT_VERSION as version } from './utils.js';
|
|
7
8
|
type PluginInterop = Record<string, unknown> & {
|
|
8
9
|
name: string;
|
|
9
10
|
};
|
|
@@ -2,21 +2,16 @@ export default plugin;
|
|
|
2
2
|
export { plugin };
|
|
3
3
|
// TODO/v1-release: remove
|
|
4
4
|
export { plugin as ssr };
|
|
5
|
+
export { getVikeConfigPublic as getVikeConfig } from './plugins/commonConfig.js';
|
|
5
6
|
export { PROJECT_VERSION as version } from './utils.js';
|
|
6
7
|
import { assertUsage } from './utils.js';
|
|
7
|
-
import {
|
|
8
|
+
import { build } from './plugins/build.js';
|
|
8
9
|
import { previewConfig } from './plugins/previewConfig.js';
|
|
9
|
-
import { autoFullBuild } from './plugins/autoFullBuild.js';
|
|
10
10
|
import { devConfig } from './plugins/devConfig/index.js';
|
|
11
|
-
import { packageJsonFile } from './plugins/packageJsonFile.js';
|
|
12
|
-
import { removeRequireHookPlugin } from './plugins/removeRequireHookPlugin.js';
|
|
13
11
|
import { importUserCode } from './plugins/importUserCode/index.js';
|
|
14
|
-
import { distFileNames } from './plugins/distFileNames.js';
|
|
15
12
|
import { extractAssetsPlugin } from './plugins/extractAssetsPlugin.js';
|
|
16
13
|
import { extractExportNamesPlugin } from './plugins/extractExportNamesPlugin.js';
|
|
17
|
-
import { suppressRollupWarning } from './plugins/suppressRollupWarning.js';
|
|
18
14
|
import { setGlobalContext } from './plugins/setGlobalContext.js';
|
|
19
|
-
import { buildEntry } from './plugins/buildEntry/index.js';
|
|
20
15
|
import { commonConfig } from './plugins/commonConfig.js';
|
|
21
16
|
import { baseUrls } from './plugins/baseUrls.js';
|
|
22
17
|
import { envVarsPlugin } from './plugins/envVars.js';
|
|
@@ -26,7 +21,6 @@ import { setResolveClientEntriesDev } from '../runtime/renderPage/getPageAssets.
|
|
|
26
21
|
import { resolveClientEntriesDev } from './shared/resolveClientEntriesDev.js';
|
|
27
22
|
import { workaroundCssModuleHmr } from './plugins/workaroundCssModuleHmr.js';
|
|
28
23
|
import { workaroundVite6HmrRegression } from './plugins/workaroundVite6HmrRegression.js';
|
|
29
|
-
import { buildApp } from './plugins/buildApp.js';
|
|
30
24
|
// We don't call this in ./onLoad.ts to avoid a cyclic dependency with utils.ts
|
|
31
25
|
setResolveClientEntriesDev(resolveClientEntriesDev);
|
|
32
26
|
// Return `PluginInterop` instead of `Plugin` to avoid type mismatch upon different Vite versions
|
|
@@ -35,18 +29,11 @@ function plugin(vikeVitePluginOptions = {}) {
|
|
|
35
29
|
...commonConfig(vikeVitePluginOptions),
|
|
36
30
|
importUserCode(),
|
|
37
31
|
...devConfig(),
|
|
38
|
-
...
|
|
39
|
-
...buildApp(),
|
|
32
|
+
...build(),
|
|
40
33
|
previewConfig(),
|
|
41
|
-
...autoFullBuild(),
|
|
42
|
-
packageJsonFile(),
|
|
43
|
-
removeRequireHookPlugin(),
|
|
44
|
-
distFileNames(),
|
|
45
34
|
...extractAssetsPlugin(),
|
|
46
35
|
extractExportNamesPlugin(),
|
|
47
|
-
suppressRollupWarning(),
|
|
48
36
|
...setGlobalContext(),
|
|
49
|
-
...buildEntry(),
|
|
50
37
|
baseUrls(),
|
|
51
38
|
envVarsPlugin(),
|
|
52
39
|
fileEnv(),
|
|
@@ -63,7 +50,7 @@ Object.defineProperty(plugin, 'apply', {
|
|
|
63
50
|
assertUsage(false, `Add ${pc.cyan('vike()')} instead of ${pc.cyan('vike')} to vite.config.js#plugins (i.e. call the function and add the return value instead of adding the function itself)`, { showStackTrace: true });
|
|
64
51
|
}
|
|
65
52
|
});
|
|
66
|
-
//
|
|
53
|
+
// CJS default export `const vike = require('vike/plugin')`
|
|
67
54
|
// - It needs to live at the end of this file, in order to ensure we do it after all assignments to `exports`.
|
|
68
55
|
try {
|
|
69
56
|
module.exports = Object.assign(exports.default, exports);
|
|
@@ -2,6 +2,7 @@ export { baseUrls };
|
|
|
2
2
|
import { resolveBase } from '../../shared/resolveBase.js';
|
|
3
3
|
import { assert } from '../utils.js';
|
|
4
4
|
import { getVikeConfig } from './importUserCode/v1-design/getVikeConfig.js';
|
|
5
|
+
import { getVikeConfigPublic } from './commonConfig.js';
|
|
5
6
|
function baseUrls() {
|
|
6
7
|
let basesResolved;
|
|
7
8
|
return {
|
|
@@ -11,7 +12,8 @@ function baseUrls() {
|
|
|
11
12
|
const isDev = config._isDev;
|
|
12
13
|
assert(typeof isDev === 'boolean');
|
|
13
14
|
const baseViteOriginal = config.base ?? '/__UNSET__'; // '/__UNSET__' because Vite resolves `_baseViteOriginal: null` to `undefined`
|
|
14
|
-
|
|
15
|
+
const vike = getVikeConfigPublic(config);
|
|
16
|
+
basesResolved = resolveBase(baseViteOriginal, vike.config.baseServer ?? null, vike.config.baseAssets ?? null);
|
|
15
17
|
// We cannot define these in configResolved() because Vite picks up the env variables before any configResolved() hook is called
|
|
16
18
|
process.env.BASE_SERVER = basesResolved.baseServer;
|
|
17
19
|
process.env.BASE_ASSETS = basesResolved.baseAssets;
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
export { handleAssetsManifest };
|
|
2
|
+
export { handleAssetsManifest_getBuildConfig };
|
|
3
|
+
export { handleAssetsManifest_isFixEnabled };
|
|
4
|
+
export { handleAssetsManifest_assertUsageCssCodeSplit };
|
|
5
|
+
export { handleAssetsManifest_assertUsageCssTarget };
|
|
6
|
+
import type { Environment, ResolvedConfig, Rollup, UserConfig } from 'vite';
|
|
7
|
+
type Bundle = Rollup.OutputBundle;
|
|
8
|
+
type Options = Rollup.NormalizedOutputOptions;
|
|
9
|
+
declare function handleAssetsManifest_isFixEnabled(config: ResolvedConfig | UserConfig): boolean;
|
|
10
|
+
declare function handleAssetsManifest_assertUsageCssCodeSplit(config: ResolvedConfig): void;
|
|
11
|
+
declare function handleAssetsManifest_assertUsageCssTarget(config: ResolvedConfig): void;
|
|
12
|
+
declare function handleAssetsManifest_getBuildConfig(config: UserConfig): {
|
|
13
|
+
readonly ssrEmitAssets: true | undefined;
|
|
14
|
+
readonly cssMinify: "esbuild" | undefined;
|
|
15
|
+
readonly manifest: "_temp_manifest.json";
|
|
16
|
+
readonly copyPublicDir: boolean | undefined;
|
|
17
|
+
};
|
|
18
|
+
declare function handleAssetsManifest(config: ResolvedConfig, viteEnv: Environment | undefined, options: Options, bundle: Bundle): Promise<void>;
|