vike 0.4.218-commit-ed9b3d4 → 0.4.218-commit-85af52a

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.
@@ -53,7 +53,7 @@ function plugin(vikeVitePluginOptions = {}) {
53
53
  (0, suppressRollupWarning_js_1.suppressRollupWarning)(),
54
54
  ...(0, setGlobalContext_js_1.setGlobalContext)(),
55
55
  ...(0, index_js_3.buildEntry)(),
56
- (0, baseUrls_js_1.baseUrls)(vikeVitePluginOptions),
56
+ (0, baseUrls_js_1.baseUrls)(),
57
57
  (0, envVars_js_1.envVarsPlugin)(),
58
58
  (0, fileEnv_js_1.fileEnv)(),
59
59
  (0, workaroundCssModuleHmr_js_1.workaroundCssModuleHmr)(),
@@ -4,22 +4,16 @@ exports.baseUrls = baseUrls;
4
4
  const resolveBase_js_1 = require("../../shared/resolveBase.js");
5
5
  const utils_js_1 = require("../utils.js");
6
6
  const getVikeConfig_js_1 = require("./importUserCode/v1-design/getVikeConfig.js");
7
- const prepareViteApiCall_js_1 = require("../../api/prepareViteApiCall.js");
8
- function baseUrls(vikeVitePluginOptions) {
7
+ function baseUrls() {
9
8
  let basesResolved;
10
- let root;
11
9
  return {
12
10
  name: 'vike:baseUrls',
13
11
  enforce: 'post',
14
- async config(config, env) {
12
+ async config(config) {
15
13
  const isDev = config._isDev;
16
14
  (0, utils_js_1.assert)(typeof isDev === 'boolean');
17
- const operation = env.command === 'build' ? 'build' : env.isPreview ? 'preview' : 'dev';
18
- root = config.root ? (0, prepareViteApiCall_js_1.normalizeViteRoot)(config.root) : await (0, prepareViteApiCall_js_1.getViteRoot)(operation);
19
- (0, utils_js_1.assert)(root);
20
15
  const baseViteOriginal = config.base ?? '/__UNSET__'; // '/__UNSET__' because Vite resolves `_baseViteOriginal: null` to `undefined`
21
- const vikeConfig = await (0, getVikeConfig_js_1.getVikeConfig2)(root, isDev, vikeVitePluginOptions);
22
- basesResolved = (0, resolveBase_js_1.resolveBase)(baseViteOriginal, vikeConfig.vikeConfigGlobal.baseServer, vikeConfig.vikeConfigGlobal.baseAssets);
16
+ basesResolved = (0, resolveBase_js_1.resolveBase)(baseViteOriginal, config.vikeTmp.vikeConfigGlobal.baseServer, config.vikeTmp.vikeConfigGlobal.baseAssets);
23
17
  // We cannot define these in configResolved() because Vite picks up the env variables before any configResolved() hook is called
24
18
  process.env.BASE_SERVER = basesResolved.baseServer;
25
19
  process.env.BASE_ASSETS = basesResolved.baseAssets;
@@ -34,7 +28,6 @@ function baseUrls(vikeVitePluginOptions) {
34
28
  };
35
29
  },
36
30
  async configResolved(config) {
37
- (0, prepareViteApiCall_js_1.assertViteRoot)(root, config);
38
31
  const vikeConfig = await (0, getVikeConfig_js_1.getVikeConfig)(config);
39
32
  const basesResolved2 = (0, resolveBase_js_1.resolveBaseFromResolvedConfig)(vikeConfig.vikeConfigGlobal.baseServer, vikeConfig.vikeConfigGlobal.baseAssets, config);
40
33
  (0, utils_js_1.assert)(basesResolved2.baseServer === basesResolved.baseServer);
@@ -14,6 +14,8 @@ const assertResolveAlias_js_1 = require("./commonConfig/assertResolveAlias.js");
14
14
  const getEnvVarObject_js_1 = require("../shared/getEnvVarObject.js");
15
15
  const isViteCliCall_js_1 = require("../shared/isViteCliCall.js");
16
16
  const context_js_1 = require("../../api/context.js");
17
+ const getVikeConfig_js_1 = require("./importUserCode/v1-design/getVikeConfig.js");
18
+ const prepareViteApiCall_js_1 = require("../../api/prepareViteApiCall.js");
17
19
  const pluginName = 'vike:commonConfig';
18
20
  function commonConfig(vikeVitePluginOptions) {
19
21
  return [
@@ -22,10 +24,18 @@ function commonConfig(vikeVitePluginOptions) {
22
24
  enforce: 'pre',
23
25
  config: {
24
26
  order: 'pre',
25
- handler(_config, env) {
27
+ async handler(configFromUser, env) {
28
+ const isDev = (0, utils_js_1.isDevCheck)(env);
29
+ const operation = env.command === 'build' ? 'build' : env.isPreview ? 'preview' : 'dev';
30
+ const root = configFromUser.root ? (0, prepareViteApiCall_js_1.normalizeViteRoot)(configFromUser.root) : await (0, prepareViteApiCall_js_1.getViteRoot)(operation);
31
+ (0, utils_js_1.assert)(root);
32
+ const vikeConfig = await (0, getVikeConfig_js_1.getVikeConfig2)(root, isDev, vikeVitePluginOptions);
26
33
  return {
27
- _isDev: (0, utils_js_1.isDevCheck)(env),
28
- _vikeVitePluginOptions: vikeVitePluginOptions
34
+ _isDev: isDev,
35
+ _root: root,
36
+ _vikeVitePluginOptions: vikeVitePluginOptions,
37
+ vike: vikeConfig.vikeConfigNew,
38
+ vikeTmp: vikeConfig
29
39
  };
30
40
  }
31
41
  }
@@ -33,6 +43,7 @@ function commonConfig(vikeVitePluginOptions) {
33
43
  {
34
44
  name: pluginName,
35
45
  configResolved(config) {
46
+ (0, prepareViteApiCall_js_1.assertViteRoot)(config._root, config);
36
47
  assertSingleInstance(config);
37
48
  (0, require_shim_1.installRequireShim_setUserRootDir)(config.root);
38
49
  }
@@ -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.218-commit-ed9b3d4';
5
+ exports.PROJECT_VERSION = '0.4.218-commit-85af52a';
@@ -47,7 +47,7 @@ function plugin(vikeVitePluginOptions = {}) {
47
47
  suppressRollupWarning(),
48
48
  ...setGlobalContext(),
49
49
  ...buildEntry(),
50
- baseUrls(vikeVitePluginOptions),
50
+ baseUrls(),
51
51
  envVarsPlugin(),
52
52
  fileEnv(),
53
53
  workaroundCssModuleHmr(),
@@ -1,3 +1,3 @@
1
1
  export { baseUrls };
2
2
  import type { Plugin } from 'vite';
3
- declare function baseUrls(vikeVitePluginOptions: unknown): Plugin;
3
+ declare function baseUrls(): Plugin;
@@ -1,23 +1,17 @@
1
1
  export { baseUrls };
2
2
  import { resolveBase, resolveBaseFromResolvedConfig } from '../../shared/resolveBase.js';
3
3
  import { assert } from '../utils.js';
4
- import { getVikeConfig, getVikeConfig2 } from './importUserCode/v1-design/getVikeConfig.js';
5
- import { assertViteRoot, getViteRoot, normalizeViteRoot } from '../../api/prepareViteApiCall.js';
6
- function baseUrls(vikeVitePluginOptions) {
4
+ import { getVikeConfig } from './importUserCode/v1-design/getVikeConfig.js';
5
+ function baseUrls() {
7
6
  let basesResolved;
8
- let root;
9
7
  return {
10
8
  name: 'vike:baseUrls',
11
9
  enforce: 'post',
12
- async config(config, env) {
10
+ async config(config) {
13
11
  const isDev = config._isDev;
14
12
  assert(typeof isDev === 'boolean');
15
- const operation = env.command === 'build' ? 'build' : env.isPreview ? 'preview' : 'dev';
16
- root = config.root ? normalizeViteRoot(config.root) : await getViteRoot(operation);
17
- assert(root);
18
13
  const baseViteOriginal = config.base ?? '/__UNSET__'; // '/__UNSET__' because Vite resolves `_baseViteOriginal: null` to `undefined`
19
- const vikeConfig = await getVikeConfig2(root, isDev, vikeVitePluginOptions);
20
- basesResolved = resolveBase(baseViteOriginal, vikeConfig.vikeConfigGlobal.baseServer, vikeConfig.vikeConfigGlobal.baseAssets);
14
+ basesResolved = resolveBase(baseViteOriginal, config.vikeTmp.vikeConfigGlobal.baseServer, config.vikeTmp.vikeConfigGlobal.baseAssets);
21
15
  // We cannot define these in configResolved() because Vite picks up the env variables before any configResolved() hook is called
22
16
  process.env.BASE_SERVER = basesResolved.baseServer;
23
17
  process.env.BASE_ASSETS = basesResolved.baseAssets;
@@ -32,7 +26,6 @@ function baseUrls(vikeVitePluginOptions) {
32
26
  };
33
27
  },
34
28
  async configResolved(config) {
35
- assertViteRoot(root, config);
36
29
  const vikeConfig = await getVikeConfig(config);
37
30
  const basesResolved2 = resolveBaseFromResolvedConfig(vikeConfig.vikeConfigGlobal.baseServer, vikeConfig.vikeConfigGlobal.baseAssets, config);
38
31
  assert(basesResolved2.baseServer === basesResolved.baseServer);
@@ -1,9 +1,14 @@
1
1
  export { commonConfig };
2
2
  import { type Plugin } from 'vite';
3
+ import { type VikeConfigObject, type VikeConfigNew } from './importUserCode/v1-design/getVikeConfig.js';
3
4
  declare module 'vite' {
4
5
  interface UserConfig {
5
6
  _isDev?: boolean;
6
7
  _vikeVitePluginOptions?: unknown;
8
+ _root?: string;
9
+ vike?: VikeConfigNew;
10
+ /** @deprecated */
11
+ vikeTmp?: VikeConfigObject;
7
12
  }
8
13
  }
9
14
  declare function commonConfig(vikeVitePluginOptions: unknown): Plugin[];
@@ -9,6 +9,8 @@ import { assertResolveAlias } from './commonConfig/assertResolveAlias.js';
9
9
  import { getEnvVarObject } from '../shared/getEnvVarObject.js';
10
10
  import { isViteCliCall } from '../shared/isViteCliCall.js';
11
11
  import { isVikeCliOrApi } from '../../api/context.js';
12
+ import { getVikeConfig2 } from './importUserCode/v1-design/getVikeConfig.js';
13
+ import { assertViteRoot, getViteRoot, normalizeViteRoot } from '../../api/prepareViteApiCall.js';
12
14
  const pluginName = 'vike:commonConfig';
13
15
  function commonConfig(vikeVitePluginOptions) {
14
16
  return [
@@ -17,10 +19,18 @@ function commonConfig(vikeVitePluginOptions) {
17
19
  enforce: 'pre',
18
20
  config: {
19
21
  order: 'pre',
20
- handler(_config, env) {
22
+ async handler(configFromUser, env) {
23
+ const isDev = isDevCheck(env);
24
+ const operation = env.command === 'build' ? 'build' : env.isPreview ? 'preview' : 'dev';
25
+ const root = configFromUser.root ? normalizeViteRoot(configFromUser.root) : await getViteRoot(operation);
26
+ assert(root);
27
+ const vikeConfig = await getVikeConfig2(root, isDev, vikeVitePluginOptions);
21
28
  return {
22
- _isDev: isDevCheck(env),
23
- _vikeVitePluginOptions: vikeVitePluginOptions
29
+ _isDev: isDev,
30
+ _root: root,
31
+ _vikeVitePluginOptions: vikeVitePluginOptions,
32
+ vike: vikeConfig.vikeConfigNew,
33
+ vikeTmp: vikeConfig
24
34
  };
25
35
  }
26
36
  }
@@ -28,6 +38,7 @@ function commonConfig(vikeVitePluginOptions) {
28
38
  {
29
39
  name: pluginName,
30
40
  configResolved(config) {
41
+ assertViteRoot(config._root, config);
31
42
  assertSingleInstance(config);
32
43
  installRequireShim_setUserRootDir(config.root);
33
44
  }
@@ -9,6 +9,7 @@ export type { VikeConfigObject };
9
9
  export type { InterfaceValueFile };
10
10
  export type { InterfaceFile };
11
11
  export type { VikeConfigGlobal };
12
+ export type { VikeConfigNew };
12
13
  export type { VikeVitePluginOptions };
13
14
  import type { PageConfigGlobalBuildTime, PageConfigBuildTime } from '../../../../../shared/page-configs/PageConfig.js';
14
15
  import { type LocationId } from './getVikeConfig/filesystemRouting.js';
@@ -35,13 +36,14 @@ type InterfaceValueFile = InterfaceFileCommons & {
35
36
  configName: string;
36
37
  };
37
38
  type ConfigName = string;
39
+ type VikeConfigNew = {
40
+ global: ReturnType<typeof getPageConfigUserFriendlyNew>;
41
+ };
38
42
  type VikeConfigObject = {
39
43
  pageConfigs: PageConfigBuildTime[];
40
44
  pageConfigGlobal: PageConfigGlobalBuildTime;
41
45
  vikeConfigGlobal: VikeConfigGlobal;
42
- vikeConfigNew: {
43
- global: ReturnType<typeof getPageConfigUserFriendlyNew>;
44
- };
46
+ vikeConfigNew: VikeConfigNew;
45
47
  };
46
48
  declare const vikeConfigDependencies: Set<string>;
47
49
  declare function reloadVikeConfig(config: ResolvedConfig): void;
@@ -1 +1 @@
1
- export declare const PROJECT_VERSION: "0.4.218-commit-ed9b3d4";
1
+ export declare const PROJECT_VERSION: "0.4.218-commit-85af52a";
@@ -1,2 +1,2 @@
1
1
  // Automatically updated by @brillout/release-me
2
- export const PROJECT_VERSION = '0.4.218-commit-ed9b3d4';
2
+ export const PROJECT_VERSION = '0.4.218-commit-85af52a';
@@ -1,4 +1,4 @@
1
1
  export declare const projectInfo: {
2
2
  projectName: "Vike";
3
- projectVersion: "0.4.218-commit-ed9b3d4";
3
+ projectVersion: "0.4.218-commit-85af52a";
4
4
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "vike",
3
- "version": "0.4.218-commit-ed9b3d4",
3
+ "version": "0.4.218-commit-85af52a",
4
4
  "repository": "https://github.com/vikejs/vike",
5
5
  "exports": {
6
6
  "./server": {