vike 0.4.223-commit-59f3966 → 0.4.223-commit-e239e2b

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.
@@ -40,7 +40,6 @@ exports.prepareViteApiCall = prepareViteApiCall;
40
40
  exports.getViteRoot = getViteRoot;
41
41
  exports.assertViteRoot = assertViteRoot;
42
42
  exports.normalizeViteRoot = normalizeViteRoot;
43
- // TODO: enable Vike extensions to add Vite plugins
44
43
  const vite_1 = require("vite");
45
44
  const context_js_1 = require("./context.js");
46
45
  const getVikeConfig_js_1 = require("../plugin/plugins/importUserCode/v1-design/getVikeConfig.js");
@@ -206,6 +206,7 @@ function getPageConfigsBuildTime(configDefinitionsResolved, plusFilesAll, userRo
206
206
  return;
207
207
  pageConfigGlobal.configValueSources[configName] = sources;
208
208
  });
209
+ applyEffectsAll(pageConfigGlobal.configValueSources, configDefinitionsResolved.configDefinitionsGlobal);
209
210
  assertPageConfigGlobal(pageConfigGlobal, plusFilesAll);
210
211
  const pageConfigs = (0, utils_js_1.objectEntries)(configDefinitionsResolved.configDefinitionsLocal)
211
212
  .filter(([_locationId, { plusFiles }]) => isDefiningPage(plusFiles))
@@ -679,7 +680,7 @@ function applyEffectsAll(configValueSources, configDefinitions) {
679
680
  if (!source)
680
681
  return;
681
682
  // The config value is eagerly loaded since `configDef.env === 'config-only``
682
- (0, utils_js_1.assert)('value' in source);
683
+ (0, utils_js_1.assert)('value' in source); // TODO/now: refactor all `'value' in`
683
684
  // Call effect
684
685
  const configModFromEffect = configDef.effect({
685
686
  configValue: source.value,
@@ -687,12 +688,11 @@ function applyEffectsAll(configValueSources, configDefinitions) {
687
688
  });
688
689
  if (!configModFromEffect)
689
690
  return;
690
- (0, utils_js_1.assert)((0, utils_js_1.hasProp)(source, 'value')); // We need to assume that the config value is loaded at build-time
691
- applyEffect(configModFromEffect, configValueSources, configDef);
691
+ applyEffect(configModFromEffect, source, configValueSources, configName, configDef, configDefinitions);
692
692
  });
693
693
  }
694
- function applyEffect(configModFromEffect, configValueSources, configDefEffect) {
695
- const notSupported = `Effects currently only supports modifying the the ${picocolors_1.default.cyan('env')} of a config.`;
694
+ function applyEffect(configModFromEffect, source, configValueSources, configNameEffect, configDefEffect, configDefinitions) {
695
+ const notSupported = `${picocolors_1.default.cyan('meta.effect')} currently only supports setting the value of a config, or modifying the ${picocolors_1.default.cyan('meta.env')} of a config.`;
696
696
  (0, utils_js_1.objectEntries)(configModFromEffect).forEach(([configName, configValue]) => {
697
697
  if (configName === 'meta') {
698
698
  let configDefinedAt;
@@ -718,14 +718,23 @@ function applyEffect(configModFromEffect, configValueSources, configDefEffect) {
718
718
  });
719
719
  }
720
720
  else {
721
- (0, utils_js_1.assertUsage)(false, notSupported);
722
- /* To implement being able to set a config value in an effect:
723
- * - Copy and append definedAtFile.fileExportPathToShowToUser with ['meta', configName, 'effect']
724
- * - Copying the definedAtFile of the config that defines the effect
725
- * - Same precedence as the config that sets the value triggering the effect (not the config defining the effect)
726
- * - Apply sortConfigValueSources() again?
727
- configValueSources.push()
728
- */
721
+ const configDef = configDefinitions[configName];
722
+ (0, utils_js_1.assert)(configDef);
723
+ (0, utils_js_1.assert)(configDefEffect._userEffectDefinedAtFilePath);
724
+ const configValueSource = {
725
+ definedAtFilePath: configDefEffect._userEffectDefinedAtFilePath,
726
+ plusFile: source.plusFile,
727
+ locationId: source.locationId,
728
+ configEnv: configDef.env,
729
+ isOverriden: false, // TODO/now check
730
+ valueIsLoadedWithImport: false,
731
+ valueIsDefinedByPlusValueFile: false,
732
+ valueIsLoaded: true,
733
+ value: configValue
734
+ };
735
+ (0, utils_js_1.assertUsage)(!!configDef.global === !!configDefEffect.global, `The configuration ${picocolors_1.default.cyan(configNameEffect)} has a ${picocolors_1.default.cyan('meta.effect')} that changes the configuration ${picocolors_1.default.cyan(configName)} and, consequently, both ${picocolors_1.default.cyan(configNameEffect)} and ${picocolors_1.default.cyan(configName)} must have the same ${picocolors_1.default.cyan('meta.global')} value.`);
736
+ configValueSources[configName] ?? (configValueSources[configName] = []);
737
+ configValueSources[configName].push(configValueSource);
729
738
  }
730
739
  });
731
740
  }
@@ -66,7 +66,9 @@ function parseConfigValuesSerialized_tmp(configValuesSerialized) {
66
66
  const { valueSerialized, ...common } = configValueSeriliazed;
67
67
  const { value, sideExports } = parseValueSerialized(valueSerialized, configName, () => {
68
68
  (0, utils_js_1.assert)(configValueSeriliazed.type !== 'computed');
69
- return configValueSeriliazed.definedAtData;
69
+ const { definedAtData } = configValueSeriliazed;
70
+ const definedAtFile = Array.isArray(definedAtData) ? definedAtData[0] : definedAtData;
71
+ return definedAtFile;
70
72
  });
71
73
  addSideExports(sideExports);
72
74
  configValue = { value, ...common };
@@ -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.223-commit-59f3966';
5
+ exports.PROJECT_VERSION = '0.4.223-commit-e239e2b';
@@ -2,7 +2,6 @@ export { prepareViteApiCall };
2
2
  export { getViteRoot };
3
3
  export { assertViteRoot };
4
4
  export { normalizeViteRoot };
5
- // TODO: enable Vike extensions to add Vite plugins
6
5
  import { loadConfigFromFile, mergeConfig, resolveConfig } from 'vite';
7
6
  import { clearContextApiOperation, setContextApiOperation } from './context.js';
8
7
  import { getVikeConfig2 } from '../plugin/plugins/importUserCode/v1-design/getVikeConfig.js';
@@ -200,6 +200,7 @@ function getPageConfigsBuildTime(configDefinitionsResolved, plusFilesAll, userRo
200
200
  return;
201
201
  pageConfigGlobal.configValueSources[configName] = sources;
202
202
  });
203
+ applyEffectsAll(pageConfigGlobal.configValueSources, configDefinitionsResolved.configDefinitionsGlobal);
203
204
  assertPageConfigGlobal(pageConfigGlobal, plusFilesAll);
204
205
  const pageConfigs = objectEntries(configDefinitionsResolved.configDefinitionsLocal)
205
206
  .filter(([_locationId, { plusFiles }]) => isDefiningPage(plusFiles))
@@ -673,7 +674,7 @@ function applyEffectsAll(configValueSources, configDefinitions) {
673
674
  if (!source)
674
675
  return;
675
676
  // The config value is eagerly loaded since `configDef.env === 'config-only``
676
- assert('value' in source);
677
+ assert('value' in source); // TODO/now: refactor all `'value' in`
677
678
  // Call effect
678
679
  const configModFromEffect = configDef.effect({
679
680
  configValue: source.value,
@@ -681,12 +682,11 @@ function applyEffectsAll(configValueSources, configDefinitions) {
681
682
  });
682
683
  if (!configModFromEffect)
683
684
  return;
684
- assert(hasProp(source, 'value')); // We need to assume that the config value is loaded at build-time
685
- applyEffect(configModFromEffect, configValueSources, configDef);
685
+ applyEffect(configModFromEffect, source, configValueSources, configName, configDef, configDefinitions);
686
686
  });
687
687
  }
688
- function applyEffect(configModFromEffect, configValueSources, configDefEffect) {
689
- const notSupported = `Effects currently only supports modifying the the ${pc.cyan('env')} of a config.`;
688
+ function applyEffect(configModFromEffect, source, configValueSources, configNameEffect, configDefEffect, configDefinitions) {
689
+ const notSupported = `${pc.cyan('meta.effect')} currently only supports setting the value of a config, or modifying the ${pc.cyan('meta.env')} of a config.`;
690
690
  objectEntries(configModFromEffect).forEach(([configName, configValue]) => {
691
691
  if (configName === 'meta') {
692
692
  let configDefinedAt;
@@ -712,14 +712,23 @@ function applyEffect(configModFromEffect, configValueSources, configDefEffect) {
712
712
  });
713
713
  }
714
714
  else {
715
- assertUsage(false, notSupported);
716
- /* To implement being able to set a config value in an effect:
717
- * - Copy and append definedAtFile.fileExportPathToShowToUser with ['meta', configName, 'effect']
718
- * - Copying the definedAtFile of the config that defines the effect
719
- * - Same precedence as the config that sets the value triggering the effect (not the config defining the effect)
720
- * - Apply sortConfigValueSources() again?
721
- configValueSources.push()
722
- */
715
+ const configDef = configDefinitions[configName];
716
+ assert(configDef);
717
+ assert(configDefEffect._userEffectDefinedAtFilePath);
718
+ const configValueSource = {
719
+ definedAtFilePath: configDefEffect._userEffectDefinedAtFilePath,
720
+ plusFile: source.plusFile,
721
+ locationId: source.locationId,
722
+ configEnv: configDef.env,
723
+ isOverriden: false, // TODO/now check
724
+ valueIsLoadedWithImport: false,
725
+ valueIsDefinedByPlusValueFile: false,
726
+ valueIsLoaded: true,
727
+ value: configValue
728
+ };
729
+ assertUsage(!!configDef.global === !!configDefEffect.global, `The configuration ${pc.cyan(configNameEffect)} has a ${pc.cyan('meta.effect')} that changes the configuration ${pc.cyan(configName)} and, consequently, both ${pc.cyan(configNameEffect)} and ${pc.cyan(configName)} must have the same ${pc.cyan('meta.global')} value.`);
730
+ configValueSources[configName] ?? (configValueSources[configName] = []);
731
+ configValueSources[configName].push(configValueSource);
723
732
  }
724
733
  });
725
734
  }
@@ -64,7 +64,9 @@ function parseConfigValuesSerialized_tmp(configValuesSerialized) {
64
64
  const { valueSerialized, ...common } = configValueSeriliazed;
65
65
  const { value, sideExports } = parseValueSerialized(valueSerialized, configName, () => {
66
66
  assert(configValueSeriliazed.type !== 'computed');
67
- return configValueSeriliazed.definedAtData;
67
+ const { definedAtData } = configValueSeriliazed;
68
+ const definedAtFile = Array.isArray(definedAtData) ? definedAtData[0] : definedAtData;
69
+ return definedAtFile;
68
70
  });
69
71
  addSideExports(sideExports);
70
72
  configValue = { value, ...common };
@@ -1 +1 @@
1
- export declare const PROJECT_VERSION: "0.4.223-commit-59f3966";
1
+ export declare const PROJECT_VERSION: "0.4.223-commit-e239e2b";
@@ -1,2 +1,2 @@
1
1
  // Automatically updated by @brillout/release-me
2
- export const PROJECT_VERSION = '0.4.223-commit-59f3966';
2
+ export const PROJECT_VERSION = '0.4.223-commit-e239e2b';
@@ -1,4 +1,4 @@
1
1
  export declare const projectInfo: {
2
2
  projectName: "Vike";
3
- projectVersion: "0.4.223-commit-59f3966";
3
+ projectVersion: "0.4.223-commit-e239e2b";
4
4
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "vike",
3
- "version": "0.4.223-commit-59f3966",
3
+ "version": "0.4.223-commit-e239e2b",
4
4
  "repository": "https://github.com/vikejs/vike",
5
5
  "exports": {
6
6
  "./server": {
@@ -252,7 +252,7 @@
252
252
  "react-streaming": "^0.3.47",
253
253
  "rimraf": "^5.0.5",
254
254
  "typescript": "^5.7.3",
255
- "vite": "^6.0.5"
255
+ "vite": "^6.2.0"
256
256
  },
257
257
  "scripts": {
258
258
  "dev": "tsc --watch",