vike 0.4.206 → 0.4.208

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.
@@ -2,7 +2,7 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.route = route;
4
4
  exports.getPagesAndRoutes = getPagesAndRoutes;
5
- exports.getPageFilesAllSafe = getPageFilesAllSafe;
5
+ exports.getMiddlewares = getMiddlewares;
6
6
  const index_js_1 = require("../shared/route/index.js");
7
7
  const getPageFiles_js_1 = require("../shared/getPageFiles.js");
8
8
  const globalContext_js_1 = require("../node/runtime/globalContext.js");
@@ -27,7 +27,18 @@ async function getPagesAndRoutes() {
27
27
  allPageIds
28
28
  };
29
29
  }
30
- // TODO: make it cleaner once the internal refactoring about global configs is done.
30
+ // TODO/eventually:
31
+ // - Remove the need for `isProduction` after Vike's CLI is implemented
32
+ // - Remove it in favor of https://vike.dev/getGlobalContext
33
+ async function getMiddlewares() {
34
+ const isProduction = process.env.NODE_ENV === 'production';
35
+ const { pageConfigs } = await getPageFilesAllSafe(isProduction);
36
+ const middlewares = pageConfigs[0].configValues.middleware.value.flat(Infinity);
37
+ return middlewares;
38
+ }
39
+ // TODO/eventually:
40
+ // - Make it cleaner once the internal refactoring about global configs is done.
41
+ // - Remove it in favor of https://vike.dev/getGlobalContext
31
42
  // Demo usage: https://github.com/vikejs/vike/pull/1823
32
43
  async function getPageFilesAllSafe(isProduction) {
33
44
  await (0, globalContext_js_1.initGlobalContext_getGlobalContextAsync)(isProduction);
@@ -62,13 +62,6 @@ function plugin(vikeConfig) {
62
62
  ];
63
63
  return plugins;
64
64
  }
65
- // Enable `const vike = require('vike/plugin')`.
66
- // - This lives at the end of the file to ensure it happens after all assignments to `exports`.
67
- // - This is only used for the CJS build; we wrap it in a try-catch for the ESM build.
68
- try {
69
- module.exports = Object.assign(exports.default, exports);
70
- }
71
- catch { }
72
65
  // Error upon wrong usage
73
66
  Object.defineProperty(plugin, 'apply', {
74
67
  enumerable: true,
@@ -80,3 +73,9 @@ Object.defineProperty(plugin, 'apply', {
80
73
  function assertViteVersion() {
81
74
  (0, utils_js_2.assertVersion)('Vite', vite_1.version, '5.1.0');
82
75
  }
76
+ // Ensures following works: `const vike = require('vike/plugin')` / `import vike from 'vike/plugin'`
77
+ // - It needs to live at the end of this file, in order to ensure we do it after all assignments to `exports`.
78
+ try {
79
+ module.exports = Object.assign(exports.default, exports);
80
+ }
81
+ catch { }
@@ -5,6 +5,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
6
  exports.fixServerAssets = fixServerAssets;
7
7
  exports.fixServerAssets_isEnabled = fixServerAssets_isEnabled;
8
+ exports.fixServerAssets_assertCssCodeSplit = fixServerAssets_assertCssCodeSplit;
8
9
  exports.fixServerAssets_assertCssTarget = fixServerAssets_assertCssTarget;
9
10
  exports.fixServerAssets_assertCssTarget_populate = fixServerAssets_assertCssTarget_populate;
10
11
  const promises_1 = __importDefault(require("fs/promises"));
@@ -157,6 +158,10 @@ function getHash(src) {
157
158
  (0, utils_js_1.assert)(hash);
158
159
  return hash;
159
160
  }
161
+ // https://github.com/vikejs/vike/issues/1993
162
+ function fixServerAssets_assertCssCodeSplit(config) {
163
+ (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 });
164
+ }
160
165
  const targets = [];
161
166
  function fixServerAssets_assertCssTarget_populate(config) {
162
167
  const isServerSide = (0, utils_js_1.viteIsSSR)(config);
@@ -176,10 +181,9 @@ async function fixServerAssets_assertCssTarget(config) {
176
181
  targetsServer.forEach((targetServer) => {
177
182
  const targetCssResolvedServer = resolveCssTarget(targetServer);
178
183
  (0, utils_js_1.assertWarning)((0, utils_js_1.isEqualStringList)(targetCssResolvedClient, targetCssResolvedServer), [
179
- 'The CSS browser target must be the same for both client-side and server-side, but we got:',
184
+ 'The CSS browser target should be the same for both client-side and server-side (https://github.com/vikejs/vike/issues/1815#issuecomment-2507002979) but we got:',
180
185
  `Client-side: ${picocolors_1.default.cyan(JSON.stringify(targetCssResolvedClient))}`,
181
- `Server-side: ${picocolors_1.default.cyan(JSON.stringify(targetCssResolvedServer))}`,
182
- 'See https://github.com/vikejs/vike/issues/1815#issuecomment-2507002979 if you want to know why.'
186
+ `Server-side: ${picocolors_1.default.cyan(JSON.stringify(targetCssResolvedServer))}`
183
187
  ].join('\n'), {
184
188
  showStackTrace: true,
185
189
  onlyOnce: 'different-css-target'
@@ -55,6 +55,7 @@ function buildConfig() {
55
55
  // Required if `ssrEmitAssets: true`, see https://github.com/vitejs/vite/pull/11430#issuecomment-1454800934
56
56
  config.build.cssMinify = 'esbuild';
57
57
  (0, fixServerAssets_js_1.fixServerAssets_assertCssTarget_populate)(config);
58
+ (0, fixServerAssets_js_1.fixServerAssets_assertCssCodeSplit)(config);
58
59
  }
59
60
  }
60
61
  }
@@ -131,7 +131,9 @@ const configDefinitionsBuiltIn = {
131
131
  },
132
132
  keepScrollPosition: {
133
133
  env: { client: true }
134
- }
134
+ },
135
+ // TODO/eventually: define it as a global config.
136
+ middleware: { env: { server: true }, cumulative: true, eager: true }
135
137
  };
136
138
  exports.configDefinitionsBuiltIn = configDefinitionsBuiltIn;
137
139
  const configDefinitionsBuiltInGlobal = {
@@ -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.206';
5
+ exports.PROJECT_VERSION = '0.4.208';
@@ -12,3 +12,8 @@ function pathJoin(path1, path2) {
12
12
  joined = '/' + joined;
13
13
  return joined;
14
14
  }
15
+ /* https://github.com/brillout/telefunc/blob/0fd44322acbd07857ae29361ba7c998607f17dd5/telefunc/utils/path-shim.ts#L17-L21
16
+ function isAbsolute(filePath: string) {
17
+ // ...
18
+ }
19
+ */
@@ -1,6 +1,6 @@
1
1
  export { route, getPagesAndRoutes };
2
2
  export type { PageRoutes, PageFile, PageConfigRuntime as PageConfig };
3
- export { getPageFilesAllSafe };
3
+ export { getMiddlewares };
4
4
  import { route as routeInternal, type PageRoutes } from '../shared/route/index.js';
5
5
  import { type PageFile } from '../shared/getPageFiles.js';
6
6
  import { PageConfigRuntime } from '../shared/page-configs/PageConfig.js';
@@ -16,12 +16,7 @@ declare function getPagesAndRoutes(): Promise<{
16
16
  pageConfigs: PageConfigRuntime[];
17
17
  allPageIds: string[];
18
18
  }>;
19
- declare function getPageFilesAllSafe(isProduction: boolean): Promise<{
20
- pageFilesAll: PageFile[];
21
- allPageIds: string[];
22
- pageConfigs: PageConfigRuntime[];
23
- pageConfigGlobal: import("../shared/page-configs/PageConfig.js").PageConfigGlobalRuntime;
24
- }>;
19
+ declare function getMiddlewares(): Promise<unknown[]>;
25
20
  declare function route(pageContext: Parameters<typeof routeInternal>[0]): Promise<{
26
21
  pageContextAddendum: import("../shared/route/index.js").PageContextFromRoute;
27
22
  }>;
@@ -1,7 +1,7 @@
1
1
  // Internals needed by vite-plugin-vercel
2
2
  export { route, getPagesAndRoutes };
3
- // Internals needed by nitedani's experimental implementation of vike-telefunc
4
- export { getPageFilesAllSafe };
3
+ // Internals needed by experimental implementation of vike-telefunc
4
+ export { getMiddlewares };
5
5
  import { route as routeInternal } from '../shared/route/index.js';
6
6
  import { getPageFilesAll } from '../shared/getPageFiles.js';
7
7
  import { getGlobalContext, initGlobalContext_getGlobalContextAsync } from '../node/runtime/globalContext.js';
@@ -26,7 +26,18 @@ async function getPagesAndRoutes() {
26
26
  allPageIds
27
27
  };
28
28
  }
29
- // TODO: make it cleaner once the internal refactoring about global configs is done.
29
+ // TODO/eventually:
30
+ // - Remove the need for `isProduction` after Vike's CLI is implemented
31
+ // - Remove it in favor of https://vike.dev/getGlobalContext
32
+ async function getMiddlewares() {
33
+ const isProduction = process.env.NODE_ENV === 'production';
34
+ const { pageConfigs } = await getPageFilesAllSafe(isProduction);
35
+ const middlewares = pageConfigs[0].configValues.middleware.value.flat(Infinity);
36
+ return middlewares;
37
+ }
38
+ // TODO/eventually:
39
+ // - Make it cleaner once the internal refactoring about global configs is done.
40
+ // - Remove it in favor of https://vike.dev/getGlobalContext
30
41
  // Demo usage: https://github.com/vikejs/vike/pull/1823
31
42
  async function getPageFilesAllSafe(isProduction) {
32
43
  await initGlobalContext_getGlobalContextAsync(isProduction);
@@ -218,6 +218,7 @@ async function renderPageClientSide(renderArgs) {
218
218
  isBackwardNavigation,
219
219
  isClientSideNavigation,
220
220
  isHydration: isFirstRender && !isForErrorPage,
221
+ // Make it public as `pageContext.previous`? Maybe after https://github.com/vikejs/vike/issues/1268
221
222
  _previousPageContext: previousPageContext,
222
223
  ...pageContextInitClient
223
224
  });
@@ -56,13 +56,6 @@ function plugin(vikeConfig) {
56
56
  ];
57
57
  return plugins;
58
58
  }
59
- // Enable `const vike = require('vike/plugin')`.
60
- // - This lives at the end of the file to ensure it happens after all assignments to `exports`.
61
- // - This is only used for the CJS build; we wrap it in a try-catch for the ESM build.
62
- try {
63
- module.exports = Object.assign(exports.default, exports);
64
- }
65
- catch { }
66
59
  // Error upon wrong usage
67
60
  Object.defineProperty(plugin, 'apply', {
68
61
  enumerable: true,
@@ -74,3 +67,9 @@ Object.defineProperty(plugin, 'apply', {
74
67
  function assertViteVersion() {
75
68
  assertVersion('Vite', version, '5.1.0');
76
69
  }
70
+ // Ensures following works: `const vike = require('vike/plugin')` / `import vike from 'vike/plugin'`
71
+ // - It needs to live at the end of this file, in order to ensure we do it after all assignments to `exports`.
72
+ try {
73
+ module.exports = Object.assign(exports.default, exports);
74
+ }
75
+ catch { }
@@ -1,5 +1,6 @@
1
1
  export { fixServerAssets };
2
2
  export { fixServerAssets_isEnabled };
3
+ export { fixServerAssets_assertCssCodeSplit };
3
4
  export { fixServerAssets_assertCssTarget };
4
5
  export { fixServerAssets_assertCssTarget_populate };
5
6
  import { ViteManifest } from '../../../shared/ViteManifest.js';
@@ -13,5 +14,6 @@ import { ResolvedConfig } from 'vite';
13
14
  declare function fixServerAssets_isEnabled(): boolean;
14
15
  /** https://github.com/vikejs/vike/issues/1339 */
15
16
  declare function fixServerAssets(config: ResolvedConfig): Promise<ViteManifest>;
17
+ declare function fixServerAssets_assertCssCodeSplit(config: ResolvedConfig): void;
16
18
  declare function fixServerAssets_assertCssTarget_populate(config: ResolvedConfig): void;
17
19
  declare function fixServerAssets_assertCssTarget(config: ResolvedConfig): Promise<void>;
@@ -1,5 +1,6 @@
1
1
  export { fixServerAssets };
2
2
  export { fixServerAssets_isEnabled };
3
+ export { fixServerAssets_assertCssCodeSplit };
3
4
  export { fixServerAssets_assertCssTarget };
4
5
  export { fixServerAssets_assertCssTarget_populate };
5
6
  import fs from 'fs/promises';
@@ -152,6 +153,10 @@ function getHash(src) {
152
153
  assert(hash);
153
154
  return hash;
154
155
  }
156
+ // https://github.com/vikejs/vike/issues/1993
157
+ function fixServerAssets_assertCssCodeSplit(config) {
158
+ 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 });
159
+ }
155
160
  const targets = [];
156
161
  function fixServerAssets_assertCssTarget_populate(config) {
157
162
  const isServerSide = viteIsSSR(config);
@@ -171,10 +176,9 @@ async function fixServerAssets_assertCssTarget(config) {
171
176
  targetsServer.forEach((targetServer) => {
172
177
  const targetCssResolvedServer = resolveCssTarget(targetServer);
173
178
  assertWarning(isEqualStringList(targetCssResolvedClient, targetCssResolvedServer), [
174
- 'The CSS browser target must be the same for both client-side and server-side, but we got:',
179
+ 'The CSS browser target should be the same for both client-side and server-side (https://github.com/vikejs/vike/issues/1815#issuecomment-2507002979) but we got:',
175
180
  `Client-side: ${pc.cyan(JSON.stringify(targetCssResolvedClient))}`,
176
- `Server-side: ${pc.cyan(JSON.stringify(targetCssResolvedServer))}`,
177
- 'See https://github.com/vikejs/vike/issues/1815#issuecomment-2507002979 if you want to know why.'
181
+ `Server-side: ${pc.cyan(JSON.stringify(targetCssResolvedServer))}`
178
182
  ].join('\n'), {
179
183
  showStackTrace: true,
180
184
  onlyOnce: 'different-css-target'
@@ -11,7 +11,7 @@ import { extractAssetsAddQuery } from '../../shared/extractAssetsQuery.js';
11
11
  import { createRequire } from 'module';
12
12
  import fs from 'fs/promises';
13
13
  import path from 'path';
14
- import { fixServerAssets, fixServerAssets_assertCssTarget, fixServerAssets_assertCssTarget_populate, fixServerAssets_isEnabled } from './buildConfig/fixServerAssets.js';
14
+ import { fixServerAssets, fixServerAssets_assertCssCodeSplit, fixServerAssets_assertCssTarget, fixServerAssets_assertCssTarget_populate, fixServerAssets_isEnabled } from './buildConfig/fixServerAssets.js';
15
15
  import { set_ASSETS_MAP } from './importBuild/index.js';
16
16
  import { prependEntriesDir } from '../../shared/prependEntriesDir.js';
17
17
  import { getFilePathResolved } from '../shared/getFilePath.js';
@@ -49,6 +49,7 @@ function buildConfig() {
49
49
  // Required if `ssrEmitAssets: true`, see https://github.com/vitejs/vite/pull/11430#issuecomment-1454800934
50
50
  config.build.cssMinify = 'esbuild';
51
51
  fixServerAssets_assertCssTarget_populate(config);
52
+ fixServerAssets_assertCssCodeSplit(config);
52
53
  }
53
54
  }
54
55
  }
@@ -130,7 +130,9 @@ const configDefinitionsBuiltIn = {
130
130
  },
131
131
  keepScrollPosition: {
132
132
  env: { client: true }
133
- }
133
+ },
134
+ // TODO/eventually: define it as a global config.
135
+ middleware: { env: { server: true }, cumulative: true, eager: true }
134
136
  };
135
137
  const configDefinitionsBuiltInGlobal = {
136
138
  onPrerenderStart: {
@@ -43,7 +43,7 @@ type HookName = HookNamePage | HookNameGlobal | HookNameOldDesign;
43
43
  type HookNamePage = 'onHydrationEnd' | 'onBeforePrerenderStart' | 'onBeforeRender' | 'onPageTransitionStart' | 'onPageTransitionEnd' | 'onRenderHtml' | 'onRenderClient' | 'guard' | 'data';
44
44
  type HookNameGlobal = 'onBeforePrerender' | 'onBeforeRoute' | 'onPrerenderStart';
45
45
  type HookNameOldDesign = 'render' | 'prerender';
46
- type ConfigNameBuiltIn = Exclude<keyof Config, keyof ConfigVikeUserProvided | 'onBeforeRoute' | 'onPrerenderStart'> | 'prerender' | 'isClientRuntimeLoaded' | 'onBeforeRenderEnv' | 'dataEnv' | 'hooksTimeout' | 'clientHooks';
46
+ type ConfigNameBuiltIn = Exclude<keyof Config, keyof ConfigVikeUserProvided | 'onBeforeRoute' | 'onPrerenderStart'> | 'prerender' | 'isClientRuntimeLoaded' | 'onBeforeRenderEnv' | 'dataEnv' | 'hooksTimeout' | 'clientHooks' | 'middleware';
47
47
  type Config = ConfigBuiltIn & Vike.Config & (VikePackages.ConfigVikeReact | VikePackages.ConfigVikeVue | VikePackages.ConfigVikeSolid | VikePackages.ConfigVikeSvelte | VikePackages.ConfigVikeAngular);
48
48
  /** Hook for fetching data.
49
49
  *
@@ -1 +1 @@
1
- export declare const PROJECT_VERSION: "0.4.206";
1
+ export declare const PROJECT_VERSION: "0.4.208";
@@ -1,2 +1,2 @@
1
1
  // Automatically updated by @brillout/release-me
2
- export const PROJECT_VERSION = '0.4.206';
2
+ export const PROJECT_VERSION = '0.4.208';
@@ -10,3 +10,8 @@ function pathJoin(path1, path2) {
10
10
  joined = '/' + joined;
11
11
  return joined;
12
12
  }
13
+ /* https://github.com/brillout/telefunc/blob/0fd44322acbd07857ae29361ba7c998607f17dd5/telefunc/utils/path-shim.ts#L17-L21
14
+ function isAbsolute(filePath: string) {
15
+ // ...
16
+ }
17
+ */
@@ -1,4 +1,4 @@
1
1
  export declare const projectInfo: {
2
2
  projectName: "Vike";
3
- projectVersion: "0.4.206";
3
+ projectVersion: "0.4.208";
4
4
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "vike",
3
- "version": "0.4.206",
3
+ "version": "0.4.208",
4
4
  "repository": "https://github.com/vikejs/vike",
5
5
  "exports": {
6
6
  "./server": {
@@ -122,7 +122,7 @@
122
122
  },
123
123
  "dependencies": {
124
124
  "@brillout/import": "^0.2.3",
125
- "@brillout/json-serializer": "^0.5.13",
125
+ "@brillout/json-serializer": "^0.5.15",
126
126
  "@brillout/picocolors": "^1.0.15",
127
127
  "@brillout/require-shim": "^0.1.2",
128
128
  "@brillout/vite-plugin-server-entry": "^0.5.0",
@@ -231,7 +231,7 @@
231
231
  "@types/resolve": "^1.20.6",
232
232
  "@types/semver": "^7.5.8",
233
233
  "@types/source-map-support": "^0.5.10",
234
- "react-streaming": "^0.3.43",
234
+ "react-streaming": "^0.3.44",
235
235
  "rimraf": "^5.0.5",
236
236
  "typescript": "^5.6.2",
237
237
  "vite": "^5.4.0"