vike 0.4.209 → 0.4.211

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 (42) hide show
  1. package/dist/cjs/node/plugin/plugins/buildConfig/fixServerAssets.js +30 -7
  2. package/dist/cjs/node/plugin/plugins/commonConfig.js +17 -9
  3. package/dist/cjs/node/plugin/plugins/config/index.js +9 -3
  4. package/dist/cjs/node/plugin/plugins/devConfig/index.js +14 -6
  5. package/dist/cjs/node/plugin/plugins/importUserCode/index.js +1 -1
  6. package/dist/cjs/node/plugin/plugins/importUserCode/v1-design/getVikeConfig/loadFileAtConfigTime.js +3 -3
  7. package/dist/cjs/node/plugin/plugins/importUserCode/v1-design/getVikeConfig/resolvePointerImport.js +38 -11
  8. package/dist/cjs/node/plugin/plugins/importUserCode/v1-design/getVikeConfig.js +20 -35
  9. package/dist/cjs/node/plugin/plugins/previewConfig.js +5 -4
  10. package/dist/cjs/node/plugin/plugins/setGlobalContext.js +1 -1
  11. package/dist/cjs/node/plugin/utils.js +1 -0
  12. package/dist/cjs/node/runtime/renderPage/logErrorHint.js +11 -7
  13. package/dist/cjs/utils/PROJECT_VERSION.js +1 -1
  14. package/dist/cjs/utils/assertVersion.js +2 -0
  15. package/dist/cjs/utils/isDev.js +11 -16
  16. package/dist/cjs/utils/isDocker.js +45 -0
  17. package/dist/esm/client/client-routing-runtime/renderPageClientSide.js +13 -2
  18. package/dist/esm/node/plugin/plugins/buildConfig/fixServerAssets.js +28 -5
  19. package/dist/esm/node/plugin/plugins/commonConfig.js +18 -10
  20. package/dist/esm/node/plugin/plugins/config/index.js +10 -4
  21. package/dist/esm/node/plugin/plugins/devConfig/index.d.ts +3 -1
  22. package/dist/esm/node/plugin/plugins/devConfig/index.js +12 -7
  23. package/dist/esm/node/plugin/plugins/importUserCode/index.js +2 -2
  24. package/dist/esm/node/plugin/plugins/importUserCode/v1-design/getVikeConfig/loadFileAtConfigTime.js +3 -3
  25. package/dist/esm/node/plugin/plugins/importUserCode/v1-design/getVikeConfig/resolvePointerImport.d.ts +11 -1
  26. package/dist/esm/node/plugin/plugins/importUserCode/v1-design/getVikeConfig/resolvePointerImport.js +39 -12
  27. package/dist/esm/node/plugin/plugins/importUserCode/v1-design/getVikeConfig.js +21 -36
  28. package/dist/esm/node/plugin/plugins/previewConfig.js +6 -5
  29. package/dist/esm/node/plugin/plugins/setGlobalContext.js +2 -2
  30. package/dist/esm/node/plugin/utils.d.ts +1 -0
  31. package/dist/esm/node/plugin/utils.js +1 -0
  32. package/dist/esm/node/runtime/renderPage/logErrorHint.js +11 -7
  33. package/dist/esm/shared/types.d.ts +6 -0
  34. package/dist/esm/utils/PROJECT_VERSION.d.ts +1 -1
  35. package/dist/esm/utils/PROJECT_VERSION.js +1 -1
  36. package/dist/esm/utils/assertVersion.js +2 -0
  37. package/dist/esm/utils/isDev.d.ts +6 -5
  38. package/dist/esm/utils/isDev.js +11 -16
  39. package/dist/esm/utils/isDocker.d.ts +2 -0
  40. package/dist/esm/utils/isDocker.js +40 -0
  41. package/dist/esm/utils/projectInfo.d.ts +1 -1
  42. package/package.json +2 -2
@@ -22,3 +22,4 @@ export * from '../../utils/isFilePathAbsoluteFilesystem.js';
22
22
  export * from '../../utils/isArray.js';
23
23
  export * from '../../utils/PROJECT_VERSION.js';
24
24
  export * from '../../utils/isEqualStringList.js';
25
+ export * from '../../utils/isDocker.js';
@@ -28,3 +28,4 @@ export * from '../../utils/isFilePathAbsoluteFilesystem.js';
28
28
  export * from '../../utils/isArray.js';
29
29
  export * from '../../utils/PROJECT_VERSION.js';
30
30
  export * from '../../utils/isEqualStringList.js';
31
+ export * from '../../utils/isDocker.js';
@@ -6,10 +6,15 @@ import pc from '@brillout/picocolors';
6
6
  const hintDefault = 'The error could be a CJS/ESM issue, see https://vike.dev/broken-npm-package';
7
7
  const hintLinkPrefix = 'To fix this error, see ';
8
8
  const errorsMisc = [
9
+ {
10
+ errMsg: 'window is not defined',
11
+ link: 'https://vike.dev/hints#window-is-not-defined',
12
+ mustMentionNodeModules: false
13
+ },
9
14
  {
10
15
  errMsg: 'jsxDEV is not a function',
11
16
  link: 'https://github.com/vikejs/vike/issues/1469#issuecomment-1919518096',
12
- shouldMentionNodeModules: false
17
+ mustMentionNodeModules: false
13
18
  },
14
19
  {
15
20
  // ```
@@ -17,7 +22,7 @@ const errorsMisc = [
17
22
  // ```
18
23
  errMsg: 'assets.json',
19
24
  link: 'https://vike.dev/getGlobalContext',
20
- shouldMentionNodeModules: false
25
+ mustMentionNodeModules: false
21
26
  }
22
27
  ];
23
28
  const errorsReact = [
@@ -25,7 +30,7 @@ const errorsReact = [
25
30
  errMsg: 'Element type is invalid: expected a string (for built-in components) or a class/function (for composite components)',
26
31
  link: 'https://vike.dev/broken-npm-package#react-invalid-component',
27
32
  // The stack trace can be user-land while the import is coming from node_modules
28
- shouldMentionNodeModules: false
33
+ mustMentionNodeModules: false
29
34
  },
30
35
  {
31
36
  // React's "Invalid hook call.", see https://github.com/vikejs/vike/discussions/1637#discussioncomment-9424712
@@ -38,7 +43,7 @@ const errorsCjsEsm_withPreciseLink = [
38
43
  errMsg: /Named export.*not found/i,
39
44
  link: 'https://vike.dev/broken-npm-package#named-export-not-found',
40
45
  // It seems that this always points to an npm package import.
41
- shouldMentionNodeModules: false
46
+ mustMentionNodeModules: false
42
47
  }
43
48
  ];
44
49
  const errorsCjsEsm = [
@@ -52,7 +57,7 @@ const errorsCjsEsm = [
52
57
  {
53
58
  errMsg: 'Cannot use import statement',
54
59
  // Since user code is always ESM, this error must always originate from an npm package.
55
- shouldMentionNodeModules: false
60
+ mustMentionNodeModules: false
56
61
  },
57
62
  { errMsg: 'is not exported' },
58
63
  { errMsg: 'Cannot read properties of undefined' },
@@ -61,7 +66,6 @@ const errorsCjsEsm = [
61
66
  { errMsg: 'require is not a function' },
62
67
  { errMsg: 'exports is not defined' },
63
68
  { errMsg: 'module is not defined' },
64
- { errMsg: 'window is not defined' },
65
69
  { errMsg: 'not defined in ES' },
66
70
  { errMsg: "Unexpected token 'export'" }
67
71
  ];
@@ -103,7 +107,7 @@ function isKnownError(error) {
103
107
  ].find((knownErorr) => {
104
108
  if (!includesLowercase(anywhere, knownErorr.errMsg))
105
109
  return false;
106
- if (knownErorr.shouldMentionNodeModules !== false && !includesLowercase(anywhere, 'node_modules'))
110
+ if (knownErorr.mustMentionNodeModules !== false && !includesLowercase(anywhere, 'node_modules'))
107
111
  return false;
108
112
  return true;
109
113
  });
@@ -133,6 +133,12 @@ type PageContextBuiltInClientWithClientRouting<Data> = Partial<PageContextBuiltI
133
133
  * The value is `true` when the user clicks on his browser's backward navigation button, or when invoking `history.back()`.
134
134
  */
135
135
  isBackwardNavigation: boolean | null;
136
+ /**
137
+ * Upon client-side page navigation, you can use `pageContext.previousPageContext` to access the `pageContext` of the previous page.
138
+ *
139
+ * https://vike.dev/pageContext
140
+ */
141
+ previousPageContext: PageContextClient<Data> | null;
136
142
  } & PageContextUrlClient;
137
143
  type PageContextBuiltInClientWithServerRouting<Data> = Partial<PageContextBuiltInCommon<Data>> & Pick<PageContextBuiltInCommon<Data>, 'Page' | 'pageExports' | 'exports' | 'abortReason' | 'pageId' | 'data'> & {
138
144
  /**
@@ -1 +1 @@
1
- export declare const PROJECT_VERSION: "0.4.209";
1
+ export declare const PROJECT_VERSION: "0.4.211";
@@ -1,2 +1,2 @@
1
1
  // Automatically updated by @brillout/release-me
2
- export const PROJECT_VERSION = '0.4.209';
2
+ export const PROJECT_VERSION = '0.4.211';
@@ -2,6 +2,8 @@ export { assertVersion };
2
2
  export { isVersionOrAbove };
3
3
  import { assert, assertUsage } from './assert.js';
4
4
  function assertVersion(dependencyName, versionActual, versionExpected) {
5
+ assert(versionActual);
6
+ assert(versionExpected);
5
7
  assertUsage(isVersionOrAbove(versionActual, versionExpected), `${dependencyName} ${versionActual} isn't supported, use ${dependencyName} >= ${versionExpected} instead.`);
6
8
  }
7
9
  function isVersionOrAbove(versionActual, versionExpected) {
@@ -1,6 +1,7 @@
1
- export { isDev2 };
2
- export { isDev3 };
1
+ export { isDevCheck };
2
+ export { applyDev };
3
+ export { applyPreview };
3
4
  import type { ConfigEnv } from 'vite';
4
- declare function isDev3(configEnv: ConfigEnv): boolean;
5
- import type { ResolvedConfig } from 'vite';
6
- declare function isDev2(config: ResolvedConfig): boolean;
5
+ declare function isDevCheck(configEnv: ConfigEnv): boolean;
6
+ declare function applyDev(_: unknown, env: ConfigEnv): boolean;
7
+ declare function applyPreview(_: unknown, env: ConfigEnv): boolean;
@@ -1,21 +1,16 @@
1
- export { isDev2 };
2
- export { isDev3 };
1
+ export { isDevCheck };
2
+ export { applyDev };
3
+ export { applyPreview };
3
4
  import { assert } from './assert.js';
4
- function isDev3(configEnv) {
5
+ function isDevCheck(configEnv) {
5
6
  const { isPreview, command } = configEnv;
6
- if (command !== 'serve')
7
- return false;
8
- // `isPreview` is `undefined` in older Vite versions.
9
- // https://github.com/vitejs/vite/pull/14855
10
- // https://github.com/vitejs/vite/pull/15695O
11
- // - Released at `vite@5.1.0`: https://github.com/vitejs/vite/blob/main/packages/vite/CHANGELOG.md#510-beta4-2024-01-26:~:text=fix(preview)%3A%20set%20isPreview%20true%20(%2315695)%20(93fce55)%2C%20closes%20%2315695
7
+ // Released at vite@5.1.0 which is guaranteed with `assertVersion('Vite', version, '5.1.0')`
12
8
  assert(typeof isPreview === 'boolean');
13
- return !isPreview;
9
+ return command === 'serve' && !isPreview;
14
10
  }
15
- function isDev2(config) {
16
- const isDev = config.command === 'serve' &&
17
- // Mode is 'development' by default: https://github.com/vitejs/vite/blob/bf9c49f521b7a6730231c35754d5e1f9c3a6a16e/packages/vite/src/node/config.ts#L383
18
- // Note that user can override this: https://github.com/vitejs/vite/blob/bf9c49f521b7a6730231c35754d5e1f9c3a6a16e/packages/vite/src/node/cli.ts#L126
19
- config.mode === 'development';
20
- return isDev;
11
+ function applyDev(_, env) {
12
+ return isDevCheck(env);
13
+ }
14
+ function applyPreview(_, env) {
15
+ return env.command == 'serve' && !isDevCheck(env);
21
16
  }
@@ -0,0 +1,2 @@
1
+ export { isDocker };
2
+ declare function isDocker(): boolean;
@@ -0,0 +1,40 @@
1
+ export { isDocker };
2
+ import fs from 'node:fs';
3
+ import { assertIsNotProductionRuntime } from './assertIsNotProductionRuntime.js';
4
+ assertIsNotProductionRuntime();
5
+ function isDocker() {
6
+ return hasContainerEnv() || isDockerContainer();
7
+ }
8
+ // Podman detection
9
+ // https://github.com/sindresorhus/is-inside-container/blob/7f0dc884bda6b368d89ec90e77f2bef3b87e6f09/index.js
10
+ function hasContainerEnv() {
11
+ try {
12
+ fs.statSync('/run/.containerenv');
13
+ return true;
14
+ }
15
+ catch {
16
+ return false;
17
+ }
18
+ }
19
+ // Docker detection
20
+ // https://github.com/sindresorhus/is-docker/blob/1cfd2b5bfa9fbd87d2b22e6f514e7d5cc60a794b/index.js
21
+ function isDockerContainer() {
22
+ return hasDockerEnv() || hasDockerCGroup();
23
+ }
24
+ function hasDockerEnv() {
25
+ try {
26
+ fs.statSync('/.dockerenv');
27
+ return true;
28
+ }
29
+ catch {
30
+ return false;
31
+ }
32
+ }
33
+ function hasDockerCGroup() {
34
+ try {
35
+ return fs.readFileSync('/proc/self/cgroup', 'utf8').includes('docker');
36
+ }
37
+ catch {
38
+ return false;
39
+ }
40
+ }
@@ -1,4 +1,4 @@
1
1
  export declare const projectInfo: {
2
2
  projectName: "Vike";
3
- projectVersion: "0.4.209";
3
+ projectVersion: "0.4.211";
4
4
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "vike",
3
- "version": "0.4.209",
3
+ "version": "0.4.211",
4
4
  "repository": "https://github.com/vikejs/vike",
5
5
  "exports": {
6
6
  "./server": {
@@ -234,7 +234,7 @@
234
234
  "react-streaming": "^0.3.44",
235
235
  "rimraf": "^5.0.5",
236
236
  "typescript": "^5.6.2",
237
- "vite": "^5.4.0"
237
+ "vite": "^6.0.5"
238
238
  },
239
239
  "scripts": {
240
240
  "dev": "tsc --watch",