vike 0.4.162-commit-8995471 → 0.4.162-commit-421de1c

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.
@@ -14,16 +14,18 @@ const assertResolveAlias_js_1 = require("./commonConfig/assertResolveAlias.js");
14
14
  // @ts-ignore Shimmed by dist-cjs-fixup.js for CJS build.
15
15
  const importMetaUrl = `file://${__filename}`;
16
16
  const require_ = (0, module_1.createRequire)(importMetaUrl);
17
+ const pluginName = 'vike:commonConfig-1';
17
18
  function commonConfig() {
18
19
  return [
19
20
  {
20
- name: 'vike-commonConfig-1',
21
+ name: pluginName,
21
22
  configResolved(config) {
23
+ assertSingleInstance(config);
22
24
  (0, require_shim_1.installRequireShim_setUserRootDir)(config.root);
23
25
  }
24
26
  },
25
27
  {
26
- name: 'vike-.commonConfig-2',
28
+ name: 'vike:commonConfig-2',
27
29
  enforce: 'post',
28
30
  configResolved: {
29
31
  order: 'post',
@@ -81,3 +83,7 @@ function assertEsm(userViteRoot) {
81
83
  dir = picocolors_1.default.dim(dir);
82
84
  (0, utils_js_1.assertWarning)(packageJson.type === 'module', `We recommend setting ${dir}package.json#type to "module", see https://vike.dev/CJS`, { onlyOnce: true });
83
85
  }
86
+ function assertSingleInstance(config) {
87
+ const numberOfInstances = config.plugins.filter((o) => o.name === pluginName).length;
88
+ (0, utils_js_1.assertUsage)(numberOfInstances === 1, `Vike's Vite plugin (${picocolors_1.default.cyan("import vike from 'vike/plugin'")}) is being added ${numberOfInstances} times to the list of Vite plugins. Make sure to add it only once instead.`);
89
+ }
@@ -474,7 +474,8 @@ function warnOverridenConfigValues(interfaceFileWinner, interfaceFilesOverriden,
474
474
  interfaceFilesOverriden.forEach((interfaceFileLoser) => {
475
475
  const loserFilePath = interfaceFileLoser.filePath.filePathToShowToUser;
476
476
  const winnerFilePath = interfaceFileWinner.filePath.filePathToShowToUser;
477
- (0, utils_js_1.assertWarning)(false, `Config ${configName} defined at ${loserFilePath} is always overwritten by ${configName} defined at ${winnerFilePath}, remove the superfluous ${configName} value defined at ${interfaceFileLoser}`, { onlyOnce: false });
477
+ const confName = picocolors_1.default.cyan(configName);
478
+ (0, utils_js_1.assertWarning)(false, `The value of the config ${confName} defined at ${loserFilePath} is always overwritten by the value defined at ${winnerFilePath}, remove the superfluous value defined at ${loserFilePath}`, { onlyOnce: true });
478
479
  });
479
480
  }
480
481
  function isInterfaceFileUserLand(interfaceFile) {
@@ -515,6 +516,7 @@ async function getConfigValueSource(configName, interfaceFile, configDef, userRo
515
516
  valueIsFilePath: true,
516
517
  configEnv,
517
518
  valueIsImportedAtRuntime: true,
519
+ valueIsDefinedByValueFile: false,
518
520
  definedAt
519
521
  };
520
522
  return configValueSource;
@@ -530,6 +532,7 @@ async function getConfigValueSource(configName, interfaceFile, configDef, userRo
530
532
  locationId,
531
533
  configEnv,
532
534
  valueIsImportedAtRuntime: true,
535
+ valueIsDefinedByValueFile: false,
533
536
  definedAt: import_
534
537
  };
535
538
  // Load fake import
@@ -554,6 +557,7 @@ async function getConfigValueSource(configName, interfaceFile, configDef, userRo
554
557
  value: configValue,
555
558
  configEnv,
556
559
  valueIsImportedAtRuntime: false,
560
+ valueIsDefinedByValueFile: false,
557
561
  definedAt: definedAtConfigFile
558
562
  };
559
563
  return configValueSource;
@@ -566,6 +570,7 @@ async function getConfigValueSource(configName, interfaceFile, configDef, userRo
566
570
  locationId,
567
571
  configEnv,
568
572
  valueIsImportedAtRuntime: !valueAlreadyLoaded,
573
+ valueIsDefinedByValueFile: true,
569
574
  definedAt: {
570
575
  ...interfaceFile.filePath,
571
576
  fileExportPathToShowToUser: configName === interfaceFile.configName
@@ -327,6 +327,9 @@ function normalizeUrl(pageContextInit, httpRequestId) {
327
327
  if (disableUrlNormalization)
328
328
  return null;
329
329
  const { urlOriginal } = pageContextInit;
330
+ const { isPageContextRequest } = (0, handlePageContextRequestUrl_js_1.handlePageContextRequestUrl)(urlOriginal);
331
+ if (isPageContextRequest)
332
+ return null;
330
333
  const urlNormalized = (0, utils_js_1.normalizeUrlPathname)(urlOriginal, trailingSlash, baseServer);
331
334
  if (!urlNormalized)
332
335
  return null;
@@ -1,7 +1,4 @@
1
1
  "use strict";
2
- var __importDefault = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
4
- };
5
2
  Object.defineProperty(exports, "__esModule", { value: true });
6
3
  exports.serializeConfigValueImported = exports.serializeConfigValue = void 0;
7
4
  // This file is never loaded on the client-side but we save it under the vike/shared/ directory in order to collocate it with:
@@ -10,7 +7,6 @@ exports.serializeConfigValueImported = exports.serializeConfigValue = void 0;
10
7
  // Both parsePageConfigs() parseConfigValuesImported() and are loaded on the client-side and server-side
11
8
  const assertIsNotProductionRuntime_js_1 = require("../../../utils/assertIsNotProductionRuntime.js");
12
9
  (0, assertIsNotProductionRuntime_js_1.assertIsNotProductionRuntime)();
13
- const path_1 = __importDefault(require("path"));
14
10
  const utils_js_1 = require("../../utils.js");
15
11
  const generateEagerImport_js_1 = require("../../../node/plugin/plugins/importUserCode/generateEagerImport.js");
16
12
  function serializeConfigValue(lines, configName, configValueSerialized) {
@@ -28,13 +24,10 @@ exports.serializeConfigValue = serializeConfigValue;
28
24
  function serializeConfigValueImported(configValueSource, configName, whitespace, varCounterContainer, importStatements) {
29
25
  (0, utils_js_1.assert)(!configValueSource.valueIsFilePath);
30
26
  (0, utils_js_1.assert)(whitespace.replaceAll(' ', '').length === 0);
31
- const { valueIsImportedAtRuntime, definedAt } = configValueSource;
27
+ const { valueIsImportedAtRuntime, valueIsDefinedByValueFile, definedAt } = configValueSource;
32
28
  (0, utils_js_1.assert)(valueIsImportedAtRuntime);
33
29
  const { filePathAbsoluteVite, fileExportName } = definedAt;
34
- (0, utils_js_1.assertPosixPath)(filePathAbsoluteVite);
35
- const fileName = path_1.default.posix.basename(filePathAbsoluteVite);
36
- const isValueFile = fileName.startsWith('+');
37
- if (isValueFile)
30
+ if (valueIsDefinedByValueFile)
38
31
  (0, utils_js_1.assert)(fileExportName === undefined);
39
32
  const { importName, importStatement } = (0, generateEagerImport_js_1.generateEagerImport)(filePathAbsoluteVite, varCounterContainer.varCounter++, fileExportName);
40
33
  importStatements.push(importStatement);
@@ -42,8 +35,8 @@ function serializeConfigValueImported(configValueSource, configName, whitespace,
42
35
  lines.push(` {`);
43
36
  lines.push(` configName: '${configName}',`);
44
37
  lines.push(` importPath: '${filePathAbsoluteVite}',`);
45
- lines.push(` isValueFile: ${JSON.stringify(isValueFile)},`);
46
- if (isValueFile) {
38
+ lines.push(` isValueFile: ${JSON.stringify(valueIsDefinedByValueFile)},`);
39
+ if (valueIsDefinedByValueFile) {
47
40
  lines.push(` exportValues: ${importName},`);
48
41
  }
49
42
  else {
@@ -2,7 +2,7 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.PROJECT_VERSION = exports.projectInfo = void 0;
4
4
  const assertSingleInstance_js_1 = require("./assertSingleInstance.js");
5
- const PROJECT_VERSION = '0.4.162-commit-8995471';
5
+ const PROJECT_VERSION = '0.4.162-commit-421de1c';
6
6
  exports.PROJECT_VERSION = PROJECT_VERSION;
7
7
  const projectInfo = {
8
8
  projectName: 'Vike',
@@ -1,5 +1,5 @@
1
1
  export { commonConfig };
2
- import { assert, assertWarning, findFile } from '../utils.js';
2
+ import { assert, assertUsage, assertWarning, findFile } from '../utils.js';
3
3
  import { assertRollupInput } from './buildConfig.js';
4
4
  import { installRequireShim_setUserRootDir } from '@brillout/require-shim';
5
5
  import pc from '@brillout/picocolors';
@@ -9,16 +9,18 @@ import { assertResolveAlias } from './commonConfig/assertResolveAlias.js';
9
9
  // @ts-ignore Shimmed by dist-cjs-fixup.js for CJS build.
10
10
  const importMetaUrl = import.meta.url;
11
11
  const require_ = createRequire(importMetaUrl);
12
+ const pluginName = 'vike:commonConfig-1';
12
13
  function commonConfig() {
13
14
  return [
14
15
  {
15
- name: 'vike-commonConfig-1',
16
+ name: pluginName,
16
17
  configResolved(config) {
18
+ assertSingleInstance(config);
17
19
  installRequireShim_setUserRootDir(config.root);
18
20
  }
19
21
  },
20
22
  {
21
- name: 'vike-.commonConfig-2',
23
+ name: 'vike:commonConfig-2',
22
24
  enforce: 'post',
23
25
  configResolved: {
24
26
  order: 'post',
@@ -75,3 +77,7 @@ function assertEsm(userViteRoot) {
75
77
  dir = pc.dim(dir);
76
78
  assertWarning(packageJson.type === 'module', `We recommend setting ${dir}package.json#type to "module", see https://vike.dev/CJS`, { onlyOnce: true });
77
79
  }
80
+ function assertSingleInstance(config) {
81
+ const numberOfInstances = config.plugins.filter((o) => o.name === pluginName).length;
82
+ assertUsage(numberOfInstances === 1, `Vike's Vite plugin (${pc.cyan("import vike from 'vike/plugin'")}) is being added ${numberOfInstances} times to the list of Vite plugins. Make sure to add it only once instead.`);
83
+ }
@@ -469,7 +469,8 @@ function warnOverridenConfigValues(interfaceFileWinner, interfaceFilesOverriden,
469
469
  interfaceFilesOverriden.forEach((interfaceFileLoser) => {
470
470
  const loserFilePath = interfaceFileLoser.filePath.filePathToShowToUser;
471
471
  const winnerFilePath = interfaceFileWinner.filePath.filePathToShowToUser;
472
- assertWarning(false, `Config ${configName} defined at ${loserFilePath} is always overwritten by ${configName} defined at ${winnerFilePath}, remove the superfluous ${configName} value defined at ${interfaceFileLoser}`, { onlyOnce: false });
472
+ const confName = pc.cyan(configName);
473
+ assertWarning(false, `The value of the config ${confName} defined at ${loserFilePath} is always overwritten by the value defined at ${winnerFilePath}, remove the superfluous value defined at ${loserFilePath}`, { onlyOnce: true });
473
474
  });
474
475
  }
475
476
  function isInterfaceFileUserLand(interfaceFile) {
@@ -510,6 +511,7 @@ async function getConfigValueSource(configName, interfaceFile, configDef, userRo
510
511
  valueIsFilePath: true,
511
512
  configEnv,
512
513
  valueIsImportedAtRuntime: true,
514
+ valueIsDefinedByValueFile: false,
513
515
  definedAt
514
516
  };
515
517
  return configValueSource;
@@ -525,6 +527,7 @@ async function getConfigValueSource(configName, interfaceFile, configDef, userRo
525
527
  locationId,
526
528
  configEnv,
527
529
  valueIsImportedAtRuntime: true,
530
+ valueIsDefinedByValueFile: false,
528
531
  definedAt: import_
529
532
  };
530
533
  // Load fake import
@@ -549,6 +552,7 @@ async function getConfigValueSource(configName, interfaceFile, configDef, userRo
549
552
  value: configValue,
550
553
  configEnv,
551
554
  valueIsImportedAtRuntime: false,
555
+ valueIsDefinedByValueFile: false,
552
556
  definedAt: definedAtConfigFile
553
557
  };
554
558
  return configValueSource;
@@ -561,6 +565,7 @@ async function getConfigValueSource(configName, interfaceFile, configDef, userRo
561
565
  locationId,
562
566
  configEnv,
563
567
  valueIsImportedAtRuntime: !valueAlreadyLoaded,
568
+ valueIsDefinedByValueFile: true,
564
569
  definedAt: {
565
570
  ...interfaceFile.filePath,
566
571
  fileExportPathToShowToUser: configName === interfaceFile.configName
@@ -321,6 +321,9 @@ function normalizeUrl(pageContextInit, httpRequestId) {
321
321
  if (disableUrlNormalization)
322
322
  return null;
323
323
  const { urlOriginal } = pageContextInit;
324
+ const { isPageContextRequest } = handlePageContextRequestUrl(urlOriginal);
325
+ if (isPageContextRequest)
326
+ return null;
324
327
  const urlNormalized = normalizeUrlPathname(urlOriginal, trailingSlash, baseServer);
325
328
  if (!urlNormalized)
326
329
  return null;
@@ -75,6 +75,7 @@ type ConfigValueSource = {
75
75
  valueIsImportedAtRuntime: boolean;
76
76
  /** Whether the config value is a file path, for example config.client */
77
77
  valueIsFilePath?: true;
78
+ valueIsDefinedByValueFile: boolean;
78
79
  };
79
80
  type DefinedAtFileFullInfo = DefinedAtFile & FilePath & {
80
81
  fileExportName?: string;
@@ -6,8 +6,7 @@ export { serializeConfigValueImported };
6
6
  // Both parsePageConfigs() parseConfigValuesImported() and are loaded on the client-side and server-side
7
7
  import { assertIsNotProductionRuntime } from '../../../utils/assertIsNotProductionRuntime.js';
8
8
  assertIsNotProductionRuntime();
9
- import path from 'path';
10
- import { assert, assertPosixPath } from '../../utils.js';
9
+ import { assert } from '../../utils.js';
11
10
  import { generateEagerImport } from '../../../node/plugin/plugins/importUserCode/generateEagerImport.js';
12
11
  function serializeConfigValue(lines, configName, configValueSerialized) {
13
12
  let whitespace = ' ';
@@ -23,13 +22,10 @@ function serializeConfigValue(lines, configName, configValueSerialized) {
23
22
  function serializeConfigValueImported(configValueSource, configName, whitespace, varCounterContainer, importStatements) {
24
23
  assert(!configValueSource.valueIsFilePath);
25
24
  assert(whitespace.replaceAll(' ', '').length === 0);
26
- const { valueIsImportedAtRuntime, definedAt } = configValueSource;
25
+ const { valueIsImportedAtRuntime, valueIsDefinedByValueFile, definedAt } = configValueSource;
27
26
  assert(valueIsImportedAtRuntime);
28
27
  const { filePathAbsoluteVite, fileExportName } = definedAt;
29
- assertPosixPath(filePathAbsoluteVite);
30
- const fileName = path.posix.basename(filePathAbsoluteVite);
31
- const isValueFile = fileName.startsWith('+');
32
- if (isValueFile)
28
+ if (valueIsDefinedByValueFile)
33
29
  assert(fileExportName === undefined);
34
30
  const { importName, importStatement } = generateEagerImport(filePathAbsoluteVite, varCounterContainer.varCounter++, fileExportName);
35
31
  importStatements.push(importStatement);
@@ -37,8 +33,8 @@ function serializeConfigValueImported(configValueSource, configName, whitespace,
37
33
  lines.push(` {`);
38
34
  lines.push(` configName: '${configName}',`);
39
35
  lines.push(` importPath: '${filePathAbsoluteVite}',`);
40
- lines.push(` isValueFile: ${JSON.stringify(isValueFile)},`);
41
- if (isValueFile) {
36
+ lines.push(` isValueFile: ${JSON.stringify(valueIsDefinedByValueFile)},`);
37
+ if (valueIsDefinedByValueFile) {
42
38
  lines.push(` exportValues: ${importName},`);
43
39
  }
44
40
  else {
@@ -1,7 +1,7 @@
1
1
  export { projectInfo };
2
2
  export { PROJECT_VERSION };
3
- declare const PROJECT_VERSION: "0.4.162-commit-8995471";
3
+ declare const PROJECT_VERSION: "0.4.162-commit-421de1c";
4
4
  declare const projectInfo: {
5
5
  projectName: "Vike";
6
- projectVersion: "0.4.162-commit-8995471";
6
+ projectVersion: "0.4.162-commit-421de1c";
7
7
  };
@@ -1,7 +1,7 @@
1
1
  export { projectInfo };
2
2
  export { PROJECT_VERSION };
3
3
  import { onProjectInfo } from './assertSingleInstance.js';
4
- const PROJECT_VERSION = '0.4.162-commit-8995471';
4
+ const PROJECT_VERSION = '0.4.162-commit-421de1c';
5
5
  const projectInfo = {
6
6
  projectName: 'Vike',
7
7
  projectVersion: PROJECT_VERSION
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "vike",
3
- "version": "0.4.162-commit-8995471",
3
+ "version": "0.4.162-commit-421de1c",
4
4
  "scripts": {
5
5
  "dev": "tsc --watch",
6
6
  "build": "rimraf dist/ && pnpm run build:esm && pnpm run build:cjs",