vike 0.4.143 → 0.4.144-commit-e40e9b1
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/index.js +2 -2
- package/dist/cjs/node/plugin/plugins/buildConfig.js +1 -1
- package/dist/cjs/node/plugin/plugins/config/index.js +1 -1
- package/dist/cjs/node/plugin/plugins/devConfig/determineOptimizeDeps.js +31 -30
- package/dist/cjs/node/plugin/plugins/importUserCode/generateEagerImport.js +19 -8
- package/dist/cjs/node/plugin/plugins/importUserCode/getVirtualFileImportUserCode.js +19 -10
- package/dist/cjs/node/plugin/plugins/importUserCode/index.js +2 -2
- package/dist/cjs/node/plugin/plugins/importUserCode/v1-design/getFilePathToShowToUser.js +6 -0
- package/dist/cjs/node/plugin/plugins/importUserCode/v1-design/getVikeConfig/configDefinitionsBuiltIn.js +4 -4
- package/dist/cjs/node/plugin/plugins/importUserCode/v1-design/getVikeConfig.js +228 -186
- package/dist/cjs/node/plugin/plugins/importUserCode/v1-design/getVirtualFilePageConfigValuesAll.js +11 -35
- package/dist/cjs/node/plugin/plugins/importUserCode/v1-design/getVirtualFilePageConfigs.js +60 -95
- package/dist/cjs/node/plugin/plugins/importUserCode/v1-design/helpers.js +12 -5
- package/dist/cjs/node/plugin/plugins/importUserCode/v1-design/isRuntimeEnvMatch.js +18 -0
- package/dist/cjs/node/plugin/plugins/importUserCode/v1-design/replaceImportStatements.js +25 -25
- package/dist/cjs/node/plugin/plugins/importUserCode/v1-design/transpileAndExecuteFile.js +14 -13
- package/dist/cjs/node/plugin/shared/findPageFiles.js +2 -1
- package/dist/cjs/node/plugin/shared/{getConfigValueSource.js → getConfigValueSourcesRelevant.js} +1 -12
- package/dist/cjs/node/plugin/shared/loggerNotProd.js +1 -1
- package/dist/cjs/node/plugin/utils.js +2 -3
- package/dist/cjs/node/prerender/runPrerender.js +18 -20
- package/dist/cjs/node/runtime/html/injectAssets/getHtmlTags.js +1 -1
- package/dist/cjs/node/runtime/renderPage/analyzePage.js +2 -2
- package/dist/cjs/node/runtime/renderPage/loadPageFilesServerSide.js +2 -2
- package/dist/cjs/node/runtime/renderPage/log404/index.js +10 -5
- package/dist/cjs/node/runtime/renderPage/renderPageAlreadyRouted.js +3 -2
- package/dist/cjs/node/runtime/renderPage.js +1 -1
- package/dist/cjs/node/shared/getClientEntryFilePath.js +1 -7
- package/dist/cjs/shared/assertPageContextProvidedByUser.js +1 -1
- package/dist/cjs/shared/error-page.js +1 -1
- package/dist/cjs/shared/getPageFiles/getExports.js +8 -11
- package/dist/cjs/shared/getPageFiles/parseGlobResults.js +10 -44
- package/dist/cjs/shared/hooks/getHook.js +3 -1
- package/dist/cjs/shared/page-configs/assertExports.js +60 -0
- package/dist/cjs/shared/page-configs/getExportPath.js +9 -10
- package/dist/cjs/shared/page-configs/loadConfigValues.js +18 -0
- package/dist/cjs/shared/page-configs/serialize/PageConfigSerialized.js +2 -0
- package/dist/cjs/shared/page-configs/serialize/assertPageConfigs.js +19 -0
- package/dist/cjs/shared/page-configs/serialize/parseConfigValuesImported.js +56 -0
- package/dist/cjs/shared/page-configs/serialize/parsePageConfigs.js +65 -0
- package/dist/cjs/shared/page-configs/serialize/serializeConfigValue.js +58 -0
- package/dist/cjs/shared/page-configs/utils.js +65 -42
- package/dist/cjs/shared/route/loadPageRoutes.js +12 -15
- package/dist/cjs/shared/route/resolveRedirects.js +1 -1
- package/dist/cjs/shared/route/resolveRouteFunction.js +1 -0
- package/dist/cjs/shared/utils.js +0 -1
- package/dist/cjs/utils/getOutDirs.js +25 -18
- package/dist/cjs/utils/getValuePrintable.js +1 -1
- package/dist/cjs/utils/objectAssign.js +3 -1
- package/dist/cjs/utils/projectInfo.js +1 -1
- package/dist/cjs/utils/{resolve.js → requireResolve.js} +3 -3
- package/dist/cjs/utils/warnIfErrorIsNotObject.js +1 -1
- package/dist/esm/__internal/index.d.ts +3 -3
- package/dist/esm/client/client-routing-runtime/createPageContext.d.ts +2 -2
- package/dist/esm/client/client-routing-runtime/getPageContext.d.ts +2 -2
- package/dist/esm/client/client-routing-runtime/getPageId.d.ts +2 -2
- package/dist/esm/client/client-routing-runtime/useClientRouter.js +3 -3
- package/dist/esm/client/server-routing-runtime/getPageContext.d.ts +1 -1
- package/dist/esm/client/shared/executeOnRenderClientHook.d.ts +2 -2
- package/dist/esm/client/shared/loadPageFilesClientSide.d.ts +2 -2
- package/dist/esm/client/shared/loadPageFilesClientSide.js +2 -2
- package/dist/esm/client/shared/preparePageContextForUserConsumptionClientSide.d.ts +2 -2
- package/dist/esm/node/plugin/index.js +3 -2
- package/dist/esm/node/plugin/plugins/buildConfig.js +2 -2
- package/dist/esm/node/plugin/plugins/config/index.js +2 -2
- package/dist/esm/node/plugin/plugins/devConfig/determineOptimizeDeps.js +31 -30
- package/dist/esm/node/plugin/plugins/importUserCode/generateEagerImport.d.ts +13 -2
- package/dist/esm/node/plugin/plugins/importUserCode/generateEagerImport.js +19 -8
- package/dist/esm/node/plugin/plugins/importUserCode/getVirtualFileImportUserCode.js +20 -11
- package/dist/esm/node/plugin/plugins/importUserCode/index.js +3 -3
- package/dist/esm/node/plugin/plugins/importUserCode/v1-design/getFilePathToShowToUser.d.ts +19 -2
- package/dist/esm/node/plugin/plugins/importUserCode/v1-design/getFilePathToShowToUser.js +6 -0
- package/dist/esm/node/plugin/plugins/importUserCode/v1-design/getVikeConfig/configDefinitionsBuiltIn.d.ts +5 -4
- package/dist/esm/node/plugin/plugins/importUserCode/v1-design/getVikeConfig/configDefinitionsBuiltIn.js +4 -4
- package/dist/esm/node/plugin/plugins/importUserCode/v1-design/getVikeConfig.d.ts +4 -4
- package/dist/esm/node/plugin/plugins/importUserCode/v1-design/getVikeConfig.js +229 -187
- package/dist/esm/node/plugin/plugins/importUserCode/v1-design/getVirtualFilePageConfigValuesAll.d.ts +1 -1
- package/dist/esm/node/plugin/plugins/importUserCode/v1-design/getVirtualFilePageConfigValuesAll.js +11 -32
- package/dist/esm/node/plugin/plugins/importUserCode/v1-design/getVirtualFilePageConfigs.d.ts +3 -3
- package/dist/esm/node/plugin/plugins/importUserCode/v1-design/getVirtualFilePageConfigs.js +60 -95
- package/dist/esm/node/plugin/plugins/importUserCode/v1-design/helpers.d.ts +3 -3
- package/dist/esm/node/plugin/plugins/importUserCode/v1-design/helpers.js +12 -5
- package/dist/esm/node/plugin/plugins/importUserCode/v1-design/isRuntimeEnvMatch.d.ts +7 -0
- package/dist/esm/node/plugin/plugins/importUserCode/v1-design/isRuntimeEnvMatch.js +15 -0
- package/dist/esm/node/plugin/plugins/importUserCode/v1-design/replaceImportStatements.d.ts +18 -6
- package/dist/esm/node/plugin/plugins/importUserCode/v1-design/replaceImportStatements.js +25 -25
- package/dist/esm/node/plugin/plugins/importUserCode/v1-design/transpileAndExecuteFile.d.ts +2 -2
- package/dist/esm/node/plugin/plugins/importUserCode/v1-design/transpileAndExecuteFile.js +14 -13
- package/dist/esm/node/plugin/shared/findPageFiles.js +3 -2
- package/dist/esm/node/plugin/shared/{getConfigValueSource.d.ts → getConfigValueSourcesRelevant.d.ts} +0 -2
- package/dist/esm/node/plugin/shared/{getConfigValueSource.js → getConfigValueSourcesRelevant.js} +0 -11
- package/dist/esm/node/plugin/shared/loggerNotProd.js +2 -2
- package/dist/esm/node/plugin/utils.d.ts +1 -2
- package/dist/esm/node/plugin/utils.js +2 -3
- package/dist/esm/node/prerender/runPrerender.js +20 -22
- package/dist/esm/node/runtime/html/injectAssets/getHtmlTags.js +1 -1
- package/dist/esm/node/runtime/html/injectAssets.d.ts +2 -2
- package/dist/esm/node/runtime/html/serializePageContextClientSide.d.ts +2 -2
- package/dist/esm/node/runtime/renderPage/analyzePage.d.ts +2 -2
- package/dist/esm/node/runtime/renderPage/analyzePage.js +2 -2
- package/dist/esm/node/runtime/renderPage/createHttpResponseObject.d.ts +2 -2
- package/dist/esm/node/runtime/renderPage/debugPageFiles.d.ts +2 -2
- package/dist/esm/node/runtime/renderPage/executeOnRenderHtmlHook.d.ts +2 -2
- package/dist/esm/node/runtime/renderPage/handleErrorWithoutErrorPage.d.ts +2 -2
- package/dist/esm/node/runtime/renderPage/loadPageFilesServerSide.d.ts +2 -2
- package/dist/esm/node/runtime/renderPage/loadPageFilesServerSide.js +2 -2
- package/dist/esm/node/runtime/renderPage/log404/index.js +10 -5
- package/dist/esm/node/runtime/renderPage/preparePageContextForUserConsumptionServerSide.d.ts +2 -2
- package/dist/esm/node/runtime/renderPage/renderPageAlreadyRouted.d.ts +13 -13
- package/dist/esm/node/runtime/renderPage/renderPageAlreadyRouted.js +3 -2
- package/dist/esm/node/runtime/renderPage.js +1 -1
- package/dist/esm/node/shared/getClientEntryFilePath.d.ts +2 -2
- package/dist/esm/node/shared/getClientEntryFilePath.js +2 -8
- package/dist/esm/shared/addIs404ToPageProps.d.ts +2 -2
- package/dist/esm/shared/addUrlComputedProps.d.ts +4 -2
- package/dist/esm/shared/assertPageContextProvidedByUser.js +1 -1
- package/dist/esm/shared/error-page.d.ts +3 -3
- package/dist/esm/shared/error-page.js +1 -1
- package/dist/esm/shared/getPageFiles/analyzeClientSide.d.ts +2 -2
- package/dist/esm/shared/getPageFiles/getExports.d.ts +3 -4
- package/dist/esm/shared/getPageFiles/getExports.js +7 -10
- package/dist/esm/shared/getPageFiles/parseGlobResults.d.ts +3 -3
- package/dist/esm/shared/getPageFiles/parseGlobResults.js +9 -43
- package/dist/esm/shared/getPageFiles/setPageFiles.d.ts +3 -3
- package/dist/esm/shared/hooks/getHook.js +3 -1
- package/dist/esm/shared/page-configs/Config.d.ts +201 -14
- package/dist/esm/shared/page-configs/PageConfig.d.ts +80 -73
- package/dist/esm/shared/page-configs/assertExports.d.ts +6 -0
- package/dist/esm/shared/page-configs/assertExports.js +54 -0
- package/dist/esm/shared/page-configs/findPageConfig.d.ts +2 -2
- package/dist/esm/shared/page-configs/getExportPath.d.ts +1 -1
- package/dist/esm/shared/page-configs/getExportPath.js +9 -10
- package/dist/esm/shared/page-configs/loadConfigValues.d.ts +3 -0
- package/dist/esm/shared/page-configs/loadConfigValues.js +15 -0
- package/dist/esm/shared/page-configs/serialize/PageConfigSerialized.d.ts +32 -0
- package/dist/esm/shared/page-configs/serialize/PageConfigSerialized.js +1 -0
- package/dist/esm/shared/page-configs/serialize/assertPageConfigs.d.ts +5 -0
- package/dist/esm/shared/page-configs/serialize/assertPageConfigs.js +16 -0
- package/dist/esm/shared/page-configs/serialize/parseConfigValuesImported.d.ts +4 -0
- package/dist/esm/shared/page-configs/serialize/parseConfigValuesImported.js +50 -0
- package/dist/esm/shared/page-configs/serialize/parsePageConfigs.d.ts +7 -0
- package/dist/esm/shared/page-configs/serialize/parsePageConfigs.js +62 -0
- package/dist/esm/shared/page-configs/serialize/serializeConfigValue.d.ts +8 -0
- package/dist/esm/shared/page-configs/serialize/serializeConfigValue.js +52 -0
- package/dist/esm/shared/page-configs/utils.d.ts +21 -14
- package/dist/esm/shared/page-configs/utils.js +64 -41
- package/dist/esm/shared/route/executeGuardHook.d.ts +2 -2
- package/dist/esm/shared/route/index.d.ts +3 -3
- package/dist/esm/shared/route/loadPageRoutes.d.ts +2 -2
- package/dist/esm/shared/route/loadPageRoutes.js +13 -16
- package/dist/esm/shared/route/resolveRedirects.js +1 -1
- package/dist/esm/shared/route/resolveRouteFunction.js +1 -0
- package/dist/esm/shared/types.d.ts +8 -6
- package/dist/esm/shared/utils.d.ts +0 -1
- package/dist/esm/shared/utils.js +0 -1
- package/dist/esm/types/index.d.ts +2 -1
- package/dist/esm/utils/getOutDirs.d.ts +0 -2
- package/dist/esm/utils/getOutDirs.js +24 -17
- package/dist/esm/utils/getValuePrintable.js +1 -1
- package/dist/esm/utils/objectAssign.js +3 -1
- package/dist/esm/utils/projectInfo.d.ts +1 -1
- package/dist/esm/utils/projectInfo.js +1 -1
- package/dist/esm/utils/requireResolve.d.ts +2 -0
- package/dist/esm/utils/{resolve.js → requireResolve.js} +2 -2
- package/dist/esm/utils/warnIfErrorIsNotObject.js +1 -1
- package/package.json +2 -2
- package/dist/cjs/node/plugin/plugins/importUserCode/v1-design/isConfigEnvMatch.js +0 -13
- package/dist/cjs/shared/getPageFiles/assertPageConfigs.js +0 -19
- package/dist/cjs/shared/page-configs/loadPageCode.js +0 -63
- package/dist/cjs/utils/assertDefaultExport.js +0 -53
- package/dist/esm/node/plugin/plugins/importUserCode/v1-design/isConfigEnvMatch.d.ts +0 -3
- package/dist/esm/node/plugin/plugins/importUserCode/v1-design/isConfigEnvMatch.js +0 -10
- package/dist/esm/shared/getPageFiles/assertPageConfigs.d.ts +0 -5
- package/dist/esm/shared/getPageFiles/assertPageConfigs.js +0 -16
- package/dist/esm/shared/page-configs/loadPageCode.d.ts +0 -3
- package/dist/esm/shared/page-configs/loadPageCode.js +0 -57
- package/dist/esm/utils/assertDefaultExport.d.ts +0 -8
- package/dist/esm/utils/assertDefaultExport.js +0 -47
- package/dist/esm/utils/resolve.d.ts +0 -2
- /package/dist/cjs/shared/getPageFiles/{assertExports.js → assert_exports_old_design.js} +0 -0
- /package/dist/esm/shared/getPageFiles/{assertExports.d.ts → assert_exports_old_design.d.ts} +0 -0
- /package/dist/esm/shared/getPageFiles/{assertExports.js → assert_exports_old_design.js} +0 -0
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
export { preparePageContextForUserConsumptionClientSide };
|
|
2
2
|
export type { PageContextForUserConsumptionClientSide };
|
|
3
3
|
import type { PageContextExports } from '../../shared/getPageFiles.js';
|
|
4
|
-
import type {
|
|
4
|
+
import type { PageConfigRuntime } from '../../shared/page-configs/PageConfig.js';
|
|
5
5
|
import { PageContextForPassToClientWarning } from './getPageContextProxyForUser.js';
|
|
6
6
|
type PageContextForUserConsumptionClientSide = PageContextExports & PageContextForPassToClientWarning & {
|
|
7
7
|
_pageId: string;
|
|
8
|
-
_pageConfigs:
|
|
8
|
+
_pageConfigs: PageConfigRuntime[];
|
|
9
9
|
};
|
|
10
10
|
declare function preparePageContextForUserConsumptionClientSide<T extends PageContextForUserConsumptionClientSide>(pageContext: T, isClientRouting: boolean): T & {
|
|
11
11
|
Page: unknown;
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
export default plugin;
|
|
2
2
|
export { plugin };
|
|
3
|
+
// TODO/v1-release: remove
|
|
3
4
|
export { plugin as ssr };
|
|
4
5
|
import { assertUsage, markEnvAsVite } from './utils.js';
|
|
5
6
|
import { buildConfig } from './plugins/buildConfig.js';
|
|
@@ -48,7 +49,7 @@ function plugin(vikeConfig) {
|
|
|
48
49
|
];
|
|
49
50
|
return plugins;
|
|
50
51
|
}
|
|
51
|
-
// Enable `const
|
|
52
|
+
// Enable `const vike = require('vike/plugin')`.
|
|
52
53
|
// - This lives at the end of the file to ensure it happens after all assignments to `exports`.
|
|
53
54
|
// - This is only used for the CJS build; we wrap it in a try-catch for the ESM build.
|
|
54
55
|
try {
|
|
@@ -59,6 +60,6 @@ catch { }
|
|
|
59
60
|
Object.defineProperty(plugin, 'apply', {
|
|
60
61
|
enumerable: true,
|
|
61
62
|
get: () => {
|
|
62
|
-
assertUsage(false, `Add ${pc.cyan('
|
|
63
|
+
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 });
|
|
63
64
|
}
|
|
64
65
|
});
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
export { buildConfig };
|
|
2
2
|
export { assertRollupInput };
|
|
3
3
|
export { analyzeClientEntries };
|
|
4
|
-
import { assert, resolveOutDir, isObject, viteIsSSR, getFilePathAbsolute, addOnBeforeLogHook, removeFileExtention, unique, assertPosixPath, assertUsage } from '../utils.js';
|
|
4
|
+
import { assert, resolveOutDir, isObject, viteIsSSR, getFilePathAbsolute, addOnBeforeLogHook, removeFileExtention, unique, assertPosixPath, assertUsage, getOutDirs, } from '../utils.js';
|
|
5
5
|
import { virtualFileIdImportUserCodeServer } from '../../shared/virtual-files/virtualFileImportUserCode.js';
|
|
6
6
|
import { getVikeConfig } from './importUserCode/v1-design/getVikeConfig.js';
|
|
7
7
|
import { getConfigValue } from '../../../shared/page-configs/utils.js';
|
|
@@ -69,7 +69,7 @@ function buildConfig() {
|
|
|
69
69
|
async function getEntries(config) {
|
|
70
70
|
const configVike = await getConfigVike(config);
|
|
71
71
|
const pageFileEntries = await getPageFileEntries(config, configVike.includeAssetsImportedByServer); // TODO/v1-release: remove
|
|
72
|
-
const { pageConfigs } = await getVikeConfig(config.root, false, configVike.extensions);
|
|
72
|
+
const { pageConfigs } = await getVikeConfig(config.root, getOutDirs(config).outDirRoot, false, configVike.extensions);
|
|
73
73
|
assertUsage(Object.keys(pageFileEntries).length !== 0 || pageConfigs.length !== 0, 'At least one page should be defined, see https://vike.dev/add');
|
|
74
74
|
if (viteIsSSR(config)) {
|
|
75
75
|
const serverEntries = analyzeServerEntries(pageConfigs);
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
export { resolveVikeConfig };
|
|
2
2
|
import { assertVikeConfig } from './assertVikeConfig.js';
|
|
3
|
-
import { isDev2 } from '../../utils.js';
|
|
3
|
+
import { getOutDirs, isDev2 } from '../../utils.js';
|
|
4
4
|
import { findConfigVikeFromStemPackages } from './findConfigVikeFromStemPackages.js';
|
|
5
5
|
import { pickFirst } from './pickFirst.js';
|
|
6
6
|
import { resolveExtensions } from './resolveExtensions.js';
|
|
@@ -24,7 +24,7 @@ async function resolveConfig(vikeConfig, config) {
|
|
|
24
24
|
const fromStemPackages = await findConfigVikeFromStemPackages(config.root);
|
|
25
25
|
const configs = [fromPluginOptions, ...fromStemPackages, fromViteConfig];
|
|
26
26
|
const extensions = resolveExtensions(configs, config);
|
|
27
|
-
const { globalVikeConfig: fromPlusConfigFile } = await getVikeConfig(config.root, isDev2(config), extensions);
|
|
27
|
+
const { globalVikeConfig: fromPlusConfigFile } = await getVikeConfig(config.root, getOutDirs(config).outDirRoot, isDev2(config), extensions);
|
|
28
28
|
configs.push(fromPlusConfigFile);
|
|
29
29
|
assertVikeConfig(fromPlusConfigFile, ({ prop, errMsg }) => {
|
|
30
30
|
// TODO: add config file path ?
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
export { determineOptimizeDeps };
|
|
2
2
|
import { findPageFiles } from '../../shared/findPageFiles.js';
|
|
3
|
-
import { assert, getFilePathAbsolute, isNotNullish, isNpmPackageImport, unique } from '../../utils.js';
|
|
3
|
+
import { assert, getFilePathAbsolute, getOutDirs, isNotNullish, isNpmPackageImport, unique } from '../../utils.js';
|
|
4
4
|
import { getVikeConfig } from '../importUserCode/v1-design/getVikeConfig.js';
|
|
5
|
-
import { getConfigValueSourcesRelevant } from '../../shared/
|
|
5
|
+
import { getConfigValueSourcesRelevant } from '../../shared/getConfigValueSourcesRelevant.js';
|
|
6
6
|
import { analyzeClientEntries } from '../buildConfig.js';
|
|
7
7
|
import { virtualFileIdImportUserCodeClientCR, virtualFileIdImportUserCodeClientSR } from '../../../shared/virtual-files/virtualFileImportUserCode.js';
|
|
8
8
|
async function determineOptimizeDeps(config, configVike, isDev) {
|
|
9
|
-
const { pageConfigs } = await getVikeConfig(config.root, isDev, configVike.extensions);
|
|
9
|
+
const { pageConfigs } = await getVikeConfig(config.root, getOutDirs(config).outDirRoot, isDev, configVike.extensions);
|
|
10
10
|
const { entries, include } = await getPageDeps(config, pageConfigs, isDev);
|
|
11
11
|
{
|
|
12
12
|
// This actually doesn't work: Vite's dep optimizer doesn't seem to be able to crawl virtual files.
|
|
@@ -22,7 +22,7 @@ async function determineOptimizeDeps(config, configVike, isDev) {
|
|
|
22
22
|
*/
|
|
23
23
|
config.optimizeDeps.include = [...include, ...normalizeInclude(config.optimizeDeps.include)];
|
|
24
24
|
config.optimizeDeps.entries = [...entries, ...normalizeEntries(config.optimizeDeps.entries)];
|
|
25
|
-
// console.log('config.optimizeDeps', config.optimizeDeps)
|
|
25
|
+
// console.log('config.optimizeDeps', { entries: config.optimizeDeps.entries, include: config.optimizeDeps.include })
|
|
26
26
|
}
|
|
27
27
|
async function getPageDeps(config, pageConfigs, isDev) {
|
|
28
28
|
let entries = [];
|
|
@@ -32,37 +32,38 @@ async function getPageDeps(config, pageConfigs, isDev) {
|
|
|
32
32
|
pageConfigs.forEach((pageConfig) => {
|
|
33
33
|
const configValueSourcesRelevant = getConfigValueSourcesRelevant(pageConfig);
|
|
34
34
|
configValueSourcesRelevant.forEach((configValueSource) => {
|
|
35
|
-
|
|
36
|
-
if (!valueIsImportedAtRuntime)
|
|
35
|
+
if (!configValueSource.valueIsImportedAtRuntime)
|
|
37
36
|
return;
|
|
38
|
-
const {
|
|
39
|
-
assert(filePath);
|
|
37
|
+
const { definedAtInfo, configEnv } = configValueSource;
|
|
40
38
|
if (configEnv !== 'client-only' && configEnv !== 'server-and-client')
|
|
41
39
|
return;
|
|
42
|
-
if (
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
// getVikeConfig() resolves relative import paths
|
|
48
|
-
assert(!filePath.startsWith('.'));
|
|
49
|
-
// We need to differentiate between npm package imports and path aliases.
|
|
50
|
-
// There are path aliases that cannot be distinguished from npm package names.
|
|
51
|
-
// We recommend users to use the '#' prefix convention for path aliases, see https://vike.dev/path-aliases#vite and assertResolveAlias()
|
|
52
|
-
if (isNpmPackageImport(filePath)) {
|
|
53
|
-
// isNpmPackageImport() returns false for a path alias like #root/renderer/onRenderClient
|
|
54
|
-
assert(!filePath.startsWith('#'));
|
|
55
|
-
include.push(filePath);
|
|
40
|
+
if (definedAtInfo.filePathRelativeToUserRootDir !== null) {
|
|
41
|
+
const { filePathAbsolute } = definedAtInfo;
|
|
42
|
+
assert(filePathAbsolute);
|
|
43
|
+
// Surprisingly Vite expects entries to be absolute paths
|
|
44
|
+
entries.push(filePathAbsolute);
|
|
56
45
|
}
|
|
57
46
|
else {
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
47
|
+
// Adding definedAtInfo.filePathAbsolute doesn't work for npm packages, I guess because of Vite's config.server.fs.allow
|
|
48
|
+
const { importPathAbsolute } = definedAtInfo;
|
|
49
|
+
assert(importPathAbsolute);
|
|
50
|
+
// We need to differentiate between npm package imports and path aliases.
|
|
51
|
+
// There are path aliases that cannot be distinguished from npm package names.
|
|
52
|
+
// We recommend users to use the '#' prefix convention for path aliases, see https://vike.dev/path-aliases#vite and assertResolveAlias()
|
|
53
|
+
if (isNpmPackageImport(importPathAbsolute)) {
|
|
54
|
+
// isNpmPackageImport() returns false for a path alias like #root/renderer/onRenderClient
|
|
55
|
+
assert(!importPathAbsolute.startsWith('#'));
|
|
56
|
+
include.push(importPathAbsolute);
|
|
57
|
+
}
|
|
58
|
+
else {
|
|
59
|
+
/* Path aliases, e.g.:
|
|
60
|
+
* ```js
|
|
61
|
+
* // /renderer/+config.js
|
|
62
|
+
* import onRenderClient from '#root/renderer/onRenderClient'
|
|
63
|
+
* ```
|
|
64
|
+
*/
|
|
65
|
+
entries.push(importPathAbsolute);
|
|
66
|
+
}
|
|
66
67
|
}
|
|
67
68
|
});
|
|
68
69
|
});
|
|
@@ -1,5 +1,16 @@
|
|
|
1
1
|
export { generateEagerImport };
|
|
2
|
-
|
|
3
|
-
|
|
2
|
+
/**
|
|
3
|
+
* Naming:
|
|
4
|
+
* `import { someExport as someImport } from './some-file'`
|
|
5
|
+
* <=>
|
|
6
|
+
* `{`
|
|
7
|
+
* `importPath: './some-file',`
|
|
8
|
+
* `exportName: 'someExport',`
|
|
9
|
+
* `importName: 'someImport',`
|
|
10
|
+
* `}`
|
|
11
|
+
* We discard the information that the import variable is called `someImport` because we don't need it.
|
|
12
|
+
*/
|
|
13
|
+
declare function generateEagerImport(importPath: string, varCounter?: number, exportName?: string): {
|
|
14
|
+
importName: string;
|
|
4
15
|
importStatement: string;
|
|
5
16
|
};
|
|
@@ -1,18 +1,29 @@
|
|
|
1
1
|
export { generateEagerImport };
|
|
2
2
|
let varCounterGlobal = 0;
|
|
3
|
-
|
|
3
|
+
/**
|
|
4
|
+
* Naming:
|
|
5
|
+
* `import { someExport as someImport } from './some-file'`
|
|
6
|
+
* <=>
|
|
7
|
+
* `{`
|
|
8
|
+
* `importPath: './some-file',`
|
|
9
|
+
* `exportName: 'someExport',`
|
|
10
|
+
* `importName: 'someImport',`
|
|
11
|
+
* `}`
|
|
12
|
+
* We discard the information that the import variable is called `someImport` because we don't need it.
|
|
13
|
+
*/
|
|
14
|
+
function generateEagerImport(importPath, varCounter, exportName) {
|
|
4
15
|
if (varCounter === undefined)
|
|
5
16
|
varCounter = varCounterGlobal++;
|
|
6
|
-
const
|
|
17
|
+
const importName = `import_${varCounter}`;
|
|
7
18
|
const importLiteral = (() => {
|
|
8
|
-
if (!
|
|
9
|
-
return `* as ${
|
|
19
|
+
if (!exportName || exportName === '*') {
|
|
20
|
+
return `* as ${importName}`;
|
|
10
21
|
}
|
|
11
|
-
if (
|
|
12
|
-
return
|
|
22
|
+
if (exportName === 'default') {
|
|
23
|
+
return importName;
|
|
13
24
|
}
|
|
14
|
-
return `{ ${
|
|
25
|
+
return `{ ${exportName} as ${importName} }`;
|
|
15
26
|
})();
|
|
16
27
|
const importStatement = `import ${importLiteral} from '${importPath}';`;
|
|
17
|
-
return {
|
|
28
|
+
return { importName, importStatement };
|
|
18
29
|
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
export { getVirtualFileImportUserCode };
|
|
2
|
-
import { assert, assertPosixPath, viteIsSSR_options, isNotNullish, scriptFileExtensions, debugGlob } from '../../utils.js';
|
|
2
|
+
import { assert, assertPosixPath, viteIsSSR_options, isNotNullish, scriptFileExtensions, debugGlob, getOutDirs } from '../../utils.js';
|
|
3
3
|
import { isVirtualFileIdImportUserCode } from '../../../shared/virtual-files/virtualFileImportUserCode.js';
|
|
4
4
|
import { fileTypes, determineFileType } from '../../../../shared/getPageFiles/fileTypes.js';
|
|
5
5
|
import path from 'path';
|
|
@@ -121,9 +121,9 @@ function addImport(importPath, fileType, exportNames, isBuild) {
|
|
|
121
121
|
return `() => import('${importPath}${query}')`;
|
|
122
122
|
}
|
|
123
123
|
else {
|
|
124
|
-
const {
|
|
124
|
+
const { importName, importStatement } = generateEagerImport(`${importPath}${query}`);
|
|
125
125
|
fileContent += importStatement + '\n';
|
|
126
|
-
return
|
|
126
|
+
return importName;
|
|
127
127
|
}
|
|
128
128
|
})();
|
|
129
129
|
fileContent += `${mapVar}['${importPath}'] = ${value};\n`;
|
|
@@ -140,7 +140,7 @@ export const pageFilesList = [];
|
|
|
140
140
|
export const neverLoaded = {};
|
|
141
141
|
export const isGeneratedFile = true;
|
|
142
142
|
|
|
143
|
-
${await getVirtualFilePageConfigs(config.root, isForClientSide, isDev, id, configVike, isClientRouting)}
|
|
143
|
+
${await getVirtualFilePageConfigs(config.root, getOutDirs(config).outDirRoot, isForClientSide, isDev, id, configVike, isClientRouting)}
|
|
144
144
|
|
|
145
145
|
`;
|
|
146
146
|
fileTypes
|
|
@@ -204,10 +204,12 @@ function getGlobs(globRoots, isBuild, fileType, query) {
|
|
|
204
204
|
...globRoots.map((globRoot, i) => {
|
|
205
205
|
const varNameLocal = `${varName}${i + 1}`;
|
|
206
206
|
varNameLocals.push(varNameLocal);
|
|
207
|
-
const
|
|
207
|
+
const globIncludePath = `'${getGlobPath(globRoot.includeDir, fileType)}'`;
|
|
208
|
+
const globExcludePath = globRoot.excludeDir ? `'!${getGlobPath(globRoot.excludeDir, fileType)}'` : null;
|
|
208
209
|
const globOptions = JSON.stringify({ eager: isEager, as: query });
|
|
209
210
|
assert(globOptions.startsWith('{"eager":true') || globOptions.startsWith('{"eager":false'));
|
|
210
|
-
const
|
|
211
|
+
const globPaths = globExcludePath ? `[${globIncludePath}, ${globExcludePath}]` : `[${globIncludePath}]`;
|
|
212
|
+
const globLine = `const ${varNameLocal} = import.meta.glob(${globPaths}, ${globOptions});`;
|
|
211
213
|
return globLine;
|
|
212
214
|
}),
|
|
213
215
|
`const ${varName} = {${varNameLocals.map((varNameLocal) => `...${varNameLocal}`).join(',')}};`,
|
|
@@ -216,19 +218,26 @@ function getGlobs(globRoots, isBuild, fileType, query) {
|
|
|
216
218
|
].join('\n');
|
|
217
219
|
}
|
|
218
220
|
function getGlobRoots(config, configVike) {
|
|
219
|
-
const globRoots = [
|
|
221
|
+
const globRoots = [
|
|
222
|
+
{
|
|
223
|
+
includeDir: '/',
|
|
224
|
+
excludeDir: path.posix.relative(config.root, getOutDirs(config).outDirRoot)
|
|
225
|
+
}
|
|
226
|
+
];
|
|
220
227
|
configVike.extensions
|
|
221
228
|
.map(({ pageConfigsSrcDir }) => pageConfigsSrcDir)
|
|
222
229
|
.filter(isNotNullish)
|
|
223
230
|
.forEach((pageConfigsSrcDir) => {
|
|
224
|
-
const globRoot =
|
|
231
|
+
const globRoot = {
|
|
232
|
+
includeDir: path.posix.relative(config.root, pageConfigsSrcDir)
|
|
233
|
+
};
|
|
225
234
|
globRoots.push(globRoot);
|
|
226
235
|
});
|
|
227
236
|
return globRoots;
|
|
228
237
|
}
|
|
229
|
-
function getGlobPath(
|
|
230
|
-
assertPosixPath(
|
|
231
|
-
let globPath = [...
|
|
238
|
+
function getGlobPath(globRootDir, fileType) {
|
|
239
|
+
assertPosixPath(globRootDir);
|
|
240
|
+
let globPath = [...globRootDir.split('/'), '**', `*${fileType}.${scriptFileExtensions}`].filter(Boolean).join('/');
|
|
232
241
|
if (!globPath.startsWith('/')) {
|
|
233
242
|
globPath = '/' + globPath;
|
|
234
243
|
}
|
|
@@ -3,7 +3,7 @@ import { normalizePath } from 'vite';
|
|
|
3
3
|
import { getConfigVike } from '../../../shared/getConfigVike.js';
|
|
4
4
|
import { getVirtualFilePageConfigValuesAll } from './v1-design/getVirtualFilePageConfigValuesAll.js';
|
|
5
5
|
import { getVirtualFileImportUserCode } from './getVirtualFileImportUserCode.js';
|
|
6
|
-
import { assert, assertPosixPath, getFilePathRelativeToUserRootDir, getVirtualFileId, isDev1, isDev1_onConfigureServer, isVirtualFileId, resolveVirtualFileId } from '../../utils.js';
|
|
6
|
+
import { assert, assertPosixPath, getFilePathRelativeToUserRootDir, getOutDirs, getVirtualFileId, isDev1, isDev1_onConfigureServer, isVirtualFileId, resolveVirtualFileId } from '../../utils.js';
|
|
7
7
|
import { isVirtualFileIdPageConfigValuesAll } from '../../../shared/virtual-files/virtualFilePageConfigValuesAll.js';
|
|
8
8
|
import { isVirtualFileIdImportUserCode } from '../../../shared/virtual-files/virtualFileImportUserCode.js';
|
|
9
9
|
import { vikeConfigDependencies, reloadVikeConfig, isVikeConfigFile } from './v1-design/getVikeConfig.js';
|
|
@@ -47,7 +47,7 @@ function importUserCode() {
|
|
|
47
47
|
return undefined;
|
|
48
48
|
id = getVirtualFileId(id);
|
|
49
49
|
if (isVirtualFileIdPageConfigValuesAll(id)) {
|
|
50
|
-
const code = await getVirtualFilePageConfigValuesAll(id, config.root, isDev, configVike);
|
|
50
|
+
const code = await getVirtualFilePageConfigValuesAll(id, config.root, getOutDirs(config).outDirRoot, isDev, configVike);
|
|
51
51
|
return code;
|
|
52
52
|
}
|
|
53
53
|
if (isVirtualFileIdImportUserCode(id)) {
|
|
@@ -120,7 +120,7 @@ function reloadConfig(filePath, config, configVike, op) {
|
|
|
120
120
|
const msg = `${op} ${filePathToShowToUser}`;
|
|
121
121
|
logConfigInfo(msg, 'info');
|
|
122
122
|
}
|
|
123
|
-
reloadVikeConfig(config.root, configVike.extensions);
|
|
123
|
+
reloadVikeConfig(config.root, getOutDirs(config).outDirRoot, configVike.extensions);
|
|
124
124
|
}
|
|
125
125
|
function getVirtualModules(server) {
|
|
126
126
|
const virtualModules = Array.from(server.moduleGraph.urlToModuleMap.keys())
|
|
@@ -1,7 +1,24 @@
|
|
|
1
1
|
export { getFilePathToShowToUser };
|
|
2
2
|
export type { FilePath };
|
|
3
3
|
type FilePath = {
|
|
4
|
+
/** The file's path relative to the filesystem root.
|
|
5
|
+
*
|
|
6
|
+
* Example: `/home/rom/code/my-app/pages/some-page/Page.js`
|
|
7
|
+
*/
|
|
4
8
|
filePathAbsolute: string;
|
|
5
|
-
|
|
6
|
-
|
|
9
|
+
} & ({
|
|
10
|
+
/** The file's path relative to the Vite's root (i.e. the user's project root directory).
|
|
11
|
+
*
|
|
12
|
+
* Example: `/pages/some-page/Page.js`
|
|
13
|
+
*/
|
|
14
|
+
filePathRelativeToUserRootDir: string;
|
|
15
|
+
importPathAbsolute: null;
|
|
16
|
+
} | {
|
|
17
|
+
filePathRelativeToUserRootDir: null;
|
|
18
|
+
/** The file's absolute import path.
|
|
19
|
+
*
|
|
20
|
+
* Example: `vike-react/config`
|
|
21
|
+
*/
|
|
22
|
+
importPathAbsolute: string;
|
|
23
|
+
});
|
|
7
24
|
declare function getFilePathToShowToUser(filePath: FilePath): string;
|
|
@@ -1,5 +1,11 @@
|
|
|
1
1
|
export { getFilePathToShowToUser };
|
|
2
2
|
import { assert } from '../../../utils.js';
|
|
3
|
+
/*
|
|
4
|
+
const f: FilePath = 1 as any
|
|
5
|
+
if (f.filePathRelativeToUserRootDir === null) {
|
|
6
|
+
f.importPathAbsolute
|
|
7
|
+
}
|
|
8
|
+
//*/
|
|
3
9
|
function getFilePathToShowToUser(filePath) {
|
|
4
10
|
const filePathToShowToUser = filePath.filePathRelativeToUserRootDir ?? filePath.filePathAbsolute;
|
|
5
11
|
assert(filePathToShowToUser);
|
|
@@ -4,7 +4,7 @@ export type { ConfigDefinition };
|
|
|
4
4
|
export type { ConfigDefinitionInternal };
|
|
5
5
|
export type { ConfigNameGlobal };
|
|
6
6
|
export type { ConfigEffect };
|
|
7
|
-
import type { ConfigEnvInternal, ConfigEnv,
|
|
7
|
+
import type { ConfigEnvInternal, ConfigEnv, ConfigValueSources } from '../../../../../../shared/page-configs/PageConfig.js';
|
|
8
8
|
import type { Config, ConfigNameBuiltIn } from '../../../../../../shared/page-configs/Config.js';
|
|
9
9
|
/** The meta definition of a config.
|
|
10
10
|
*
|
|
@@ -31,19 +31,20 @@ type ConfigDefinition = {
|
|
|
31
31
|
effect?: ConfigEffect;
|
|
32
32
|
};
|
|
33
33
|
type ConfigEffect = (config: {
|
|
34
|
-
/** The
|
|
34
|
+
/** The config value.
|
|
35
35
|
*
|
|
36
36
|
* https://vike.dev/meta
|
|
37
37
|
*/
|
|
38
38
|
configValue: unknown;
|
|
39
|
-
/**
|
|
39
|
+
/** Where the config value is defined.
|
|
40
40
|
*
|
|
41
41
|
* https://vike.dev/meta
|
|
42
42
|
*/
|
|
43
43
|
configDefinedAt: `Config ${string}`;
|
|
44
44
|
}) => Config | undefined;
|
|
45
|
+
/** For Vike internal use */
|
|
45
46
|
type ConfigDefinitionInternal = Omit<ConfigDefinition, 'env'> & {
|
|
46
|
-
_computed?: (
|
|
47
|
+
_computed?: (configValueSources: ConfigValueSources) => unknown;
|
|
47
48
|
_valueIsFilePath?: true;
|
|
48
49
|
env: ConfigEnvInternal;
|
|
49
50
|
};
|
|
@@ -67,13 +67,13 @@ const configDefinitionsBuiltIn = {
|
|
|
67
67
|
},
|
|
68
68
|
isClientSideRenderable: {
|
|
69
69
|
env: 'server-and-client',
|
|
70
|
-
_computed: (
|
|
71
|
-
isConfigSet(
|
|
72
|
-
getConfigEnv(
|
|
70
|
+
_computed: (configValueSources) => isConfigSet(configValueSources, 'onRenderClient') &&
|
|
71
|
+
isConfigSet(configValueSources, 'Page') &&
|
|
72
|
+
getConfigEnv(configValueSources, 'Page') !== 'server-only'
|
|
73
73
|
},
|
|
74
74
|
onBeforeRenderEnv: {
|
|
75
75
|
env: 'client-only',
|
|
76
|
-
_computed: (
|
|
76
|
+
_computed: (configValueSources) => !isConfigSet(configValueSources, 'onBeforeRender') ? null : getConfigEnv(configValueSources, 'onBeforeRender')
|
|
77
77
|
}
|
|
78
78
|
};
|
|
79
79
|
const configDefinitionsBuiltInGlobal = {
|
|
@@ -2,14 +2,14 @@ export { getVikeConfig };
|
|
|
2
2
|
export { reloadVikeConfig };
|
|
3
3
|
export { vikeConfigDependencies };
|
|
4
4
|
export { isVikeConfigFile };
|
|
5
|
-
import type {
|
|
5
|
+
import type { PageConfigGlobalBuildTime, PageConfigBuildTime } from '../../../../../shared/page-configs/PageConfig.js';
|
|
6
6
|
import type { ExtensionResolved } from '../../../../../shared/ConfigVike.js';
|
|
7
7
|
type VikeConfig = {
|
|
8
8
|
pageConfigs: PageConfigBuildTime[];
|
|
9
|
-
pageConfigGlobal:
|
|
9
|
+
pageConfigGlobal: PageConfigGlobalBuildTime;
|
|
10
10
|
globalVikeConfig: Record<string, unknown>;
|
|
11
11
|
};
|
|
12
12
|
declare const vikeConfigDependencies: Set<string>;
|
|
13
|
-
declare function reloadVikeConfig(userRootDir: string, extensions: ExtensionResolved[]): void;
|
|
14
|
-
declare function getVikeConfig(userRootDir: string, isDev: boolean, extensions: ExtensionResolved[], tolerateInvalidConfig?: boolean): Promise<VikeConfig>;
|
|
13
|
+
declare function reloadVikeConfig(userRootDir: string, outDirRoot: string, extensions: ExtensionResolved[]): void;
|
|
14
|
+
declare function getVikeConfig(userRootDir: string, outDirRoot: string, isDev: boolean, extensions: ExtensionResolved[], tolerateInvalidConfig?: boolean): Promise<VikeConfig>;
|
|
15
15
|
declare function isVikeConfigFile(filePath: string): boolean;
|