vike 0.4.181-commit-ddcbf7d → 0.4.181-commit-b6b5064

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.
@@ -31,6 +31,10 @@ function fileEnv() {
31
31
  order: 'pre',
32
32
  */
33
33
  async handler(source, importer, options) {
34
+ // It seems like Vite's scan doesn't apply transformers. (We need the `.telefunc.js` transformer to apply for our analysis to be correct.)
35
+ // @ts-expect-error Vite's type is wrong
36
+ if (options.scan)
37
+ return;
34
38
  // TODO/v1-release: remove
35
39
  if (extractAssetsPlugin_js_1.extractAssetsRE.test(source) || extractExportNamesPlugin_js_1.extractExportNamesRE.test(source))
36
40
  return;
@@ -58,14 +62,14 @@ function fileEnv() {
58
62
  const envActual = isServerSide ? 'server' : 'client';
59
63
  const envExpect = isServerSide ? 'client' : 'server';
60
64
  const suffix = `.${envExpect}.`;
61
- // Everything nonimal
65
+ // Everything is good
62
66
  if (!modulePath.includes(suffix))
63
67
  return;
64
68
  // Show error message
65
69
  let errMsg;
66
70
  let modulePathPretty = (0, getFilePath_js_1.getModuleFilePath)(moduleId, config);
67
71
  modulePathPretty = modulePathPretty.replaceAll(suffix, picocolors_1.default.bold(suffix));
68
- errMsg = `${(0, utils_js_1.capitalizeFirstLetter)(envExpect)}-only module ${modulePathPretty} (https://vike.dev/file-env) imported on the ${envActual}-side`;
72
+ errMsg = `${(0, utils_js_1.capitalizeFirstLetter)(envExpect)}-only file ${modulePathPretty} (https://vike.dev/file-env) imported on the ${envActual}-side`;
69
73
  if (importer &&
70
74
  // Don't show Vike's virtual modules that import the entry plus files such as /pages/about/+Page.js
71
75
  !importer.includes('virtual:vike:') &&
@@ -75,10 +79,7 @@ function fileEnv() {
75
79
  errMsg += ` by ${importerPath}`;
76
80
  }
77
81
  if (isDev) {
78
- errMsg += ' (building your app for production will be prevented and an error will be thrown)';
79
- }
80
- errMsg += '.';
81
- if (isDev) {
82
+ errMsg += ' and, therefore, Vike will prevent building your app for production.';
82
83
  (0, utils_js_1.assertWarning)(false, errMsg, { onlyOnce: true });
83
84
  }
84
85
  else {
@@ -255,6 +255,33 @@ async function loadVikeConfig(userRootDir, outDirRoot, isDev, crawlWithGit) {
255
255
  if (isGlobalConfig(configName))
256
256
  return;
257
257
  const configDef = getConfigDefinition(configDefinitions, configName, interfaceFile.filePath.filePathToShowToUser);
258
+ // TODO/soon: refactor
259
+ // - Dedupe: most of the code below is a copy-paste of the assertUsage() inside getGlobalConfigs()
260
+ // - update comment above `await Promise.all`
261
+ if (configDef.global) {
262
+ const locationIds = (0, utils_js_1.objectKeys)(interfaceFilesByLocationId);
263
+ if (!(0, filesystemRouting_js_1.isGlobalLocation)(interfaceFile.locationId, locationIds)) {
264
+ const interfaceFilesGlobal = (0, utils_js_1.objectFromEntries)((0, utils_js_1.objectEntries)(interfaceFilesByLocationId).filter(([locationId]) => {
265
+ return (0, filesystemRouting_js_1.isGlobalLocation)(locationId, locationIds);
266
+ }));
267
+ const interfaceFilesGlobalPaths = [];
268
+ (0, utils_js_1.objectEntries)(interfaceFilesGlobal).forEach(([locationId, interfaceFiles]) => {
269
+ (0, utils_js_1.assert)((0, filesystemRouting_js_1.isGlobalLocation)(locationId, locationIds));
270
+ interfaceFiles.forEach(({ filePath: { filePathAbsoluteUserRootDir } }) => {
271
+ if (filePathAbsoluteUserRootDir) {
272
+ interfaceFilesGlobalPaths.push(filePathAbsoluteUserRootDir);
273
+ }
274
+ });
275
+ });
276
+ const globalPaths = Array.from(new Set(interfaceFilesGlobalPaths.map((p) => path_1.default.posix.dirname(p))));
277
+ (0, utils_js_1.assertUsage)(false, [
278
+ `${interfaceFile.filePath.filePathToShowToUser} defines the config ${picocolors_1.default.cyan(configName)} which is global:`,
279
+ globalPaths.length
280
+ ? `define ${picocolors_1.default.cyan(configName)} in ${(0, utils_js_1.joinEnglish)(globalPaths, 'or')} instead`
281
+ : `create a global config (e.g. /pages/+config.js) and define ${picocolors_1.default.cyan(configName)} there instead`
282
+ ].join(' '));
283
+ }
284
+ }
258
285
  if (!isLoadableAtBuildTime(configDef))
259
286
  return;
260
287
  const isAlreadyLoaded = interfacefileIsAlreaydLoaded(interfaceFile);
@@ -1,4 +1,5 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.PROJECT_VERSION = void 0;
4
- exports.PROJECT_VERSION = '0.4.181-commit-ddcbf7d';
4
+ // Automatically updated by @brillout/release-me
5
+ exports.PROJECT_VERSION = '0.4.181-commit-b6b5064';
@@ -26,6 +26,10 @@ function fileEnv() {
26
26
  order: 'pre',
27
27
  */
28
28
  async handler(source, importer, options) {
29
+ // It seems like Vite's scan doesn't apply transformers. (We need the `.telefunc.js` transformer to apply for our analysis to be correct.)
30
+ // @ts-expect-error Vite's type is wrong
31
+ if (options.scan)
32
+ return;
29
33
  // TODO/v1-release: remove
30
34
  if (extractAssetsRE.test(source) || extractExportNamesRE.test(source))
31
35
  return;
@@ -53,14 +57,14 @@ function fileEnv() {
53
57
  const envActual = isServerSide ? 'server' : 'client';
54
58
  const envExpect = isServerSide ? 'client' : 'server';
55
59
  const suffix = `.${envExpect}.`;
56
- // Everything nonimal
60
+ // Everything is good
57
61
  if (!modulePath.includes(suffix))
58
62
  return;
59
63
  // Show error message
60
64
  let errMsg;
61
65
  let modulePathPretty = getModuleFilePath(moduleId, config);
62
66
  modulePathPretty = modulePathPretty.replaceAll(suffix, pc.bold(suffix));
63
- errMsg = `${capitalizeFirstLetter(envExpect)}-only module ${modulePathPretty} (https://vike.dev/file-env) imported on the ${envActual}-side`;
67
+ errMsg = `${capitalizeFirstLetter(envExpect)}-only file ${modulePathPretty} (https://vike.dev/file-env) imported on the ${envActual}-side`;
64
68
  if (importer &&
65
69
  // Don't show Vike's virtual modules that import the entry plus files such as /pages/about/+Page.js
66
70
  !importer.includes('virtual:vike:') &&
@@ -70,10 +74,7 @@ function fileEnv() {
70
74
  errMsg += ` by ${importerPath}`;
71
75
  }
72
76
  if (isDev) {
73
- errMsg += ' (building your app for production will be prevented and an error will be thrown)';
74
- }
75
- errMsg += '.';
76
- if (isDev) {
77
+ errMsg += ' and, therefore, Vike will prevent building your app for production.';
77
78
  assertWarning(false, errMsg, { onlyOnce: true });
78
79
  }
79
80
  else {
@@ -31,6 +31,14 @@ type ConfigDefinition = {
31
31
  * https://vike.dev/meta
32
32
  */
33
33
  effect?: ConfigEffect;
34
+ /**
35
+ * Whether the configuration always applies to all pages (no config inheritance).
36
+ *
37
+ * @default false
38
+ *
39
+ * https://vike.dev/extends#inheritance
40
+ */
41
+ global?: boolean;
34
42
  };
35
43
  /**
36
44
  * Function called when the config value is defined.
@@ -251,6 +251,33 @@ async function loadVikeConfig(userRootDir, outDirRoot, isDev, crawlWithGit) {
251
251
  if (isGlobalConfig(configName))
252
252
  return;
253
253
  const configDef = getConfigDefinition(configDefinitions, configName, interfaceFile.filePath.filePathToShowToUser);
254
+ // TODO/soon: refactor
255
+ // - Dedupe: most of the code below is a copy-paste of the assertUsage() inside getGlobalConfigs()
256
+ // - update comment above `await Promise.all`
257
+ if (configDef.global) {
258
+ const locationIds = objectKeys(interfaceFilesByLocationId);
259
+ if (!isGlobalLocation(interfaceFile.locationId, locationIds)) {
260
+ const interfaceFilesGlobal = objectFromEntries(objectEntries(interfaceFilesByLocationId).filter(([locationId]) => {
261
+ return isGlobalLocation(locationId, locationIds);
262
+ }));
263
+ const interfaceFilesGlobalPaths = [];
264
+ objectEntries(interfaceFilesGlobal).forEach(([locationId, interfaceFiles]) => {
265
+ assert(isGlobalLocation(locationId, locationIds));
266
+ interfaceFiles.forEach(({ filePath: { filePathAbsoluteUserRootDir } }) => {
267
+ if (filePathAbsoluteUserRootDir) {
268
+ interfaceFilesGlobalPaths.push(filePathAbsoluteUserRootDir);
269
+ }
270
+ });
271
+ });
272
+ const globalPaths = Array.from(new Set(interfaceFilesGlobalPaths.map((p) => path.posix.dirname(p))));
273
+ assertUsage(false, [
274
+ `${interfaceFile.filePath.filePathToShowToUser} defines the config ${pc.cyan(configName)} which is global:`,
275
+ globalPaths.length
276
+ ? `define ${pc.cyan(configName)} in ${joinEnglish(globalPaths, 'or')} instead`
277
+ : `create a global config (e.g. /pages/+config.js) and define ${pc.cyan(configName)} there instead`
278
+ ].join(' '));
279
+ }
280
+ }
254
281
  if (!isLoadableAtBuildTime(configDef))
255
282
  return;
256
283
  const isAlreadyLoaded = interfacefileIsAlreaydLoaded(interfaceFile);
@@ -1 +1 @@
1
- export declare const PROJECT_VERSION: "0.4.181-commit-ddcbf7d";
1
+ export declare const PROJECT_VERSION: "0.4.181-commit-b6b5064";
@@ -1 +1,2 @@
1
- export const PROJECT_VERSION = '0.4.181-commit-ddcbf7d';
1
+ // Automatically updated by @brillout/release-me
2
+ export const PROJECT_VERSION = '0.4.181-commit-b6b5064';
@@ -1,4 +1,4 @@
1
1
  export declare const projectInfo: {
2
2
  projectName: "Vike";
3
- projectVersion: "0.4.181-commit-ddcbf7d";
3
+ projectVersion: "0.4.181-commit-b6b5064";
4
4
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "vike",
3
- "version": "0.4.181-commit-ddcbf7d",
3
+ "version": "0.4.181-commit-b6b5064",
4
4
  "scripts": {
5
5
  "dev": "tsc --watch",
6
6
  "build": "rimraf dist/ && pnpm run build:esm && pnpm run build:cjs",
@@ -229,7 +229,7 @@
229
229
  "sirv": "^2.0.4",
230
230
  "source-map-support": "^0.5.21",
231
231
  "typescript": "^5.4.5",
232
- "vite": "npm:@brillout/vite@5.1.0-commit-3dc7abd"
232
+ "vite": "^5.3.5"
233
233
  },
234
234
  "engines": {
235
235
  "node": ">=18.0.0"