vike 0.4.176 → 0.4.177-commit-ff3d6cd

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.
Files changed (38) hide show
  1. package/dist/cjs/node/plugin/plugins/extractAssetsPlugin.js +1 -1
  2. package/dist/cjs/node/plugin/plugins/importUserCode/v1-design/getVikeConfig/configDefinitionsBuiltIn.js +1 -1
  3. package/dist/cjs/node/plugin/plugins/importUserCode/v1-design/getVikeConfig/crawlPlusFiles.js +129 -18
  4. package/dist/cjs/node/plugin/plugins/importUserCode/v1-design/getVikeConfig.js +14 -6
  5. package/dist/cjs/node/plugin/shared/loggerNotProd/errorWithCodeSnippet/fixture-errors/errBabelReact.js +5 -5
  6. package/dist/cjs/node/plugin/shared/loggerNotProd/errorWithCodeSnippet/fixture-errors/errEsbuild.js +9 -9
  7. package/dist/cjs/node/plugin/shared/loggerNotProd/errorWithCodeSnippet/fixture-errors/errVueCss.js +7 -7
  8. package/dist/cjs/node/runtime/renderPage/handleErrorWithoutErrorPage.js +2 -2
  9. package/dist/cjs/node/runtime/renderPage/renderPageAlreadyRouted.js +4 -2
  10. package/dist/cjs/node/shared/assertV1Design.js +11 -6
  11. package/dist/cjs/shared/page-configs/getConfigValueBuildTime.js +0 -1
  12. package/dist/cjs/utils/assertSingleInstance.js +5 -1
  13. package/dist/cjs/utils/projectInfo.js +1 -1
  14. package/dist/esm/client/client-routing-runtime/installClientRouter.js +1 -1
  15. package/dist/esm/client/client-routing-runtime/navigate.d.ts +2 -2
  16. package/dist/esm/client/client-routing-runtime/navigate.js +2 -12
  17. package/dist/esm/client/client-routing-runtime/onBrowserHistoryNavigation.js +1 -1
  18. package/dist/esm/client/client-routing-runtime/onLinkClick.js +6 -2
  19. package/dist/esm/client/client-routing-runtime/renderPageClientSide.js +2 -2
  20. package/dist/esm/client/client-routing-runtime/setScrollPosition.d.ts +3 -1
  21. package/dist/esm/client/client-routing-runtime/setScrollPosition.js +16 -16
  22. package/dist/esm/node/plugin/plugins/extractAssetsPlugin.js +1 -1
  23. package/dist/esm/node/plugin/plugins/importUserCode/v1-design/getVikeConfig/configDefinitionsBuiltIn.js +1 -1
  24. package/dist/esm/node/plugin/plugins/importUserCode/v1-design/getVikeConfig/crawlPlusFiles.js +130 -19
  25. package/dist/esm/node/plugin/plugins/importUserCode/v1-design/getVikeConfig.js +14 -6
  26. package/dist/esm/node/plugin/shared/loggerNotProd/errorWithCodeSnippet/fixture-errors/errBabelReact.js +5 -5
  27. package/dist/esm/node/plugin/shared/loggerNotProd/errorWithCodeSnippet/fixture-errors/errEsbuild.js +9 -9
  28. package/dist/esm/node/plugin/shared/loggerNotProd/errorWithCodeSnippet/fixture-errors/errVueCss.js +7 -7
  29. package/dist/esm/node/runtime/renderPage/handleErrorWithoutErrorPage.js +2 -2
  30. package/dist/esm/node/runtime/renderPage/renderPageAlreadyRouted.js +4 -2
  31. package/dist/esm/node/shared/assertV1Design.d.ts +1 -1
  32. package/dist/esm/node/shared/assertV1Design.js +11 -6
  33. package/dist/esm/shared/page-configs/PageConfig.d.ts +3 -3
  34. package/dist/esm/shared/page-configs/getConfigValueBuildTime.js +0 -1
  35. package/dist/esm/utils/assertSingleInstance.js +2 -1
  36. package/dist/esm/utils/projectInfo.d.ts +2 -2
  37. package/dist/esm/utils/projectInfo.js +1 -1
  38. package/package.json +1 -1
@@ -21,6 +21,7 @@ import { executeGuardHook } from '../../../shared/route/executeGuardHook.js';
21
21
  import { loadPageRoutes } from '../../../shared/route/loadPageRoutes.js';
22
22
  import pc from '@brillout/picocolors';
23
23
  import { isServerSideError } from '../../../shared/misc/isServerSideError.js';
24
+ import { assertV1Design } from '../../shared/assertV1Design.js';
24
25
  async function renderPageAlreadyRouted(pageContext) {
25
26
  // pageContext._pageId can either be the:
26
27
  // - ID of the page matching the routing, or the
@@ -170,8 +171,9 @@ async function getRenderContext() {
170
171
  const globalContext = getGlobalContext();
171
172
  const { pageFilesAll, allPageIds, pageConfigs, pageConfigGlobal } = await getPageFilesAll(false, globalContext.isProduction);
172
173
  const { pageRoutes, onBeforeRouteHook } = await loadPageRoutes(pageFilesAll, pageConfigs, pageConfigGlobal, allPageIds);
173
- // We assume assertV1Design() was already called at build-time
174
- assert(pageFilesAll.length === 0 || pageConfigs.length === 0);
174
+ assertV1Design(
175
+ // pageConfigs is PageConfigRuntime[] but assertV1Design() requires PageConfigBuildTime[]
176
+ pageConfigs.length > 0, pageFilesAll);
175
177
  const renderContext = {
176
178
  pageFilesAll: pageFilesAll,
177
179
  pageConfigs,
@@ -1,4 +1,4 @@
1
1
  export { assertV1Design };
2
2
  import { PageFile } from '../../shared/getPageFiles.js';
3
3
  import type { PageConfigBuildTime } from '../../shared/page-configs/PageConfig.js';
4
- declare function assertV1Design(isOldDesign: boolean, pageConfigs: PageConfigBuildTime[], pageFilesAll?: PageFile[]): void;
4
+ declare function assertV1Design(pageConfigs: PageConfigBuildTime[] | boolean, pageFilesAll: PageFile[] | boolean): void;
@@ -1,20 +1,25 @@
1
1
  export { assertV1Design };
2
2
  import { assert, assertUsage, assertWarning, isNotNullish, unique } from './utils.js';
3
- function assertV1Design(isOldDesign, pageConfigs, pageFilesAll) {
4
- const isV1Design = pageConfigs.length > 0;
3
+ function assertV1Design(pageConfigs, pageFilesAll) {
4
+ const isOldDesign = pageFilesAll === true || (pageFilesAll !== false && pageFilesAll.length > 0);
5
+ const isV1Design = pageConfigs === true || (pageConfigs !== false && pageConfigs.length > 0);
5
6
  if (isV1Design && isOldDesign) {
6
7
  const lines = ['Mixing the new V1 design with the old V0.4 design is forbidden.'];
7
- if (pageFilesAll) {
8
- assert(pageFilesAll.length > 0);
9
- const indent = '- ';
8
+ const indent = '- ';
9
+ if (typeof pageConfigs !== 'boolean') {
10
+ assert(pageConfigs.length > 0);
10
11
  const filesV1 = unique(pageConfigs
11
12
  .map((p) => Object.values(p.configValueSources).map((sources) => sources
12
13
  .map((c) => c.definedAtFilePath.filePathAbsoluteUserRootDir)
13
14
  .filter(isNotNullish)
14
15
  .map((filePathToShowToUser) => indent + filePathToShowToUser)))
15
16
  .flat(2));
17
+ lines.push(...['V1 design files:', ...filesV1]);
18
+ }
19
+ if (typeof pageFilesAll !== 'boolean') {
20
+ assert(pageFilesAll.length > 0);
16
21
  const filesOld = pageFilesAll.map((p) => indent + p.filePath);
17
- lines.push(...['V1 design files:', ...filesV1, 'Old design files:', ...filesOld]);
22
+ lines.push(...['Old design files:', ...filesOld]);
18
23
  }
19
24
  assertUsage(false, lines.join('\n'));
20
25
  }
@@ -67,9 +67,9 @@ type ConfigEnv = {
67
67
  /** For Vike internal use */
68
68
  type ConfigEnvInternal = Omit<ConfigEnv, 'client'> & {
69
69
  client?: boolean | 'if-client-routing';
70
- /** Always load value, not matter what page is loaded. */
71
- eager?: boolean;
72
- /** Load value only in production or only in development. */
70
+ /** Always load value, no matter which page is loaded. */
71
+ eager?: true;
72
+ /** Load value only in production, or only in development. */
73
73
  production?: boolean;
74
74
  };
75
75
  type ConfigValueSource = {
@@ -22,7 +22,6 @@ function getConfigValue(pageConfig, configName) {
22
22
  const sources = configValueSources[configName];
23
23
  if (!sources)
24
24
  return null;
25
- assert(sources.every((s) => s.configEnv.config === true));
26
25
  const configDef = configDefinitions[configName];
27
26
  assert(configDef);
28
27
  if (!configDef.cumulative) {
@@ -7,6 +7,7 @@ export { onAssertModuleLoad };
7
7
  import { unique } from './unique.js';
8
8
  import { getGlobalObject } from './getGlobalObject.js';
9
9
  import { projectInfo } from './projectInfo.js';
10
+ import pc from '@brillout/picocolors';
10
11
  /* Use original assertUsage() & assertWarning() after all CJS is removed from node_modules/vike/dist/
11
12
  import { assertUsage, assertWarning } from './assert.js'
12
13
  */
@@ -21,7 +22,7 @@ function assertSingleInstance() {
21
22
  const versions = unique(globalObject.instances);
22
23
  assertUsage(versions.length <= 1,
23
24
  // DO *NOT* patch vike to remove this error: because of multiple conflicting versions, you *will* eventually encounter insidious issues that hard to debug and potentially a security hazard, see for example https://github.com/vikejs/vike/issues/1108
24
- `Both vike@${versions[0]} and vike@${versions[1]} loaded. Only one version should be loaded.`);
25
+ `vike@${pc.bold(versions[0])} and vike@${pc.bold(versions[1])} loaded but only one version should be loaded`);
25
26
  }
26
27
  if (globalObject.checkSingleInstance && globalObject.instances.length > 1) {
27
28
  /*/ Not sure whether circular dependency can cause problems? In principle not since client-side code is ESM.
@@ -1,7 +1,7 @@
1
1
  export { projectInfo };
2
2
  export { PROJECT_VERSION };
3
- declare const PROJECT_VERSION: "0.4.176";
3
+ declare const PROJECT_VERSION: "0.4.177-commit-ff3d6cd";
4
4
  declare const projectInfo: {
5
5
  projectName: "Vike";
6
- projectVersion: "0.4.176";
6
+ projectVersion: "0.4.177-commit-ff3d6cd";
7
7
  };
@@ -1,6 +1,6 @@
1
1
  export { projectInfo };
2
2
  export { PROJECT_VERSION };
3
- const PROJECT_VERSION = '0.4.176';
3
+ const PROJECT_VERSION = '0.4.177-commit-ff3d6cd';
4
4
  const projectInfo = {
5
5
  projectName: 'Vike',
6
6
  projectVersion: PROJECT_VERSION
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "vike",
3
- "version": "0.4.176",
3
+ "version": "0.4.177-commit-ff3d6cd",
4
4
  "scripts": {
5
5
  "dev": "tsc --watch",
6
6
  "build": "rimraf dist/ && pnpm run build:esm && pnpm run build:cjs",