vike 0.4.155 → 0.4.156-commit-1a83691

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.
@@ -33,7 +33,7 @@ function importBuild() {
33
33
  await replace_ASSETS_MAP(options, bundle);
34
34
  }
35
35
  },
36
- (0, plugin_js_1.serverEntryPlugin)({
36
+ ...(0, plugin_js_1.serverEntryPlugin)({
37
37
  getImporterCode: () => {
38
38
  return getEntryCode(config, configVike);
39
39
  },
@@ -67,17 +67,18 @@ function getEntryCode(config, configVike) {
67
67
  async function replace_ASSETS_MAP(options, bundle) {
68
68
  const { dir } = options;
69
69
  (0, utils_js_1.assert)(dir);
70
- // I guess importBuild won't be found in the bundle when using @vitejs/plugin-legacy
71
- const importBuildEntry = (0, plugin_js_1.findServerEntry)(bundle);
72
- const importBuildFilePath = path_1.default.join(dir, importBuildEntry.fileName);
70
+ // This will probably fail with @vitejs/plugin-legacy
71
+ // - See `git log -p` for how we used to workaround the @vitejs/plugin-legacy issue.
72
+ const serverEntry = (0, plugin_js_1.findServerEntry)(bundle);
73
+ const serverEntryFilePath = path_1.default.join(dir, serverEntry.fileName);
73
74
  const assetsJsonFilePath = path_1.default.join(dir, '..', 'assets.json');
74
- const [assetsJsonString, importBuildFileContent] = await Promise.all([
75
+ const [assetsJsonString, serverEntryFileContent] = await Promise.all([
75
76
  await promises_1.default.readFile(assetsJsonFilePath, 'utf8'),
76
- await promises_1.default.readFile(importBuildFilePath, 'utf8')
77
+ await promises_1.default.readFile(serverEntryFilePath, 'utf8')
77
78
  ]);
78
- const importBuildFileContentFixed = importBuildFileContent.replace(ASSETS_MAP, assetsJsonString);
79
- (0, utils_js_1.assert)(importBuildFileContentFixed !== importBuildFileContent);
80
- await promises_1.default.writeFile(importBuildFilePath, importBuildFileContentFixed);
79
+ const serverEntryFileContentPatched = serverEntryFileContent.replace(ASSETS_MAP, assetsJsonString);
80
+ (0, utils_js_1.assert)(serverEntryFileContentPatched !== serverEntryFileContent);
81
+ await promises_1.default.writeFile(serverEntryFilePath, serverEntryFileContentPatched);
81
82
  }
82
83
  function getImportPath(config) {
83
84
  // We resolve filePathAbsolute even if we don't use it: we use require.resolve() as an assertion that the relative path is correct
@@ -90,12 +90,12 @@ async function getHtmlTags(pageContext, injectToStream, injectFilter) {
90
90
  // See https://github.com/vikejs/vike/pull/1271
91
91
  const positionJavaScriptEntry = (() => {
92
92
  if (pageContext._pageContextPromise) {
93
- (0, utils_js_1.assertWarning)(!injectToStream, "[getHtmlTags()] We recommend against using streaming and a pageContext promise at the same time as partial hydration won't work", { onlyOnce: true });
93
+ (0, utils_js_1.assertWarning)(!injectToStream, "[getHtmlTags()] We recommend against using streaming and a pageContext promise at the same time as progressive hydration won't work", { onlyOnce: true });
94
94
  // If there is a pageContext._pageContextPromise (which is resolved after the stream has ended) then the pageContext JSON data needs to await for it: https://vike.dev/stream#initial-data-after-stream-end
95
95
  return 'HTML_END';
96
96
  }
97
97
  if (injectToStream) {
98
- // If there is a stream then, in order to support partial hydration, inject the JavaScript during the stream after React(/Vue/Solid/...) resolved the first suspense boundary
98
+ // If there is a stream then, in order to support progressive hydration, inject the JavaScript during the stream after React(/Vue/Solid/...) resolved the first suspense boundary
99
99
  return 'STREAM';
100
100
  }
101
101
  else {
@@ -2,7 +2,7 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.scriptAttrs = exports.inferEarlyHintLink = exports.inferPreloadTag = exports.inferAssetTag = void 0;
4
4
  const utils_js_1 = require("../../utils.js");
5
- // We can't use `defer` here. With `defer`, the entry script won't start before `</body>` has been parsed, preventing partial hydration during SSR streaming, see https://github.com/vikejs/vike/pull/1271
5
+ // We can't use `defer` here. With `defer`, the entry script won't start before `</body>` has been parsed, preventing progressive hydration during SSR streaming, see https://github.com/vikejs/vike/pull/1271
6
6
  const scriptAttrs = 'type="module" async';
7
7
  exports.scriptAttrs = scriptAttrs;
8
8
  function inferPreloadTag(pageAsset) {
@@ -6,16 +6,17 @@ const utils_js_1 = require("./utils.js");
6
6
  const query = 'extractAssets';
7
7
  function extractAssetsAddQuery(id) {
8
8
  const fileExtension = (0, utils_js_1.getFileExtension)(id);
9
- (0, utils_js_1.assert)(fileExtension || id.includes('virtual:vike:'));
10
- if (!fileExtension)
9
+ if (!fileExtension || id.includes('virtual:vike:')) {
11
10
  return `${id}?${query}`;
12
- if (id.includes('?')) {
13
- id = id.replace('?', `?${query}&`);
14
11
  }
15
12
  else {
16
- id = `${id}?${query}&lang.${fileExtension}`;
13
+ if (!id.includes('?')) {
14
+ return `${id}?${query}&lang.${fileExtension}`;
15
+ }
16
+ else {
17
+ return id.replace('?', `?${query}&`);
18
+ }
17
19
  }
18
- return id;
19
20
  }
20
21
  exports.extractAssetsAddQuery = extractAssetsAddQuery;
21
22
  function extractAssetsRemoveQuery(id) {
@@ -6,7 +6,7 @@ const getGlobalObject_js_1 = require("../../utils/getGlobalObject.js");
6
6
  const humanizeTime_js_1 = require("../../utils/humanizeTime.js");
7
7
  const isObject_js_1 = require("../../utils/isObject.js");
8
8
  const globalObject = (0, getGlobalObject_js_1.getGlobalObject)('utils/executeHook.ts', {
9
- userHookErrors: new Map()
9
+ userHookErrors: new WeakMap()
10
10
  });
11
11
  function isUserHookError(err) {
12
12
  if (!(0, isObject_js_1.isObject)(err))
@@ -2,7 +2,7 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.PROJECT_VERSION = exports.projectInfo = void 0;
4
4
  const assertSingleInstance_js_1 = require("./assertSingleInstance.js");
5
- const PROJECT_VERSION = '0.4.155';
5
+ const PROJECT_VERSION = '0.4.156-commit-1a83691';
6
6
  exports.PROJECT_VERSION = PROJECT_VERSION;
7
7
  const projectInfo = {
8
8
  projectName: 'Vike',
@@ -11,7 +11,7 @@ import { createPageContext } from './createPageContext.js';
11
11
  import { route } from '../../shared/route/index.js';
12
12
  import { noRouteMatch } from '../../shared/route/noRouteMatch.js';
13
13
  assertClientRouting();
14
- const globalObject = getGlobalObject('prefetch.ts', { linkPrefetchHandlerAdded: new Map() });
14
+ const globalObject = getGlobalObject('prefetch.ts', { linkPrefetchHandlerAdded: new WeakMap() });
15
15
  async function prefetchAssets(pageId, pageContext) {
16
16
  try {
17
17
  await loadUserFilesClientSide(pageId, pageContext._pageFilesAll, pageContext._pageConfigs);
@@ -28,7 +28,7 @@ function importBuild() {
28
28
  await replace_ASSETS_MAP(options, bundle);
29
29
  }
30
30
  },
31
- serverEntryPlugin({
31
+ ...serverEntryPlugin({
32
32
  getImporterCode: () => {
33
33
  return getEntryCode(config, configVike);
34
34
  },
@@ -61,17 +61,18 @@ function getEntryCode(config, configVike) {
61
61
  async function replace_ASSETS_MAP(options, bundle) {
62
62
  const { dir } = options;
63
63
  assert(dir);
64
- // I guess importBuild won't be found in the bundle when using @vitejs/plugin-legacy
65
- const importBuildEntry = findServerEntry(bundle);
66
- const importBuildFilePath = path.join(dir, importBuildEntry.fileName);
64
+ // This will probably fail with @vitejs/plugin-legacy
65
+ // - See `git log -p` for how we used to workaround the @vitejs/plugin-legacy issue.
66
+ const serverEntry = findServerEntry(bundle);
67
+ const serverEntryFilePath = path.join(dir, serverEntry.fileName);
67
68
  const assetsJsonFilePath = path.join(dir, '..', 'assets.json');
68
- const [assetsJsonString, importBuildFileContent] = await Promise.all([
69
+ const [assetsJsonString, serverEntryFileContent] = await Promise.all([
69
70
  await fs.readFile(assetsJsonFilePath, 'utf8'),
70
- await fs.readFile(importBuildFilePath, 'utf8')
71
+ await fs.readFile(serverEntryFilePath, 'utf8')
71
72
  ]);
72
- const importBuildFileContentFixed = importBuildFileContent.replace(ASSETS_MAP, assetsJsonString);
73
- assert(importBuildFileContentFixed !== importBuildFileContent);
74
- await fs.writeFile(importBuildFilePath, importBuildFileContentFixed);
73
+ const serverEntryFileContentPatched = serverEntryFileContent.replace(ASSETS_MAP, assetsJsonString);
74
+ assert(serverEntryFileContentPatched !== serverEntryFileContent);
75
+ await fs.writeFile(serverEntryFilePath, serverEntryFileContentPatched);
75
76
  }
76
77
  function getImportPath(config) {
77
78
  // We resolve filePathAbsolute even if we don't use it: we use require.resolve() as an assertion that the relative path is correct
@@ -85,12 +85,12 @@ async function getHtmlTags(pageContext, injectToStream, injectFilter) {
85
85
  // See https://github.com/vikejs/vike/pull/1271
86
86
  const positionJavaScriptEntry = (() => {
87
87
  if (pageContext._pageContextPromise) {
88
- assertWarning(!injectToStream, "[getHtmlTags()] We recommend against using streaming and a pageContext promise at the same time as partial hydration won't work", { onlyOnce: true });
88
+ assertWarning(!injectToStream, "[getHtmlTags()] We recommend against using streaming and a pageContext promise at the same time as progressive hydration won't work", { onlyOnce: true });
89
89
  // If there is a pageContext._pageContextPromise (which is resolved after the stream has ended) then the pageContext JSON data needs to await for it: https://vike.dev/stream#initial-data-after-stream-end
90
90
  return 'HTML_END';
91
91
  }
92
92
  if (injectToStream) {
93
- // If there is a stream then, in order to support partial hydration, inject the JavaScript during the stream after React(/Vue/Solid/...) resolved the first suspense boundary
93
+ // If there is a stream then, in order to support progressive hydration, inject the JavaScript during the stream after React(/Vue/Solid/...) resolved the first suspense boundary
94
94
  return 'STREAM';
95
95
  }
96
96
  else {
@@ -3,7 +3,7 @@ export { inferPreloadTag };
3
3
  export { inferEarlyHintLink };
4
4
  export { scriptAttrs };
5
5
  import { assert } from '../../utils.js';
6
- // We can't use `defer` here. With `defer`, the entry script won't start before `</body>` has been parsed, preventing partial hydration during SSR streaming, see https://github.com/vikejs/vike/pull/1271
6
+ // We can't use `defer` here. With `defer`, the entry script won't start before `</body>` has been parsed, preventing progressive hydration during SSR streaming, see https://github.com/vikejs/vike/pull/1271
7
7
  const scriptAttrs = 'type="module" async';
8
8
  function inferPreloadTag(pageAsset) {
9
9
  const { src, assetType, mediaType } = pageAsset;
@@ -5,16 +5,17 @@ import { assert, getFileExtension } from './utils.js';
5
5
  const query = 'extractAssets';
6
6
  function extractAssetsAddQuery(id) {
7
7
  const fileExtension = getFileExtension(id);
8
- assert(fileExtension || id.includes('virtual:vike:'));
9
- if (!fileExtension)
8
+ if (!fileExtension || id.includes('virtual:vike:')) {
10
9
  return `${id}?${query}`;
11
- if (id.includes('?')) {
12
- id = id.replace('?', `?${query}&`);
13
10
  }
14
11
  else {
15
- id = `${id}?${query}&lang.${fileExtension}`;
12
+ if (!id.includes('?')) {
13
+ return `${id}?${query}&lang.${fileExtension}`;
14
+ }
15
+ else {
16
+ return id.replace('?', `?${query}&`);
17
+ }
16
18
  }
17
- return id;
18
19
  }
19
20
  function extractAssetsRemoveQuery(id) {
20
21
  if (!id.includes('?'))
@@ -5,7 +5,7 @@ import { getGlobalObject } from '../../utils/getGlobalObject.js';
5
5
  import { humanizeTime } from '../../utils/humanizeTime.js';
6
6
  import { isObject } from '../../utils/isObject.js';
7
7
  const globalObject = getGlobalObject('utils/executeHook.ts', {
8
- userHookErrors: new Map()
8
+ userHookErrors: new WeakMap()
9
9
  });
10
10
  function isUserHookError(err) {
11
11
  if (!isObject(err))
@@ -1,13 +1,13 @@
1
1
  export { projectInfo };
2
2
  export type { ProjectTag };
3
3
  export { PROJECT_VERSION };
4
- declare const PROJECT_VERSION: "0.4.155";
4
+ declare const PROJECT_VERSION: "0.4.156-commit-1a83691";
5
5
  type PackageName = typeof projectInfo.npmPackageName;
6
6
  type ProjectVersion = typeof projectInfo.projectVersion;
7
7
  type ProjectTag = `[${PackageName}]` | `[${PackageName}@${ProjectVersion}]`;
8
8
  declare const projectInfo: {
9
9
  projectName: "Vike";
10
- projectVersion: "0.4.155";
10
+ projectVersion: "0.4.156-commit-1a83691";
11
11
  npmPackageName: "vike";
12
12
  githubRepository: "https://github.com/vikejs/vike";
13
13
  };
@@ -1,7 +1,7 @@
1
1
  export { projectInfo };
2
2
  export { PROJECT_VERSION };
3
3
  import { onProjectInfo } from './assertSingleInstance.js';
4
- const PROJECT_VERSION = '0.4.155';
4
+ const PROJECT_VERSION = '0.4.156-commit-1a83691';
5
5
  const projectInfo = {
6
6
  projectName: 'Vike',
7
7
  projectVersion: PROJECT_VERSION,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "vike",
3
- "version": "0.4.155",
3
+ "version": "0.4.156-commit-1a83691",
4
4
  "scripts": {
5
5
  "dev": "tsc --watch",
6
6
  "build": "rimraf dist/ && pnpm run build:esm && pnpm run build:cjs",
@@ -16,7 +16,7 @@
16
16
  "@brillout/json-serializer": "^0.5.8",
17
17
  "@brillout/picocolors": "^1.0.10",
18
18
  "@brillout/require-shim": "^0.1.2",
19
- "@brillout/vite-plugin-server-entry": "^0.4.1",
19
+ "@brillout/vite-plugin-server-entry": "^0.4.3",
20
20
  "acorn": "^8.0.0",
21
21
  "cac": "^6.0.0",
22
22
  "es-module-lexer": "^1.0.0",