vike 0.4.154 → 0.4.156-commit-f4c1d32

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.
@@ -4,7 +4,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
6
  exports.importBuild = void 0;
7
- const plugin_js_1 = require("@brillout/vite-plugin-import-build/plugin.js");
7
+ const plugin_js_1 = require("@brillout/vite-plugin-server-entry/plugin.js");
8
8
  const utils_js_1 = require("../../utils.js");
9
9
  const path_1 = __importDefault(require("path"));
10
10
  const module_1 = require("module");
@@ -33,7 +33,7 @@ function importBuild() {
33
33
  await replace_ASSETS_MAP(options, bundle);
34
34
  }
35
35
  },
36
- (0, plugin_js_1.importBuild)({
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.findImportBuildBundleEntry)(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
@@ -101,7 +101,7 @@ async function runPrerender(options, manuallyTriggered) {
101
101
  }
102
102
  const { partial = false, noExtraDir = false, parallel = true } = prerenderConfig || {};
103
103
  const concurrencyLimit = (0, pLimit_js_1.pLimit)(parallel === false || parallel === 0 ? 1 : parallel === true || parallel === undefined ? (0, os_1.cpus)().length : parallel);
104
- (0, assertPathIsFilesystemAbsolute_js_1.assertPathIsFilesystemAbsolute)(outDirRoot); // Needed for loadServerBuild(outDir) of @brillout/vite-plugin-import-build
104
+ (0, assertPathIsFilesystemAbsolute_js_1.assertPathIsFilesystemAbsolute)(outDirRoot); // Needed for loadImportBuild(outDir) of @brillout/vite-plugin-server-entry
105
105
  await (0, globalContext_js_1.initGlobalContext)(true, outDirRoot);
106
106
  const renderContext = await (0, renderPageAlreadyRouted_js_1.getRenderContext)();
107
107
  renderContext.pageFilesAll.forEach(assertExportNames);
@@ -1,7 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.setImportBuildGetters = exports.loadImportBuild = void 0;
4
- const loadServerBuild_js_1 = require("@brillout/vite-plugin-import-build/loadServerBuild.js");
4
+ const importServerEntry_js_1 = require("@brillout/vite-plugin-server-entry/importServerEntry.js");
5
5
  const utils_js_1 = require("../utils.js");
6
6
  const buildGetters = (globalThis.__vike_buildGetters = globalThis.__vike_buildGetters || {
7
7
  getters: null
@@ -12,7 +12,7 @@ function setImportBuildGetters(getters) {
12
12
  exports.setImportBuildGetters = setImportBuildGetters;
13
13
  async function loadImportBuild(outDir) {
14
14
  if (!buildGetters.getters) {
15
- await (0, loadServerBuild_js_1.loadServerBuild)(outDir);
15
+ await (0, importServerEntry_js_1.importServerEntry)(outDir);
16
16
  (0, utils_js_1.assert)(buildGetters.getters);
17
17
  }
18
18
  const [pageFiles, clientManifest, pluginManifest] = await Promise.all([
@@ -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) {
@@ -264,7 +264,7 @@ function includesNodeModules(str) {
264
264
  return true;
265
265
  }
266
266
  function normalize(packageNames) {
267
- const result = (0, utils_js_1.unique)(packageNames.filter(utils_js_1.isNotNullish));
267
+ const result = (0, utils_js_1.unique)(packageNames.filter(utils_js_1.isNotNullish).filter((packageName) => packageName !== '@brillout/import'));
268
268
  if (result.length === 0)
269
269
  return false;
270
270
  return result;
@@ -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) {
@@ -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.154';
5
+ const PROJECT_VERSION = '0.4.156-commit-f4c1d32';
6
6
  exports.PROJECT_VERSION = PROJECT_VERSION;
7
7
  const projectInfo = {
8
8
  projectName: 'Vike',
@@ -1,5 +1,5 @@
1
1
  export { importBuild };
2
- import { importBuild as importBuild_, findImportBuildBundleEntry } from '@brillout/vite-plugin-import-build/plugin.js';
2
+ import { serverEntryPlugin, findServerEntry } from '@brillout/vite-plugin-server-entry/plugin.js';
3
3
  import { assert, getOutDirs, projectInfo, toPosixPath, viteIsSSR } from '../../utils.js';
4
4
  import path from 'path';
5
5
  import { createRequire } from 'module';
@@ -28,7 +28,7 @@ function importBuild() {
28
28
  await replace_ASSETS_MAP(options, bundle);
29
29
  }
30
30
  },
31
- importBuild_({
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 = findImportBuildBundleEntry(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
@@ -73,7 +73,7 @@ async function runPrerender(options, manuallyTriggered) {
73
73
  }
74
74
  const { partial = false, noExtraDir = false, parallel = true } = prerenderConfig || {};
75
75
  const concurrencyLimit = pLimit(parallel === false || parallel === 0 ? 1 : parallel === true || parallel === undefined ? cpus().length : parallel);
76
- assertPathIsFilesystemAbsolute(outDirRoot); // Needed for loadServerBuild(outDir) of @brillout/vite-plugin-import-build
76
+ assertPathIsFilesystemAbsolute(outDirRoot); // Needed for loadImportBuild(outDir) of @brillout/vite-plugin-server-entry
77
77
  await initGlobalContext(true, outDirRoot);
78
78
  const renderContext = await getRenderContext();
79
79
  renderContext.pageFilesAll.forEach(assertExportNames);
@@ -1,6 +1,6 @@
1
1
  export { loadImportBuild };
2
2
  export { setImportBuildGetters };
3
- import { loadServerBuild } from '@brillout/vite-plugin-import-build/loadServerBuild.js';
3
+ import { importServerEntry } from '@brillout/vite-plugin-server-entry/importServerEntry.js';
4
4
  import { assert } from '../utils.js';
5
5
  const buildGetters = (globalThis.__vike_buildGetters = globalThis.__vike_buildGetters || {
6
6
  getters: null
@@ -10,7 +10,7 @@ function setImportBuildGetters(getters) {
10
10
  }
11
11
  async function loadImportBuild(outDir) {
12
12
  if (!buildGetters.getters) {
13
- await loadServerBuild(outDir);
13
+ await importServerEntry(outDir);
14
14
  assert(buildGetters.getters);
15
15
  }
16
16
  const [pageFiles, clientManifest, pluginManifest] = await Promise.all([
@@ -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;
@@ -259,7 +259,7 @@ function includesNodeModules(str) {
259
259
  return true;
260
260
  }
261
261
  function normalize(packageNames) {
262
- const result = unique(packageNames.filter(isNotNullish));
262
+ const result = unique(packageNames.filter(isNotNullish).filter((packageName) => packageName !== '@brillout/import'));
263
263
  if (result.length === 0)
264
264
  return false;
265
265
  return result;
@@ -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('?'))
@@ -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.154";
4
+ declare const PROJECT_VERSION: "0.4.156-commit-f4c1d32";
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.154";
10
+ projectVersion: "0.4.156-commit-f4c1d32";
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.154';
4
+ const PROJECT_VERSION = '0.4.156-commit-f4c1d32';
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.154",
3
+ "version": "0.4.156-commit-f4c1d32",
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-import-build": "^0.3.4",
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",
@@ -173,7 +173,7 @@
173
173
  "@brillout/json-serializer": "^0.5.8",
174
174
  "@brillout/picocolors": "^1.0.10",
175
175
  "@brillout/require-shim": "^0.1.2",
176
- "@brillout/vite-plugin-import-build": "^0.3.1",
176
+ "@brillout/vite-plugin-server-entry": "^0.4.0",
177
177
  "acorn": "^8.11.2",
178
178
  "cac": "^6.7.14",
179
179
  "es-module-lexer": "^1.4.1",