vike 0.4.239-commit-33e55d4 → 0.4.239-commit-59f1017

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.
@@ -8,6 +8,8 @@ exports.handleAssetsManifest_getBuildConfig = handleAssetsManifest_getBuildConfi
8
8
  exports.handleAssetsManifest_isFixEnabled = handleAssetsManifest_isFixEnabled;
9
9
  exports.handleAssetsManifest_assertUsageCssCodeSplit = handleAssetsManifest_assertUsageCssCodeSplit;
10
10
  exports.handleAssetsManifest_assertUsageCssTarget = handleAssetsManifest_assertUsageCssTarget;
11
+ exports.handleAssetsManifest_workaroundCssTarget_part1 = handleAssetsManifest_workaroundCssTarget_part1;
12
+ exports.handleAssetsManifest_workaroundCssTarget_part2 = handleAssetsManifest_workaroundCssTarget_part2;
11
13
  const promises_1 = __importDefault(require("node:fs/promises"));
12
14
  const node_fs_1 = __importDefault(require("node:fs"));
13
15
  const node_path_1 = __importDefault(require("node:path"));
@@ -21,8 +23,11 @@ const getOutDirs_js_1 = require("../../shared/getOutDirs.js");
21
23
  const isViteServerSide_js_1 = require("../../shared/isViteServerSide.js");
22
24
  const pluginProdBuildEntry_js_1 = require("./pluginProdBuildEntry.js");
23
25
  const getManifestFilePathRelative_js_1 = require("../../shared/getManifestFilePathRelative.js");
24
- const globalObject = (0, utils_js_1.getGlobalObject)('build/handleAssetsManifest.ts', {
26
+ const globalObject = (0, utils_js_1.getGlobalObject)('handleAssetsManifest.ts', {
25
27
  assetsJsonFilePath: undefined,
28
+ cssTarget: '__VIKE__UNSET',
29
+ targetsAll: [],
30
+ configsAll: [],
26
31
  });
27
32
  // yes => use workaround config.build.ssrEmitAssets
28
33
  // false => use workaround extractAssets plugin
@@ -221,16 +226,26 @@ function handleAssetsManifest_assertUsageCssCodeSplit(config) {
221
226
  return;
222
227
  (0, utils_js_1.assertWarning)(config.build.cssCodeSplit, `${picocolors_1.default.cyan('build.cssCodeSplit')} shouldn't be set to ${picocolors_1.default.cyan('false')} (https://github.com/vikejs/vike/issues/1993)`, { onlyOnce: true });
223
228
  }
224
- const targets = [];
229
+ function handleAssetsManifest_workaroundCssTarget_part1(config) {
230
+ globalObject.configsAll.push(config);
231
+ if (!(0, isViteServerSide_js_1.isViteServerSide_viteEnvOptional)(config, undefined)) {
232
+ globalObject.cssTarget = config.build.cssTarget;
233
+ }
234
+ }
235
+ function handleAssetsManifest_workaroundCssTarget_part2() {
236
+ (0, utils_js_1.assert)(globalObject.cssTarget !== '__VIKE__UNSET');
237
+ globalObject.configsAll.forEach((c) => (c.build.cssTarget = globalObject.cssTarget));
238
+ }
225
239
  function handleAssetsManifest_assertUsageCssTarget(config, env) {
226
240
  if (!handleAssetsManifest_isFixEnabled())
227
241
  return;
228
242
  const isServerSide = (0, isViteServerSide_js_1.isViteServerSide)(config, env);
229
243
  (0, utils_js_1.assert)(typeof isServerSide === 'boolean');
230
244
  (0, utils_js_1.assert)(config.build.target !== undefined);
231
- targets.push({ global: config.build.target, css: config.build.cssTarget, isServerSide });
232
- const targetsServer = targets.filter((t) => t.isServerSide);
233
- const targetsClient = targets.filter((t) => !t.isServerSide);
245
+ const { targetsAll } = globalObject;
246
+ targetsAll.push({ global: config.build.target, css: config.build.cssTarget, isServerSide });
247
+ const targetsServer = targetsAll.filter((t) => t.isServerSide);
248
+ const targetsClient = targetsAll.filter((t) => !t.isServerSide);
234
249
  targetsClient.forEach((targetClient) => {
235
250
  const targetCssResolvedClient = resolveCssTarget(targetClient);
236
251
  targetsServer.forEach((targetServer) => {
@@ -18,14 +18,26 @@ function pluginBuildConfig() {
18
18
  let config;
19
19
  return [
20
20
  {
21
- name: 'vike:build:pluginBuildConfig',
21
+ name: 'vike:build:pluginBuildConfig:post1',
22
22
  apply: 'build',
23
23
  enforce: 'post',
24
24
  configResolved: {
25
25
  order: 'post',
26
- async handler(config_) {
27
- (0, utils_js_1.onSetupBuild)();
26
+ handler(config_) {
28
27
  config = config_;
28
+ (0, handleAssetsManifest_js_1.handleAssetsManifest_workaroundCssTarget_part1)(config);
29
+ },
30
+ },
31
+ },
32
+ {
33
+ name: 'vike:build:pluginBuildConfig:post2',
34
+ apply: 'build',
35
+ enforce: 'post',
36
+ configResolved: {
37
+ order: 'post',
38
+ async handler() {
39
+ (0, handleAssetsManifest_js_1.handleAssetsManifest_workaroundCssTarget_part2)();
40
+ (0, utils_js_1.onSetupBuild)();
29
41
  assertRollupInput(config);
30
42
  const entries = await getEntries(config);
31
43
  (0, utils_js_1.assert)(Object.keys(entries).length > 0);
@@ -8,6 +8,7 @@ const pluginDistFileNames_js_1 = require("./pluginBuild/pluginDistFileNames.js")
8
8
  const pluginProdBuildEntry_js_1 = require("./pluginBuild/pluginProdBuildEntry.js");
9
9
  const pluginBuildConfig_js_1 = require("./pluginBuild/pluginBuildConfig.js");
10
10
  const pluginModuleBanner_js_1 = require("./pluginBuild/pluginModuleBanner.js");
11
+ // TODO/now refactor
11
12
  function pluginBuild() {
12
13
  return [
13
14
  ...(0, pluginBuildConfig_js_1.pluginBuildConfig)(),
@@ -2,4 +2,4 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.PROJECT_VERSION = void 0;
4
4
  // Automatically updated by @brillout/release-me
5
- exports.PROJECT_VERSION = '0.4.239-commit-33e55d4';
5
+ exports.PROJECT_VERSION = '0.4.239-commit-59f1017';
@@ -7,7 +7,7 @@ export type { PageContextBegin };
7
7
  import { type PageContextFromRewrite } from '../../shared/route/abort.js';
8
8
  import { type ScrollTarget } from './setScrollPosition.js';
9
9
  import type { PageContextConfig } from '../../shared/getPageFiles.js';
10
- import type { PageContextClient } from '../../types/PageContext.js';
10
+ import type { PageContextClient, PageContextInternalClient } from '../../types/PageContext.js';
11
11
  import type { VikeGlobalInternal } from '../../types/VikeGlobalInternal.js';
12
12
  declare const firstRenderStartPromise: Promise<void>;
13
13
  type PageContextRouted = {
@@ -107,7 +107,7 @@ declare function getPageContextBegin(isForErrorPage: boolean, { urlOriginal, isB
107
107
  isHydration: boolean;
108
108
  previousPageContext: ({
109
109
  pageId: string;
110
- } & PageContextConfig & PageContextRouted & import("../../shared/preparePageContextForPublicUsage.js").PageContextPrepareMinimum & import("../../types/PageContext.js").PageContextInternalClient & Omit<Partial<PageContextConfig & {
110
+ } & PageContextConfig & PageContextRouted & import("../../shared/preparePageContextForPublicUsage.js").PageContextPrepareMinimum & PageContextInternalClient & Omit<Partial<PageContextConfig & {
111
111
  isPageContext: true;
112
112
  Page: import("../../types/Config.js").Config["Page"];
113
113
  routeParams: Record<string, string>;
@@ -16,7 +16,7 @@ import { route } from '../../shared/route/index.js';
16
16
  import { isClientSideRoutable } from './isClientSideRoutable.js';
17
17
  import { setScrollPosition } from './setScrollPosition.js';
18
18
  import { scrollRestoration_initialRenderIsDone } from './scrollRestoration.js';
19
- import { getErrorPageId } from '../../shared/error-page.js';
19
+ import { getErrorPageId, isErrorPage } from '../../shared/error-page.js';
20
20
  import { setPageContextCurrent } from './getPageContextCurrent.js';
21
21
  import { getRouteStringParameterList } from '../../shared/route/resolveRouteString.js';
22
22
  import { getCurrentUrl } from '../shared/getCurrentUrl.js';
@@ -644,3 +644,16 @@ function handleErrorFetchingStaticAssets(err, pageContext, isFirstRender) {
644
644
  redirectHard(pageContext.urlOriginal);
645
645
  return true;
646
646
  }
647
+ // [HMR] If error page is shown => re-render whole page
648
+ if (import.meta.env.DEV && import.meta.hot)
649
+ import.meta.hot.on('vite:beforeUpdate', () => {
650
+ const pageContext = globalObject.renderedPageContext;
651
+ if (pageContext?.pageId && isErrorPage(pageContext.pageId, pageContext._globalContext._pageConfigs)) {
652
+ renderPageClientSide({
653
+ scrollTarget: { preserveScroll: false },
654
+ urlOriginal: getCurrentUrl(),
655
+ overwriteLastHistoryEntry: true,
656
+ isBackwardNavigation: false,
657
+ });
658
+ }
659
+ });
@@ -3,10 +3,14 @@ export { handleAssetsManifest_getBuildConfig };
3
3
  export { handleAssetsManifest_isFixEnabled };
4
4
  export { handleAssetsManifest_assertUsageCssCodeSplit };
5
5
  export { handleAssetsManifest_assertUsageCssTarget };
6
+ export { handleAssetsManifest_workaroundCssTarget_part1 };
7
+ export { handleAssetsManifest_workaroundCssTarget_part2 };
6
8
  import type { Environment, ResolvedConfig, Rollup } from 'vite';
7
9
  type Bundle = Rollup.OutputBundle;
8
10
  declare function handleAssetsManifest_isFixEnabled(): boolean;
9
11
  declare function handleAssetsManifest_assertUsageCssCodeSplit(config: ResolvedConfig): void;
12
+ declare function handleAssetsManifest_workaroundCssTarget_part1(config: ResolvedConfig): void;
13
+ declare function handleAssetsManifest_workaroundCssTarget_part2(): void;
10
14
  declare function handleAssetsManifest_assertUsageCssTarget(config: ResolvedConfig, env: Environment): void;
11
15
  declare function handleAssetsManifest_getBuildConfig(): Promise<{
12
16
  readonly ssrEmitAssets: true | undefined;
@@ -3,6 +3,8 @@ export { handleAssetsManifest_getBuildConfig };
3
3
  export { handleAssetsManifest_isFixEnabled };
4
4
  export { handleAssetsManifest_assertUsageCssCodeSplit };
5
5
  export { handleAssetsManifest_assertUsageCssTarget };
6
+ export { handleAssetsManifest_workaroundCssTarget_part1 };
7
+ export { handleAssetsManifest_workaroundCssTarget_part2 };
6
8
  import fs from 'node:fs/promises';
7
9
  import fs_sync from 'node:fs';
8
10
  import path from 'node:path';
@@ -13,11 +15,14 @@ import { getAssetsDir } from '../../shared/getAssetsDir.js';
13
15
  import pc from '@brillout/picocolors';
14
16
  import { isV1Design } from '../../shared/resolveVikeConfigInternal.js';
15
17
  import { getOutDirs } from '../../shared/getOutDirs.js';
16
- import { isViteServerSide_onlySsrEnv, isViteServerSide } from '../../shared/isViteServerSide.js';
18
+ import { isViteServerSide_onlySsrEnv, isViteServerSide, isViteServerSide_viteEnvOptional, } from '../../shared/isViteServerSide.js';
17
19
  import { set_macro_ASSETS_MANIFEST } from './pluginProdBuildEntry.js';
18
20
  import { getManifestFilePathRelative } from '../../shared/getManifestFilePathRelative.js';
19
- const globalObject = getGlobalObject('build/handleAssetsManifest.ts', {
21
+ const globalObject = getGlobalObject('handleAssetsManifest.ts', {
20
22
  assetsJsonFilePath: undefined,
23
+ cssTarget: '__VIKE__UNSET',
24
+ targetsAll: [],
25
+ configsAll: [],
21
26
  });
22
27
  // yes => use workaround config.build.ssrEmitAssets
23
28
  // false => use workaround extractAssets plugin
@@ -216,16 +221,26 @@ function handleAssetsManifest_assertUsageCssCodeSplit(config) {
216
221
  return;
217
222
  assertWarning(config.build.cssCodeSplit, `${pc.cyan('build.cssCodeSplit')} shouldn't be set to ${pc.cyan('false')} (https://github.com/vikejs/vike/issues/1993)`, { onlyOnce: true });
218
223
  }
219
- const targets = [];
224
+ function handleAssetsManifest_workaroundCssTarget_part1(config) {
225
+ globalObject.configsAll.push(config);
226
+ if (!isViteServerSide_viteEnvOptional(config, undefined)) {
227
+ globalObject.cssTarget = config.build.cssTarget;
228
+ }
229
+ }
230
+ function handleAssetsManifest_workaroundCssTarget_part2() {
231
+ assert(globalObject.cssTarget !== '__VIKE__UNSET');
232
+ globalObject.configsAll.forEach((c) => (c.build.cssTarget = globalObject.cssTarget));
233
+ }
220
234
  function handleAssetsManifest_assertUsageCssTarget(config, env) {
221
235
  if (!handleAssetsManifest_isFixEnabled())
222
236
  return;
223
237
  const isServerSide = isViteServerSide(config, env);
224
238
  assert(typeof isServerSide === 'boolean');
225
239
  assert(config.build.target !== undefined);
226
- targets.push({ global: config.build.target, css: config.build.cssTarget, isServerSide });
227
- const targetsServer = targets.filter((t) => t.isServerSide);
228
- const targetsClient = targets.filter((t) => !t.isServerSide);
240
+ const { targetsAll } = globalObject;
241
+ targetsAll.push({ global: config.build.target, css: config.build.cssTarget, isServerSide });
242
+ const targetsServer = targetsAll.filter((t) => t.isServerSide);
243
+ const targetsClient = targetsAll.filter((t) => !t.isServerSide);
229
244
  targetsClient.forEach((targetClient) => {
230
245
  const targetCssResolvedClient = resolveCssTarget(targetClient);
231
246
  targetsServer.forEach((targetServer) => {
@@ -10,20 +10,32 @@ import { prependEntriesDir } from '../../../shared/prependEntriesDir.js';
10
10
  import { getFilePathResolved } from '../../shared/getFilePath.js';
11
11
  import { getConfigValueBuildTime } from '../../../../shared/page-configs/getConfigValueBuildTime.js';
12
12
  import { isViteServerSide_viteEnvOptional } from '../../shared/isViteServerSide.js';
13
- import { handleAssetsManifest_assertUsageCssCodeSplit, handleAssetsManifest_getBuildConfig, } from './handleAssetsManifest.js';
13
+ import { handleAssetsManifest_assertUsageCssCodeSplit, handleAssetsManifest_getBuildConfig, handleAssetsManifest_workaroundCssTarget_part1, handleAssetsManifest_workaroundCssTarget_part2, } from './handleAssetsManifest.js';
14
14
  import { resolveIncludeAssetsImportedByServer } from '../../../runtime/renderPage/getPageAssets/retrievePageAssetsProd.js';
15
15
  function pluginBuildConfig() {
16
16
  let config;
17
17
  return [
18
18
  {
19
- name: 'vike:build:pluginBuildConfig',
19
+ name: 'vike:build:pluginBuildConfig:post1',
20
20
  apply: 'build',
21
21
  enforce: 'post',
22
22
  configResolved: {
23
23
  order: 'post',
24
- async handler(config_) {
25
- onSetupBuild();
24
+ handler(config_) {
26
25
  config = config_;
26
+ handleAssetsManifest_workaroundCssTarget_part1(config);
27
+ },
28
+ },
29
+ },
30
+ {
31
+ name: 'vike:build:pluginBuildConfig:post2',
32
+ apply: 'build',
33
+ enforce: 'post',
34
+ configResolved: {
35
+ order: 'post',
36
+ async handler() {
37
+ handleAssetsManifest_workaroundCssTarget_part2();
38
+ onSetupBuild();
27
39
  assertRollupInput(config);
28
40
  const entries = await getEntries(config);
29
41
  assert(Object.keys(entries).length > 0);
@@ -6,6 +6,7 @@ import { pluginDistFileNames } from './pluginBuild/pluginDistFileNames.js';
6
6
  import { pluginProdBuildEntry } from './pluginBuild/pluginProdBuildEntry.js';
7
7
  import { pluginBuildConfig } from './pluginBuild/pluginBuildConfig.js';
8
8
  import { pluginModuleBanner } from './pluginBuild/pluginModuleBanner.js';
9
+ // TODO/now refactor
9
10
  function pluginBuild() {
10
11
  return [
11
12
  ...pluginBuildConfig(),
@@ -1,5 +1,5 @@
1
1
  export { pluginCommon };
2
- import { assert, assertUsage, assertWarning, hasProp, isDevCheck, isDocker, isObject, isVitest, } from '../utils.js';
2
+ import { assert, assertUsage, assertWarning, hasProp, isDevCheck, isDocker, isObject, isVitest } from '../utils.js';
3
3
  import { assertRollupInput } from './pluginBuild/pluginBuildConfig.js';
4
4
  import { installRequireShim_setUserRootDir } from '@brillout/require-shim';
5
5
  import pc from '@brillout/picocolors';
@@ -1 +1 @@
1
- export declare const PROJECT_VERSION: "0.4.239-commit-33e55d4";
1
+ export declare const PROJECT_VERSION: "0.4.239-commit-59f1017";
@@ -1,2 +1,2 @@
1
1
  // Automatically updated by @brillout/release-me
2
- export const PROJECT_VERSION = '0.4.239-commit-33e55d4';
2
+ export const PROJECT_VERSION = '0.4.239-commit-59f1017';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "vike",
3
- "version": "0.4.239-commit-33e55d4",
3
+ "version": "0.4.239-commit-59f1017",
4
4
  "repository": "https://github.com/vikejs/vike",
5
5
  "exports": {
6
6
  "./server": {
@@ -263,7 +263,7 @@
263
263
  "react-streaming": "^0.4.3",
264
264
  "rimraf": "^5.0.5",
265
265
  "typescript": "^5.8.3",
266
- "vite": "^7.1.3"
266
+ "vite": "^7.1.5"
267
267
  },
268
268
  "scripts": {
269
269
  "dev": "tsc --watch",