vike 0.4.144-commit-e40e9b1 → 0.4.144-commit-d687042

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.
Files changed (24) hide show
  1. package/dist/cjs/node/plugin/plugins/devConfig/determineOptimizeDeps.js +4 -4
  2. package/dist/cjs/node/plugin/plugins/envVars.js +22 -17
  3. package/dist/cjs/node/plugin/plugins/importUserCode/index.js +2 -2
  4. package/dist/cjs/node/plugin/plugins/importUserCode/v1-design/getFilePathToShowToUser.js +1 -1
  5. package/dist/cjs/node/plugin/plugins/importUserCode/v1-design/getVikeConfig.js +47 -47
  6. package/dist/cjs/node/plugin/plugins/importUserCode/v1-design/transpileAndExecuteFile.js +12 -12
  7. package/dist/cjs/utils/getFilePathAbsolute.js +11 -11
  8. package/dist/cjs/utils/parseUrl.js +1 -1
  9. package/dist/cjs/utils/projectInfo.js +1 -1
  10. package/dist/esm/node/plugin/plugins/buildConfig.js +1 -1
  11. package/dist/esm/node/plugin/plugins/devConfig/determineOptimizeDeps.js +4 -4
  12. package/dist/esm/node/plugin/plugins/envVars.js +23 -18
  13. package/dist/esm/node/plugin/plugins/importUserCode/index.js +2 -2
  14. package/dist/esm/node/plugin/plugins/importUserCode/v1-design/getFilePathToShowToUser.d.ts +1 -1
  15. package/dist/esm/node/plugin/plugins/importUserCode/v1-design/getFilePathToShowToUser.js +1 -1
  16. package/dist/esm/node/plugin/plugins/importUserCode/v1-design/getVikeConfig.js +47 -47
  17. package/dist/esm/node/plugin/plugins/importUserCode/v1-design/transpileAndExecuteFile.js +12 -12
  18. package/dist/esm/shared/page-configs/PageConfig.d.ts +2 -2
  19. package/dist/esm/utils/getFilePathAbsolute.d.ts +1 -1
  20. package/dist/esm/utils/getFilePathAbsolute.js +11 -11
  21. package/dist/esm/utils/parseUrl.js +1 -1
  22. package/dist/esm/utils/projectInfo.d.ts +1 -1
  23. package/dist/esm/utils/projectInfo.js +1 -1
  24. package/package.json +1 -2
@@ -41,13 +41,13 @@ async function getPageDeps(config, pageConfigs, isDev) {
41
41
  if (configEnv !== 'client-only' && configEnv !== 'server-and-client')
42
42
  return;
43
43
  if (definedAtInfo.filePathRelativeToUserRootDir !== null) {
44
- const { filePathAbsolute } = definedAtInfo;
45
- (0, utils_js_1.assert)(filePathAbsolute);
44
+ const { filePathAbsoluteFilesystem } = definedAtInfo;
45
+ (0, utils_js_1.assert)(filePathAbsoluteFilesystem);
46
46
  // Surprisingly Vite expects entries to be absolute paths
47
- entries.push(filePathAbsolute);
47
+ entries.push(filePathAbsoluteFilesystem);
48
48
  }
49
49
  else {
50
- // Adding definedAtInfo.filePathAbsolute doesn't work for npm packages, I guess because of Vite's config.server.fs.allow
50
+ // Adding definedAtInfo.filePathAbsoluteFilesystem doesn't work for npm packages, I guess because of Vite's config.server.fs.allow
51
51
  const { importPathAbsolute } = definedAtInfo;
52
52
  (0, utils_js_1.assert)(importPathAbsolute);
53
53
  // We need to differentiate between npm package imports and path aliases.
@@ -37,25 +37,30 @@ function envVarsPlugin() {
37
37
  })
38
38
  .forEach(([key, val]) => {
39
39
  const varName = `import.meta.env.${key}`;
40
- const publicPrefix = 'PUBLIC_ENV__';
41
- const keyPublic = `${publicPrefix}${key}`;
42
- const isPrivate = !key.startsWith(publicPrefix);
43
- if (isPrivate && isClientSide) {
44
- if (!code.includes(varName))
45
- return;
46
- const filePathToShowToUser = (0, utils_js_1.getFilePathRelativeToUserRootDir)(id, config.root);
47
- const errMsgAddendum = isBuild ? '' : ' (vike will prevent your app from building for production)';
48
- const errMsg = `${varName} used in ${filePathToShowToUser} and therefore included in client-side bundle which can be be a security leak${errMsgAddendum}, remove ${varName} or rename ${key} to ${keyPublic}, see https://vike.dev/env`;
49
- if (isBuild) {
50
- (0, utils_js_1.assertUsage)(false, errMsg);
51
- }
52
- else {
53
- // Only a warning for faster development DX (e.g. when use toggles `ssr: boolean` or `onBeforeRenderIsomorph: boolean`)
54
- (0, utils_js_1.assertWarning)(false, errMsg, { onlyOnce: true });
40
+ // Security check
41
+ {
42
+ const publicPrefix = 'PUBLIC_ENV__';
43
+ const isPrivate = !key.startsWith(publicPrefix);
44
+ if (isPrivate && isClientSide) {
45
+ if (!code.includes(varName))
46
+ return;
47
+ const filePathToShowToUser = (0, utils_js_1.getFilePathRelativeToUserRootDir)(id, config.root);
48
+ const errMsgAddendum = isBuild ? '' : ' (Vike will prevent your app from building for production)';
49
+ const keyPublic = `${publicPrefix}${key}`;
50
+ const errMsg = `${varName} is used in client-side file ${filePathToShowToUser} which means that the environment variable ${key} will be included in client-side bundles and, therefore, ${key} will be publicly exposed which can be a security leak${errMsgAddendum}. Use ${varName} only in server-side files, or rename ${key} to ${keyPublic}, see https://vike.dev/env`;
51
+ if (isBuild) {
52
+ (0, utils_js_1.assertUsage)(false, errMsg);
53
+ }
54
+ else {
55
+ // Only a warning for faster development DX (e.g. when user toggles `ssr: boolean` or `onBeforeRenderIsomorph: boolean`)
56
+ (0, utils_js_1.assertWarning)(false, errMsg, { onlyOnce: true });
57
+ }
55
58
  }
59
+ // Double check
60
+ (0, utils_js_1.assert)(!(isPrivate && isClientSide) || !isBuild);
56
61
  }
57
- (0, utils_js_1.assert)(!(isPrivate && isClientSide) || !isBuild);
58
- code = code.replaceAll(varName, JSON.stringify(val));
62
+ // Apply
63
+ code = code.replace(new RegExp((0, utils_js_1.escapeRegex)(varName) + '\b', 'g'), JSON.stringify(val));
59
64
  });
60
65
  // No need for low-resolution source map since line numbers didn't change. (Does Vite do high-resolution column numbers source mapping?)
61
66
  return code;
@@ -117,8 +117,8 @@ function handleHotUpdate(ctx, config, configVike) {
117
117
  return virtualModules;
118
118
  }
119
119
  }
120
- function isVikeConfigModule(filePathAbsolute) {
121
- return getVikeConfig_js_1.vikeConfigDependencies.has(filePathAbsolute);
120
+ function isVikeConfigModule(filePathAbsoluteFilesystem) {
121
+ return getVikeConfig_js_1.vikeConfigDependencies.has(filePathAbsoluteFilesystem);
122
122
  }
123
123
  function reloadConfig(filePath, config, configVike, op) {
124
124
  {
@@ -9,7 +9,7 @@ if (f.filePathRelativeToUserRootDir === null) {
9
9
  }
10
10
  //*/
11
11
  function getFilePathToShowToUser(filePath) {
12
- const filePathToShowToUser = filePath.filePathRelativeToUserRootDir ?? filePath.filePathAbsolute;
12
+ const filePathToShowToUser = filePath.filePathRelativeToUserRootDir ?? filePath.filePathAbsoluteFilesystem;
13
13
  (0, utils_js_1.assert)(filePathToShowToUser);
14
14
  return filePathToShowToUser;
15
15
  }
@@ -86,9 +86,9 @@ async function loadInterfaceFiles(userRootDir, outDirRoot, isDev, extensions) {
86
86
  });
87
87
  let interfaceFilesByLocationId = {};
88
88
  // Config files
89
- await Promise.all(configFiles.map(async ({ filePathAbsolute, filePathRelativeToUserRootDir }) => {
89
+ await Promise.all(configFiles.map(async ({ filePathAbsoluteFilesystem, filePathRelativeToUserRootDir }) => {
90
90
  const configFilePath = {
91
- filePathAbsolute: filePathAbsolute,
91
+ filePathAbsoluteFilesystem: filePathAbsoluteFilesystem,
92
92
  filePathRelativeToUserRootDir: filePathRelativeToUserRootDir,
93
93
  importPathAbsolute: null
94
94
  };
@@ -103,13 +103,13 @@ async function loadInterfaceFiles(userRootDir, outDirRoot, isDev, extensions) {
103
103
  });
104
104
  }));
105
105
  // Value files
106
- await Promise.all(valueFiles.map(async ({ filePathAbsolute, filePathRelativeToUserRootDir }) => {
106
+ await Promise.all(valueFiles.map(async ({ filePathAbsoluteFilesystem, filePathRelativeToUserRootDir }) => {
107
107
  const configName = getConfigName(filePathRelativeToUserRootDir);
108
108
  (0, utils_js_1.assert)(configName);
109
109
  const interfaceFile = {
110
110
  filePath: {
111
111
  filePathRelativeToUserRootDir,
112
- filePathAbsolute,
112
+ filePathAbsoluteFilesystem,
113
113
  importPathAbsolute: null
114
114
  },
115
115
  configMap: {
@@ -551,20 +551,20 @@ function resolveImport(configValue, importerFilePath, userRootDir, configEnv, co
551
551
  if (!importData)
552
552
  return null;
553
553
  const { importPath, exportName } = importData;
554
- const filePathAbsolute = resolveImportPath(importData, importerFilePath);
555
- assertFileEnv(filePathAbsolute ?? importPath, configEnv, configName);
554
+ const filePathAbsoluteFilesystem = resolveImportPath(importData, importerFilePath);
555
+ assertFileEnv(filePathAbsoluteFilesystem ?? importPath, configEnv, configName);
556
556
  const fileExportPath = exportName === 'default' || exportName === configName ? [] : [exportName];
557
557
  if (importPath.startsWith('.')) {
558
558
  // We need to resolve relative paths into absolute paths. Because the import paths are included in virtual files:
559
559
  // ```
560
560
  // [vite] Internal server error: Failed to resolve import "./onPageTransitionHooks" from "virtual:vike:pageConfigValuesAll:client:/pages/index". Does the file exist?
561
561
  // ```
562
- assertImportPath(filePathAbsolute, importData, importerFilePath);
563
- const filePathRelativeToUserRootDir = resolveImportPath_relativeToUserRootDir(filePathAbsolute, importData, importerFilePath, userRootDir);
562
+ assertImportPath(filePathAbsoluteFilesystem, importData, importerFilePath);
563
+ const filePathRelativeToUserRootDir = resolveImportPath_relativeToUserRootDir(filePathAbsoluteFilesystem, importData, importerFilePath, userRootDir);
564
564
  return {
565
565
  exportName,
566
566
  fileExportPath,
567
- filePathAbsolute,
567
+ filePathAbsoluteFilesystem,
568
568
  filePathRelativeToUserRootDir,
569
569
  importPathAbsolute: null
570
570
  };
@@ -576,26 +576,26 @@ function resolveImport(configValue, importerFilePath, userRootDir, configEnv, co
576
576
  return {
577
577
  exportName,
578
578
  fileExportPath,
579
- filePathAbsolute,
579
+ filePathAbsoluteFilesystem,
580
580
  filePathRelativeToUserRootDir: null,
581
581
  importPathAbsolute: importPath
582
582
  };
583
583
  }
584
584
  }
585
- function resolveImportPath_relativeToUserRootDir(filePathAbsolute, importData, configFilePath, userRootDir) {
585
+ function resolveImportPath_relativeToUserRootDir(filePathAbsoluteFilesystem, importData, configFilePath, userRootDir) {
586
586
  (0, utils_js_1.assertPosixPath)(userRootDir);
587
587
  let filePathRelativeToUserRootDir;
588
- if (filePathAbsolute.startsWith(userRootDir)) {
589
- filePathRelativeToUserRootDir = getVitePathFromAbsolutePath(filePathAbsolute, userRootDir);
588
+ if (filePathAbsoluteFilesystem.startsWith(userRootDir)) {
589
+ filePathRelativeToUserRootDir = getVitePathFromAbsolutePath(filePathAbsoluteFilesystem, userRootDir);
590
590
  }
591
591
  else {
592
592
  (0, utils_js_1.assertUsage)(false, `${(0, getFilePathToShowToUser_js_1.getFilePathToShowToUser)(configFilePath)} imports from a relative path ${picocolors_1.default.cyan(importData.importPath)} outside of ${userRootDir} which is forbidden: import from a relative path inside ${userRootDir}, or import from a dependency's package.json#exports entry instead`);
593
593
  // None of the following works. Seems to be a Vite bug?
594
594
  // /*
595
- // assert(filePathAbsolute.startsWith('/'))
596
- // filePath = `/@fs${filePathAbsolute}`
595
+ // assert(filePathAbsoluteFilesystem.startsWith('/'))
596
+ // filePath = `/@fs${filePathAbsoluteFilesystem}`
597
597
  // /*/
598
- // filePathRelativeToUserRootDir = path.posix.relative(userRootDir, filePathAbsolute)
598
+ // filePathRelativeToUserRootDir = path.posix.relative(userRootDir, filePathAbsoluteFilesystem)
599
599
  // assert(filePathRelativeToUserRootDir.startsWith('../'))
600
600
  // filePathRelativeToUserRootDir = '/' + filePathRelativeToUserRootDir
601
601
  // //*/
@@ -604,11 +604,11 @@ function resolveImportPath_relativeToUserRootDir(filePathAbsolute, importData, c
604
604
  (0, utils_js_1.assert)(filePathRelativeToUserRootDir.startsWith('/'));
605
605
  return filePathRelativeToUserRootDir;
606
606
  }
607
- function getVitePathFromAbsolutePath(filePathAbsolute, root) {
608
- (0, utils_js_1.assertPosixPath)(filePathAbsolute);
607
+ function getVitePathFromAbsolutePath(filePathAbsoluteFilesystem, root) {
608
+ (0, utils_js_1.assertPosixPath)(filePathAbsoluteFilesystem);
609
609
  (0, utils_js_1.assertPosixPath)(root);
610
- (0, utils_js_1.assert)(filePathAbsolute.startsWith(root));
611
- let vitePath = path_1.default.posix.relative(root, filePathAbsolute);
610
+ (0, utils_js_1.assert)(filePathAbsoluteFilesystem.startsWith(root));
611
+ let vitePath = path_1.default.posix.relative(root, filePathAbsoluteFilesystem);
612
612
  (0, utils_js_1.assert)(!vitePath.startsWith('/') && !vitePath.startsWith('.'));
613
613
  vitePath = '/' + vitePath;
614
614
  return vitePath;
@@ -761,8 +761,8 @@ async function findPlusFiles(userRootDir, ignoreDirs, isDev, extensions) {
761
761
  const plusFiles = result.map((p) => {
762
762
  p = (0, utils_js_1.toPosixPath)(p);
763
763
  const filePathRelativeToUserRootDir = path_1.default.posix.join('/', p);
764
- const filePathAbsolute = path_1.default.posix.join(userRootDir, p);
765
- return { filePathRelativeToUserRootDir, filePathAbsolute };
764
+ const filePathAbsoluteFilesystem = path_1.default.posix.join(userRootDir, p);
765
+ return { filePathRelativeToUserRootDir, filePathAbsoluteFilesystem };
766
766
  });
767
767
  extensions.forEach((extension) => {
768
768
  extension.pageConfigsDistFiles?.forEach((pageConfigDistFile) => {
@@ -774,7 +774,7 @@ async function findPlusFiles(userRootDir, ignoreDirs, isDev, extensions) {
774
774
  const { importPath, filePath } = pageConfigDistFile;
775
775
  plusFiles.push({
776
776
  filePathRelativeToUserRootDir: importPath,
777
- filePathAbsolute: filePath
777
+ filePathAbsoluteFilesystem: filePath
778
778
  });
779
779
  });
780
780
  });
@@ -804,12 +804,12 @@ function assertNoUnexpectedPlusSign(filePath, fileName) {
804
804
  (0, utils_js_1.assertUsage)(!fileName.slice(1).includes('+'), `Character '+' is only allowed at the beginning of filenames: make sure ${filePath} doesn't contain any '+' in its filename other than its first letter`);
805
805
  }
806
806
  async function loadConfigFile(configFilePath, userRootDir, visited) {
807
- const { filePathAbsolute } = configFilePath;
808
- assertNoInfiniteLoop(visited, filePathAbsolute);
807
+ const { filePathAbsoluteFilesystem } = configFilePath;
808
+ assertNoInfiniteLoop(visited, filePathAbsoluteFilesystem);
809
809
  const { fileExports } = await (0, transpileAndExecuteFile_js_1.transpileAndExecuteFile)(configFilePath, false, userRootDir);
810
810
  const { extendsConfigs, extendsFilePaths } = await loadExtendsConfigs(fileExports, configFilePath, userRootDir, [
811
811
  ...visited,
812
- filePathAbsolute
812
+ filePathAbsoluteFilesystem
813
813
  ]);
814
814
  const configFile = {
815
815
  fileExports,
@@ -818,13 +818,13 @@ async function loadConfigFile(configFilePath, userRootDir, visited) {
818
818
  };
819
819
  return { configFile, extendsConfigs };
820
820
  }
821
- function assertNoInfiniteLoop(visited, filePathAbsolute) {
822
- const idx = visited.indexOf(filePathAbsolute);
821
+ function assertNoInfiniteLoop(visited, filePathAbsoluteFilesystem) {
822
+ const idx = visited.indexOf(filePathAbsoluteFilesystem);
823
823
  if (idx === -1)
824
824
  return;
825
825
  const loop = visited.slice(idx);
826
- (0, utils_js_1.assert)(loop[0] === filePathAbsolute);
827
- (0, utils_js_1.assertUsage)(idx === -1, `Infinite extends loop ${[...loop, filePathAbsolute].join('>')}`);
826
+ (0, utils_js_1.assert)(loop[0] === filePathAbsoluteFilesystem);
827
+ (0, utils_js_1.assertUsage)(idx === -1, `Infinite extends loop ${[...loop, filePathAbsoluteFilesystem].join('>')}`);
828
828
  }
829
829
  async function loadExtendsConfigs(configFileExports, configFilePath, userRootDir, visited) {
830
830
  const extendsImportData = getExtendsImportData(configFileExports, configFilePath);
@@ -833,14 +833,14 @@ async function loadExtendsConfigs(configFileExports, configFilePath, userRootDir
833
833
  const { importPath: importPath } = importData;
834
834
  // TODO
835
835
  // - validate extends configs
836
- const filePathAbsolute = resolveImportPath(importData, configFilePath);
837
- assertImportPath(filePathAbsolute, importData, configFilePath);
838
- assertExtendsImportPath(importPath, filePathAbsolute, configFilePath);
836
+ const filePathAbsoluteFilesystem = resolveImportPath(importData, configFilePath);
837
+ assertImportPath(filePathAbsoluteFilesystem, importData, configFilePath);
838
+ assertExtendsImportPath(importPath, filePathAbsoluteFilesystem, configFilePath);
839
839
  // - filePathRelativeToUserRootDir has no functionality beyond nicer error messages for user
840
- // - Using importPath would be visually nicer but it's ambigous => we rather pick filePathAbsolute for added clarity
841
- const filePathRelativeToUserRootDir = determineFilePathRelativeToUserDir(filePathAbsolute, userRootDir);
840
+ // - Using importPath would be visually nicer but it's ambigous => we rather pick filePathAbsoluteFilesystem for added clarity
841
+ const filePathRelativeToUserRootDir = determineFilePathRelativeToUserDir(filePathAbsoluteFilesystem, userRootDir);
842
842
  extendsConfigFiles.push({
843
- filePathAbsolute,
843
+ filePathAbsoluteFilesystem,
844
844
  // TODO: fix type cast
845
845
  filePathRelativeToUserRootDir: filePathRelativeToUserRootDir,
846
846
  importPathAbsolute: importPath
@@ -852,16 +852,16 @@ async function loadExtendsConfigs(configFileExports, configFilePath, userRootDir
852
852
  extendsConfigs.push(result.configFile);
853
853
  extendsConfigs.push(...result.extendsConfigs);
854
854
  }));
855
- const extendsFilePaths = extendsConfigFiles.map((f) => f.filePathAbsolute);
855
+ const extendsFilePaths = extendsConfigFiles.map((f) => f.filePathAbsoluteFilesystem);
856
856
  return { extendsConfigs, extendsFilePaths };
857
857
  }
858
- function determineFilePathRelativeToUserDir(filePathAbsolute, userRootDir) {
859
- (0, utils_js_1.assertPosixPath)(filePathAbsolute);
858
+ function determineFilePathRelativeToUserDir(filePathAbsoluteFilesystem, userRootDir) {
859
+ (0, utils_js_1.assertPosixPath)(filePathAbsoluteFilesystem);
860
860
  (0, utils_js_1.assertPosixPath)(userRootDir);
861
- if (!filePathAbsolute.startsWith(userRootDir)) {
861
+ if (!filePathAbsoluteFilesystem.startsWith(userRootDir)) {
862
862
  return null;
863
863
  }
864
- let filePathRelativeToUserRootDir = filePathAbsolute.slice(userRootDir.length);
864
+ let filePathRelativeToUserRootDir = filePathAbsoluteFilesystem.slice(userRootDir.length);
865
865
  if (!filePathRelativeToUserRootDir.startsWith('/'))
866
866
  filePathRelativeToUserRootDir = '/' + filePathRelativeToUserRootDir;
867
867
  return filePathRelativeToUserRootDir;
@@ -1021,17 +1021,17 @@ function determineIsErrorPage(routeFilesystem) {
1021
1021
  return routeFilesystem.split('/').includes('_error');
1022
1022
  }
1023
1023
  function resolveImportPath(importData, importerFilePath) {
1024
- const importerFilePathAbsolute = importerFilePath.filePathAbsolute;
1024
+ const importerFilePathAbsolute = importerFilePath.filePathAbsoluteFilesystem;
1025
1025
  (0, utils_js_1.assertPosixPath)(importerFilePathAbsolute);
1026
1026
  const cwd = path_1.default.posix.dirname(importerFilePathAbsolute);
1027
- // filePathAbsolute is expected to be null when importData.importPath is a Vite path alias
1028
- const filePathAbsolute = (0, utils_js_1.requireResolve)(importData.importPath, cwd);
1029
- return filePathAbsolute;
1027
+ // filePathAbsoluteFilesystem is expected to be null when importData.importPath is a Vite path alias
1028
+ const filePathAbsoluteFilesystem = (0, utils_js_1.requireResolve)(importData.importPath, cwd);
1029
+ return filePathAbsoluteFilesystem;
1030
1030
  }
1031
- function assertImportPath(filePathAbsolute, importData, importerFilePath) {
1031
+ function assertImportPath(filePathAbsoluteFilesystem, importData, importerFilePath) {
1032
1032
  const { importPath: importPath, importStringWasGenerated, importString } = importData;
1033
1033
  const filePathToShowToUser = (0, getFilePathToShowToUser_js_1.getFilePathToShowToUser)(importerFilePath);
1034
- if (!filePathAbsolute) {
1034
+ if (!filePathAbsoluteFilesystem) {
1035
1035
  const importPathString = picocolors_1.default.cyan(`'${importPath}'`);
1036
1036
  const errIntro = importStringWasGenerated
1037
1037
  ? `The import path ${importPathString} in ${filePathToShowToUser}`
@@ -23,9 +23,9 @@ async function transpileAndExecuteFile(filePath, isValueFile, userRootDir) {
23
23
  }
24
24
  exports.transpileAndExecuteFile = transpileAndExecuteFile;
25
25
  async function transpileFile(filePath, isValueFile, userRootDir) {
26
- const { filePathAbsolute } = filePath;
27
- (0, utils_js_1.assertPosixPath)(filePathAbsolute);
28
- getVikeConfig_js_1.vikeConfigDependencies.add(filePathAbsolute);
26
+ const { filePathAbsoluteFilesystem } = filePath;
27
+ (0, utils_js_1.assertPosixPath)(filePathAbsoluteFilesystem);
28
+ getVikeConfig_js_1.vikeConfigDependencies.add(filePathAbsoluteFilesystem);
29
29
  let code = await transpileWithEsbuild(filePath, isValueFile, userRootDir);
30
30
  let fileImports = null;
31
31
  {
@@ -39,9 +39,9 @@ async function transpileFile(filePath, isValueFile, userRootDir) {
39
39
  }
40
40
  function transpileImports(codeOriginal, filePath, isValueFile) {
41
41
  // Do we need to remove the imports?
42
- const { filePathAbsolute } = filePath;
43
- (0, utils_js_1.assertPosixPath)(filePathAbsolute);
44
- const isHeader = isHeaderFile(filePathAbsolute);
42
+ const { filePathAbsoluteFilesystem } = filePath;
43
+ (0, utils_js_1.assertPosixPath)(filePathAbsoluteFilesystem);
44
+ const isHeader = isHeaderFile(filePathAbsoluteFilesystem);
45
45
  const isPageConfigFile = !isValueFile;
46
46
  if (!isHeader && !isPageConfigFile) {
47
47
  return null;
@@ -63,7 +63,7 @@ function transpileImports(codeOriginal, filePath, isValueFile) {
63
63
  return { code, fileImports };
64
64
  }
65
65
  async function transpileWithEsbuild(filePath, bundle, userRootDir) {
66
- const entryFilePath = filePath.filePathAbsolute;
66
+ const entryFilePath = filePath.filePathAbsoluteFilesystem;
67
67
  const entryFileDir = path_1.default.posix.dirname(entryFilePath);
68
68
  const options = {
69
69
  platform: 'node',
@@ -128,8 +128,8 @@ async function transpileWithEsbuild(filePath, bundle, userRootDir) {
128
128
  Object.keys(result.metafile.inputs).forEach((filePathRelative) => {
129
129
  filePathRelative = (0, utils_js_1.toPosixPath)(filePathRelative);
130
130
  (0, utils_js_1.assertPosixPath)(userRootDir);
131
- const filePathAbsolute = path_1.default.posix.join(userRootDir, filePathRelative);
132
- getVikeConfig_js_1.vikeConfigDependencies.add(filePathAbsolute);
131
+ const filePathAbsoluteFilesystem = path_1.default.posix.join(userRootDir, filePathRelative);
132
+ getVikeConfig_js_1.vikeConfigDependencies.add(filePathAbsoluteFilesystem);
133
133
  });
134
134
  }
135
135
  const code = result.outputFiles[0].text;
@@ -137,10 +137,10 @@ async function transpileWithEsbuild(filePath, bundle, userRootDir) {
137
137
  return code;
138
138
  }
139
139
  async function executeFile(filePath, code, fileImports, isValueFile) {
140
- const { filePathAbsolute, filePathRelativeToUserRootDir } = filePath;
140
+ const { filePathAbsoluteFilesystem, filePathRelativeToUserRootDir } = filePath;
141
141
  // Alternative to using a temporary file: https://github.com/vitejs/vite/pull/13269
142
142
  // - But seems to break source maps, so I don't think it's worth it
143
- const filePathTmp = getFilePathTmp(filePathAbsolute);
143
+ const filePathTmp = getFilePathTmp(filePathAbsoluteFilesystem);
144
144
  fs_1.default.writeFileSync(filePathTmp, code);
145
145
  const clean = () => fs_1.default.unlinkSync(filePathTmp);
146
146
  let fileExports = {};
@@ -163,7 +163,7 @@ async function executeFile(filePath, code, fileImports, isValueFile) {
163
163
  fileExports = { ...fileExports };
164
164
  if (fileImports && !isValueFile) {
165
165
  (0, utils_js_1.assert)(filePathRelativeToUserRootDir !== undefined);
166
- const filePathToShowToUser = filePathRelativeToUserRootDir ?? filePathAbsolute;
166
+ const filePathToShowToUser = filePathRelativeToUserRootDir ?? filePathAbsoluteFilesystem;
167
167
  assertImportsAreReExported(fileImports, fileExports, filePathToShowToUser);
168
168
  }
169
169
  return { fileExports };
@@ -34,27 +34,27 @@ function getFilePathAbsolute(filePath, config) {
34
34
  filePathUnresolved = path_1.default.posix.join(root, filePath);
35
35
  (0, assertPathIsFilesystemAbsolute_js_1.assertPathIsFilesystemAbsolute)(filePathUnresolved);
36
36
  }
37
- let filePathAbsolute;
37
+ let filePathAbsoluteFilesystem;
38
38
  try {
39
- filePathAbsolute = require_.resolve(filePathUnresolved, { paths: [config.root] });
39
+ filePathAbsoluteFilesystem = require_.resolve(filePathUnresolved, { paths: [config.root] });
40
40
  }
41
41
  catch (err) {
42
42
  console.error(err);
43
43
  (0, assert_js_1.assert)(false);
44
44
  }
45
- filePathAbsolute = (0, filesystemPathHandling_js_1.toPosixPath)(filePathAbsolute);
46
- (0, assertPathIsFilesystemAbsolute_js_1.assertPathIsFilesystemAbsolute)(filePathAbsolute);
47
- return filePathAbsolute;
45
+ filePathAbsoluteFilesystem = (0, filesystemPathHandling_js_1.toPosixPath)(filePathAbsoluteFilesystem);
46
+ (0, assertPathIsFilesystemAbsolute_js_1.assertPathIsFilesystemAbsolute)(filePathAbsoluteFilesystem);
47
+ return filePathAbsoluteFilesystem;
48
48
  }
49
49
  exports.getFilePathAbsolute = getFilePathAbsolute;
50
- function getFilePathRelativeToUserRootDir(filePathAbsolute, userRootDir, alwaysRelative = false) {
51
- (0, filesystemPathHandling_js_1.assertPosixPath)(filePathAbsolute);
50
+ function getFilePathRelativeToUserRootDir(filePathAbsoluteFilesystem, userRootDir, alwaysRelative = false) {
51
+ (0, filesystemPathHandling_js_1.assertPosixPath)(filePathAbsoluteFilesystem);
52
52
  (0, filesystemPathHandling_js_1.assertPosixPath)(userRootDir);
53
- let filePathRelativeToUserRootDir = path_1.default.posix.relative(userRootDir, filePathAbsolute);
54
- if (filePathAbsolute.startsWith(userRootDir)) {
53
+ let filePathRelativeToUserRootDir = path_1.default.posix.relative(userRootDir, filePathAbsoluteFilesystem);
54
+ if (filePathAbsoluteFilesystem.startsWith(userRootDir)) {
55
55
  (0, assert_js_1.assert)(!filePathRelativeToUserRootDir.startsWith('.') && !filePathRelativeToUserRootDir.startsWith('/'),
56
56
  // Surprinsingly, this assertion seem to fail sometimes: https://github.com/vikejs/vike/issues/1139
57
- { filePathRelativeToUserRootDir, filePathAbsolute, userRootDir });
57
+ { filePathRelativeToUserRootDir, filePathAbsoluteFilesystem, userRootDir });
58
58
  filePathRelativeToUserRootDir = `/${filePathRelativeToUserRootDir}`;
59
59
  return filePathRelativeToUserRootDir;
60
60
  }
@@ -63,7 +63,7 @@ function getFilePathRelativeToUserRootDir(filePathAbsolute, userRootDir, alwaysR
63
63
  return filePathRelativeToUserRootDir;
64
64
  }
65
65
  else {
66
- return filePathAbsolute;
66
+ return filePathAbsoluteFilesystem;
67
67
  }
68
68
  }
69
69
  }
@@ -52,7 +52,7 @@ function parseUrl(url, baseServer) {
52
52
  const searchAll = {};
53
53
  Array.from(new URLSearchParams(searchOriginal || '')).forEach(([key, val]) => {
54
54
  search[key] = val;
55
- searchAll[key] = [...(searchAll[key] || []), val];
55
+ searchAll[key] = [...(searchAll.hasOwnProperty(key) ? searchAll[key] : []), val];
56
56
  });
57
57
  // Origin + pathname
58
58
  const { origin, pathname: pathnameResolved } = parsePathname(urlWithoutHashNorSearch, baseServer);
@@ -2,7 +2,7 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.projectInfo = void 0;
4
4
  const assertSingleInstance_js_1 = require("./assertSingleInstance.js");
5
- const PROJECT_VERSION = '0.4.144-commit-e40e9b1';
5
+ const PROJECT_VERSION = '0.4.144-commit-d687042';
6
6
  const projectInfo = {
7
7
  projectName: 'Vike',
8
8
  projectVersion: PROJECT_VERSION,
@@ -1,7 +1,7 @@
1
1
  export { buildConfig };
2
2
  export { assertRollupInput };
3
3
  export { analyzeClientEntries };
4
- import { assert, resolveOutDir, isObject, viteIsSSR, getFilePathAbsolute, addOnBeforeLogHook, removeFileExtention, unique, assertPosixPath, assertUsage, getOutDirs, } from '../utils.js';
4
+ import { assert, resolveOutDir, isObject, viteIsSSR, getFilePathAbsolute, addOnBeforeLogHook, removeFileExtention, unique, assertPosixPath, assertUsage, getOutDirs } from '../utils.js';
5
5
  import { virtualFileIdImportUserCodeServer } from '../../shared/virtual-files/virtualFileImportUserCode.js';
6
6
  import { getVikeConfig } from './importUserCode/v1-design/getVikeConfig.js';
7
7
  import { getConfigValue } from '../../../shared/page-configs/utils.js';
@@ -38,13 +38,13 @@ async function getPageDeps(config, pageConfigs, isDev) {
38
38
  if (configEnv !== 'client-only' && configEnv !== 'server-and-client')
39
39
  return;
40
40
  if (definedAtInfo.filePathRelativeToUserRootDir !== null) {
41
- const { filePathAbsolute } = definedAtInfo;
42
- assert(filePathAbsolute);
41
+ const { filePathAbsoluteFilesystem } = definedAtInfo;
42
+ assert(filePathAbsoluteFilesystem);
43
43
  // Surprisingly Vite expects entries to be absolute paths
44
- entries.push(filePathAbsolute);
44
+ entries.push(filePathAbsoluteFilesystem);
45
45
  }
46
46
  else {
47
- // Adding definedAtInfo.filePathAbsolute doesn't work for npm packages, I guess because of Vite's config.server.fs.allow
47
+ // Adding definedAtInfo.filePathAbsoluteFilesystem doesn't work for npm packages, I guess because of Vite's config.server.fs.allow
48
48
  const { importPathAbsolute } = definedAtInfo;
49
49
  assert(importPathAbsolute);
50
50
  // We need to differentiate between npm package imports and path aliases.
@@ -1,6 +1,6 @@
1
1
  export { envVarsPlugin };
2
2
  import { loadEnv } from 'vite';
3
- import { assert, assertPosixPath, assertUsage, assertWarning, getFilePathRelativeToUserRootDir, lowerFirst } from '../utils.js';
3
+ import { assert, assertPosixPath, assertUsage, assertWarning, escapeRegex, getFilePathRelativeToUserRootDir, lowerFirst } from '../utils.js';
4
4
  function envVarsPlugin() {
5
5
  let envsAll;
6
6
  let config;
@@ -35,25 +35,30 @@ function envVarsPlugin() {
35
35
  })
36
36
  .forEach(([key, val]) => {
37
37
  const varName = `import.meta.env.${key}`;
38
- const publicPrefix = 'PUBLIC_ENV__';
39
- const keyPublic = `${publicPrefix}${key}`;
40
- const isPrivate = !key.startsWith(publicPrefix);
41
- if (isPrivate && isClientSide) {
42
- if (!code.includes(varName))
43
- return;
44
- const filePathToShowToUser = getFilePathRelativeToUserRootDir(id, config.root);
45
- const errMsgAddendum = isBuild ? '' : ' (vike will prevent your app from building for production)';
46
- const errMsg = `${varName} used in ${filePathToShowToUser} and therefore included in client-side bundle which can be be a security leak${errMsgAddendum}, remove ${varName} or rename ${key} to ${keyPublic}, see https://vike.dev/env`;
47
- if (isBuild) {
48
- assertUsage(false, errMsg);
49
- }
50
- else {
51
- // Only a warning for faster development DX (e.g. when use toggles `ssr: boolean` or `onBeforeRenderIsomorph: boolean`)
52
- assertWarning(false, errMsg, { onlyOnce: true });
38
+ // Security check
39
+ {
40
+ const publicPrefix = 'PUBLIC_ENV__';
41
+ const isPrivate = !key.startsWith(publicPrefix);
42
+ if (isPrivate && isClientSide) {
43
+ if (!code.includes(varName))
44
+ return;
45
+ const filePathToShowToUser = getFilePathRelativeToUserRootDir(id, config.root);
46
+ const errMsgAddendum = isBuild ? '' : ' (Vike will prevent your app from building for production)';
47
+ const keyPublic = `${publicPrefix}${key}`;
48
+ const errMsg = `${varName} is used in client-side file ${filePathToShowToUser} which means that the environment variable ${key} will be included in client-side bundles and, therefore, ${key} will be publicly exposed which can be a security leak${errMsgAddendum}. Use ${varName} only in server-side files, or rename ${key} to ${keyPublic}, see https://vike.dev/env`;
49
+ if (isBuild) {
50
+ assertUsage(false, errMsg);
51
+ }
52
+ else {
53
+ // Only a warning for faster development DX (e.g. when user toggles `ssr: boolean` or `onBeforeRenderIsomorph: boolean`)
54
+ assertWarning(false, errMsg, { onlyOnce: true });
55
+ }
53
56
  }
57
+ // Double check
58
+ assert(!(isPrivate && isClientSide) || !isBuild);
54
59
  }
55
- assert(!(isPrivate && isClientSide) || !isBuild);
56
- code = code.replaceAll(varName, JSON.stringify(val));
60
+ // Apply
61
+ code = code.replace(new RegExp(escapeRegex(varName) + '\b', 'g'), JSON.stringify(val));
57
62
  });
58
63
  // No need for low-resolution source map since line numbers didn't change. (Does Vite do high-resolution column numbers source mapping?)
59
64
  return code;
@@ -111,8 +111,8 @@ function handleHotUpdate(ctx, config, configVike) {
111
111
  return virtualModules;
112
112
  }
113
113
  }
114
- function isVikeConfigModule(filePathAbsolute) {
115
- return vikeConfigDependencies.has(filePathAbsolute);
114
+ function isVikeConfigModule(filePathAbsoluteFilesystem) {
115
+ return vikeConfigDependencies.has(filePathAbsoluteFilesystem);
116
116
  }
117
117
  function reloadConfig(filePath, config, configVike, op) {
118
118
  {
@@ -5,7 +5,7 @@ type FilePath = {
5
5
  *
6
6
  * Example: `/home/rom/code/my-app/pages/some-page/Page.js`
7
7
  */
8
- filePathAbsolute: string;
8
+ filePathAbsoluteFilesystem: string;
9
9
  } & ({
10
10
  /** The file's path relative to the Vite's root (i.e. the user's project root directory).
11
11
  *
@@ -7,7 +7,7 @@ if (f.filePathRelativeToUserRootDir === null) {
7
7
  }
8
8
  //*/
9
9
  function getFilePathToShowToUser(filePath) {
10
- const filePathToShowToUser = filePath.filePathRelativeToUserRootDir ?? filePath.filePathAbsolute;
10
+ const filePathToShowToUser = filePath.filePathRelativeToUserRootDir ?? filePath.filePathAbsoluteFilesystem;
11
11
  assert(filePathToShowToUser);
12
12
  return filePathToShowToUser;
13
13
  }
@@ -81,9 +81,9 @@ async function loadInterfaceFiles(userRootDir, outDirRoot, isDev, extensions) {
81
81
  });
82
82
  let interfaceFilesByLocationId = {};
83
83
  // Config files
84
- await Promise.all(configFiles.map(async ({ filePathAbsolute, filePathRelativeToUserRootDir }) => {
84
+ await Promise.all(configFiles.map(async ({ filePathAbsoluteFilesystem, filePathRelativeToUserRootDir }) => {
85
85
  const configFilePath = {
86
- filePathAbsolute: filePathAbsolute,
86
+ filePathAbsoluteFilesystem: filePathAbsoluteFilesystem,
87
87
  filePathRelativeToUserRootDir: filePathRelativeToUserRootDir,
88
88
  importPathAbsolute: null
89
89
  };
@@ -98,13 +98,13 @@ async function loadInterfaceFiles(userRootDir, outDirRoot, isDev, extensions) {
98
98
  });
99
99
  }));
100
100
  // Value files
101
- await Promise.all(valueFiles.map(async ({ filePathAbsolute, filePathRelativeToUserRootDir }) => {
101
+ await Promise.all(valueFiles.map(async ({ filePathAbsoluteFilesystem, filePathRelativeToUserRootDir }) => {
102
102
  const configName = getConfigName(filePathRelativeToUserRootDir);
103
103
  assert(configName);
104
104
  const interfaceFile = {
105
105
  filePath: {
106
106
  filePathRelativeToUserRootDir,
107
- filePathAbsolute,
107
+ filePathAbsoluteFilesystem,
108
108
  importPathAbsolute: null
109
109
  },
110
110
  configMap: {
@@ -546,20 +546,20 @@ function resolveImport(configValue, importerFilePath, userRootDir, configEnv, co
546
546
  if (!importData)
547
547
  return null;
548
548
  const { importPath, exportName } = importData;
549
- const filePathAbsolute = resolveImportPath(importData, importerFilePath);
550
- assertFileEnv(filePathAbsolute ?? importPath, configEnv, configName);
549
+ const filePathAbsoluteFilesystem = resolveImportPath(importData, importerFilePath);
550
+ assertFileEnv(filePathAbsoluteFilesystem ?? importPath, configEnv, configName);
551
551
  const fileExportPath = exportName === 'default' || exportName === configName ? [] : [exportName];
552
552
  if (importPath.startsWith('.')) {
553
553
  // We need to resolve relative paths into absolute paths. Because the import paths are included in virtual files:
554
554
  // ```
555
555
  // [vite] Internal server error: Failed to resolve import "./onPageTransitionHooks" from "virtual:vike:pageConfigValuesAll:client:/pages/index". Does the file exist?
556
556
  // ```
557
- assertImportPath(filePathAbsolute, importData, importerFilePath);
558
- const filePathRelativeToUserRootDir = resolveImportPath_relativeToUserRootDir(filePathAbsolute, importData, importerFilePath, userRootDir);
557
+ assertImportPath(filePathAbsoluteFilesystem, importData, importerFilePath);
558
+ const filePathRelativeToUserRootDir = resolveImportPath_relativeToUserRootDir(filePathAbsoluteFilesystem, importData, importerFilePath, userRootDir);
559
559
  return {
560
560
  exportName,
561
561
  fileExportPath,
562
- filePathAbsolute,
562
+ filePathAbsoluteFilesystem,
563
563
  filePathRelativeToUserRootDir,
564
564
  importPathAbsolute: null
565
565
  };
@@ -571,26 +571,26 @@ function resolveImport(configValue, importerFilePath, userRootDir, configEnv, co
571
571
  return {
572
572
  exportName,
573
573
  fileExportPath,
574
- filePathAbsolute,
574
+ filePathAbsoluteFilesystem,
575
575
  filePathRelativeToUserRootDir: null,
576
576
  importPathAbsolute: importPath
577
577
  };
578
578
  }
579
579
  }
580
- function resolveImportPath_relativeToUserRootDir(filePathAbsolute, importData, configFilePath, userRootDir) {
580
+ function resolveImportPath_relativeToUserRootDir(filePathAbsoluteFilesystem, importData, configFilePath, userRootDir) {
581
581
  assertPosixPath(userRootDir);
582
582
  let filePathRelativeToUserRootDir;
583
- if (filePathAbsolute.startsWith(userRootDir)) {
584
- filePathRelativeToUserRootDir = getVitePathFromAbsolutePath(filePathAbsolute, userRootDir);
583
+ if (filePathAbsoluteFilesystem.startsWith(userRootDir)) {
584
+ filePathRelativeToUserRootDir = getVitePathFromAbsolutePath(filePathAbsoluteFilesystem, userRootDir);
585
585
  }
586
586
  else {
587
587
  assertUsage(false, `${getFilePathToShowToUser(configFilePath)} imports from a relative path ${pc.cyan(importData.importPath)} outside of ${userRootDir} which is forbidden: import from a relative path inside ${userRootDir}, or import from a dependency's package.json#exports entry instead`);
588
588
  // None of the following works. Seems to be a Vite bug?
589
589
  // /*
590
- // assert(filePathAbsolute.startsWith('/'))
591
- // filePath = `/@fs${filePathAbsolute}`
590
+ // assert(filePathAbsoluteFilesystem.startsWith('/'))
591
+ // filePath = `/@fs${filePathAbsoluteFilesystem}`
592
592
  // /*/
593
- // filePathRelativeToUserRootDir = path.posix.relative(userRootDir, filePathAbsolute)
593
+ // filePathRelativeToUserRootDir = path.posix.relative(userRootDir, filePathAbsoluteFilesystem)
594
594
  // assert(filePathRelativeToUserRootDir.startsWith('../'))
595
595
  // filePathRelativeToUserRootDir = '/' + filePathRelativeToUserRootDir
596
596
  // //*/
@@ -599,11 +599,11 @@ function resolveImportPath_relativeToUserRootDir(filePathAbsolute, importData, c
599
599
  assert(filePathRelativeToUserRootDir.startsWith('/'));
600
600
  return filePathRelativeToUserRootDir;
601
601
  }
602
- function getVitePathFromAbsolutePath(filePathAbsolute, root) {
603
- assertPosixPath(filePathAbsolute);
602
+ function getVitePathFromAbsolutePath(filePathAbsoluteFilesystem, root) {
603
+ assertPosixPath(filePathAbsoluteFilesystem);
604
604
  assertPosixPath(root);
605
- assert(filePathAbsolute.startsWith(root));
606
- let vitePath = path.posix.relative(root, filePathAbsolute);
605
+ assert(filePathAbsoluteFilesystem.startsWith(root));
606
+ let vitePath = path.posix.relative(root, filePathAbsoluteFilesystem);
607
607
  assert(!vitePath.startsWith('/') && !vitePath.startsWith('.'));
608
608
  vitePath = '/' + vitePath;
609
609
  return vitePath;
@@ -756,8 +756,8 @@ async function findPlusFiles(userRootDir, ignoreDirs, isDev, extensions) {
756
756
  const plusFiles = result.map((p) => {
757
757
  p = toPosixPath(p);
758
758
  const filePathRelativeToUserRootDir = path.posix.join('/', p);
759
- const filePathAbsolute = path.posix.join(userRootDir, p);
760
- return { filePathRelativeToUserRootDir, filePathAbsolute };
759
+ const filePathAbsoluteFilesystem = path.posix.join(userRootDir, p);
760
+ return { filePathRelativeToUserRootDir, filePathAbsoluteFilesystem };
761
761
  });
762
762
  extensions.forEach((extension) => {
763
763
  extension.pageConfigsDistFiles?.forEach((pageConfigDistFile) => {
@@ -769,7 +769,7 @@ async function findPlusFiles(userRootDir, ignoreDirs, isDev, extensions) {
769
769
  const { importPath, filePath } = pageConfigDistFile;
770
770
  plusFiles.push({
771
771
  filePathRelativeToUserRootDir: importPath,
772
- filePathAbsolute: filePath
772
+ filePathAbsoluteFilesystem: filePath
773
773
  });
774
774
  });
775
775
  });
@@ -799,12 +799,12 @@ function assertNoUnexpectedPlusSign(filePath, fileName) {
799
799
  assertUsage(!fileName.slice(1).includes('+'), `Character '+' is only allowed at the beginning of filenames: make sure ${filePath} doesn't contain any '+' in its filename other than its first letter`);
800
800
  }
801
801
  async function loadConfigFile(configFilePath, userRootDir, visited) {
802
- const { filePathAbsolute } = configFilePath;
803
- assertNoInfiniteLoop(visited, filePathAbsolute);
802
+ const { filePathAbsoluteFilesystem } = configFilePath;
803
+ assertNoInfiniteLoop(visited, filePathAbsoluteFilesystem);
804
804
  const { fileExports } = await transpileAndExecuteFile(configFilePath, false, userRootDir);
805
805
  const { extendsConfigs, extendsFilePaths } = await loadExtendsConfigs(fileExports, configFilePath, userRootDir, [
806
806
  ...visited,
807
- filePathAbsolute
807
+ filePathAbsoluteFilesystem
808
808
  ]);
809
809
  const configFile = {
810
810
  fileExports,
@@ -813,13 +813,13 @@ async function loadConfigFile(configFilePath, userRootDir, visited) {
813
813
  };
814
814
  return { configFile, extendsConfigs };
815
815
  }
816
- function assertNoInfiniteLoop(visited, filePathAbsolute) {
817
- const idx = visited.indexOf(filePathAbsolute);
816
+ function assertNoInfiniteLoop(visited, filePathAbsoluteFilesystem) {
817
+ const idx = visited.indexOf(filePathAbsoluteFilesystem);
818
818
  if (idx === -1)
819
819
  return;
820
820
  const loop = visited.slice(idx);
821
- assert(loop[0] === filePathAbsolute);
822
- assertUsage(idx === -1, `Infinite extends loop ${[...loop, filePathAbsolute].join('>')}`);
821
+ assert(loop[0] === filePathAbsoluteFilesystem);
822
+ assertUsage(idx === -1, `Infinite extends loop ${[...loop, filePathAbsoluteFilesystem].join('>')}`);
823
823
  }
824
824
  async function loadExtendsConfigs(configFileExports, configFilePath, userRootDir, visited) {
825
825
  const extendsImportData = getExtendsImportData(configFileExports, configFilePath);
@@ -828,14 +828,14 @@ async function loadExtendsConfigs(configFileExports, configFilePath, userRootDir
828
828
  const { importPath: importPath } = importData;
829
829
  // TODO
830
830
  // - validate extends configs
831
- const filePathAbsolute = resolveImportPath(importData, configFilePath);
832
- assertImportPath(filePathAbsolute, importData, configFilePath);
833
- assertExtendsImportPath(importPath, filePathAbsolute, configFilePath);
831
+ const filePathAbsoluteFilesystem = resolveImportPath(importData, configFilePath);
832
+ assertImportPath(filePathAbsoluteFilesystem, importData, configFilePath);
833
+ assertExtendsImportPath(importPath, filePathAbsoluteFilesystem, configFilePath);
834
834
  // - filePathRelativeToUserRootDir has no functionality beyond nicer error messages for user
835
- // - Using importPath would be visually nicer but it's ambigous => we rather pick filePathAbsolute for added clarity
836
- const filePathRelativeToUserRootDir = determineFilePathRelativeToUserDir(filePathAbsolute, userRootDir);
835
+ // - Using importPath would be visually nicer but it's ambigous => we rather pick filePathAbsoluteFilesystem for added clarity
836
+ const filePathRelativeToUserRootDir = determineFilePathRelativeToUserDir(filePathAbsoluteFilesystem, userRootDir);
837
837
  extendsConfigFiles.push({
838
- filePathAbsolute,
838
+ filePathAbsoluteFilesystem,
839
839
  // TODO: fix type cast
840
840
  filePathRelativeToUserRootDir: filePathRelativeToUserRootDir,
841
841
  importPathAbsolute: importPath
@@ -847,16 +847,16 @@ async function loadExtendsConfigs(configFileExports, configFilePath, userRootDir
847
847
  extendsConfigs.push(result.configFile);
848
848
  extendsConfigs.push(...result.extendsConfigs);
849
849
  }));
850
- const extendsFilePaths = extendsConfigFiles.map((f) => f.filePathAbsolute);
850
+ const extendsFilePaths = extendsConfigFiles.map((f) => f.filePathAbsoluteFilesystem);
851
851
  return { extendsConfigs, extendsFilePaths };
852
852
  }
853
- function determineFilePathRelativeToUserDir(filePathAbsolute, userRootDir) {
854
- assertPosixPath(filePathAbsolute);
853
+ function determineFilePathRelativeToUserDir(filePathAbsoluteFilesystem, userRootDir) {
854
+ assertPosixPath(filePathAbsoluteFilesystem);
855
855
  assertPosixPath(userRootDir);
856
- if (!filePathAbsolute.startsWith(userRootDir)) {
856
+ if (!filePathAbsoluteFilesystem.startsWith(userRootDir)) {
857
857
  return null;
858
858
  }
859
- let filePathRelativeToUserRootDir = filePathAbsolute.slice(userRootDir.length);
859
+ let filePathRelativeToUserRootDir = filePathAbsoluteFilesystem.slice(userRootDir.length);
860
860
  if (!filePathRelativeToUserRootDir.startsWith('/'))
861
861
  filePathRelativeToUserRootDir = '/' + filePathRelativeToUserRootDir;
862
862
  return filePathRelativeToUserRootDir;
@@ -1016,17 +1016,17 @@ function determineIsErrorPage(routeFilesystem) {
1016
1016
  return routeFilesystem.split('/').includes('_error');
1017
1017
  }
1018
1018
  function resolveImportPath(importData, importerFilePath) {
1019
- const importerFilePathAbsolute = importerFilePath.filePathAbsolute;
1019
+ const importerFilePathAbsolute = importerFilePath.filePathAbsoluteFilesystem;
1020
1020
  assertPosixPath(importerFilePathAbsolute);
1021
1021
  const cwd = path.posix.dirname(importerFilePathAbsolute);
1022
- // filePathAbsolute is expected to be null when importData.importPath is a Vite path alias
1023
- const filePathAbsolute = requireResolve(importData.importPath, cwd);
1024
- return filePathAbsolute;
1022
+ // filePathAbsoluteFilesystem is expected to be null when importData.importPath is a Vite path alias
1023
+ const filePathAbsoluteFilesystem = requireResolve(importData.importPath, cwd);
1024
+ return filePathAbsoluteFilesystem;
1025
1025
  }
1026
- function assertImportPath(filePathAbsolute, importData, importerFilePath) {
1026
+ function assertImportPath(filePathAbsoluteFilesystem, importData, importerFilePath) {
1027
1027
  const { importPath: importPath, importStringWasGenerated, importString } = importData;
1028
1028
  const filePathToShowToUser = getFilePathToShowToUser(importerFilePath);
1029
- if (!filePathAbsolute) {
1029
+ if (!filePathAbsoluteFilesystem) {
1030
1030
  const importPathString = pc.cyan(`'${importPath}'`);
1031
1031
  const errIntro = importStringWasGenerated
1032
1032
  ? `The import path ${importPathString} in ${filePathToShowToUser}`
@@ -20,9 +20,9 @@ async function transpileAndExecuteFile(filePath, isValueFile, userRootDir) {
20
20
  return { fileExports };
21
21
  }
22
22
  async function transpileFile(filePath, isValueFile, userRootDir) {
23
- const { filePathAbsolute } = filePath;
24
- assertPosixPath(filePathAbsolute);
25
- vikeConfigDependencies.add(filePathAbsolute);
23
+ const { filePathAbsoluteFilesystem } = filePath;
24
+ assertPosixPath(filePathAbsoluteFilesystem);
25
+ vikeConfigDependencies.add(filePathAbsoluteFilesystem);
26
26
  let code = await transpileWithEsbuild(filePath, isValueFile, userRootDir);
27
27
  let fileImports = null;
28
28
  {
@@ -36,9 +36,9 @@ async function transpileFile(filePath, isValueFile, userRootDir) {
36
36
  }
37
37
  function transpileImports(codeOriginal, filePath, isValueFile) {
38
38
  // Do we need to remove the imports?
39
- const { filePathAbsolute } = filePath;
40
- assertPosixPath(filePathAbsolute);
41
- const isHeader = isHeaderFile(filePathAbsolute);
39
+ const { filePathAbsoluteFilesystem } = filePath;
40
+ assertPosixPath(filePathAbsoluteFilesystem);
41
+ const isHeader = isHeaderFile(filePathAbsoluteFilesystem);
42
42
  const isPageConfigFile = !isValueFile;
43
43
  if (!isHeader && !isPageConfigFile) {
44
44
  return null;
@@ -60,7 +60,7 @@ function transpileImports(codeOriginal, filePath, isValueFile) {
60
60
  return { code, fileImports };
61
61
  }
62
62
  async function transpileWithEsbuild(filePath, bundle, userRootDir) {
63
- const entryFilePath = filePath.filePathAbsolute;
63
+ const entryFilePath = filePath.filePathAbsoluteFilesystem;
64
64
  const entryFileDir = path.posix.dirname(entryFilePath);
65
65
  const options = {
66
66
  platform: 'node',
@@ -125,8 +125,8 @@ async function transpileWithEsbuild(filePath, bundle, userRootDir) {
125
125
  Object.keys(result.metafile.inputs).forEach((filePathRelative) => {
126
126
  filePathRelative = toPosixPath(filePathRelative);
127
127
  assertPosixPath(userRootDir);
128
- const filePathAbsolute = path.posix.join(userRootDir, filePathRelative);
129
- vikeConfigDependencies.add(filePathAbsolute);
128
+ const filePathAbsoluteFilesystem = path.posix.join(userRootDir, filePathRelative);
129
+ vikeConfigDependencies.add(filePathAbsoluteFilesystem);
130
130
  });
131
131
  }
132
132
  const code = result.outputFiles[0].text;
@@ -134,10 +134,10 @@ async function transpileWithEsbuild(filePath, bundle, userRootDir) {
134
134
  return code;
135
135
  }
136
136
  async function executeFile(filePath, code, fileImports, isValueFile) {
137
- const { filePathAbsolute, filePathRelativeToUserRootDir } = filePath;
137
+ const { filePathAbsoluteFilesystem, filePathRelativeToUserRootDir } = filePath;
138
138
  // Alternative to using a temporary file: https://github.com/vitejs/vite/pull/13269
139
139
  // - But seems to break source maps, so I don't think it's worth it
140
- const filePathTmp = getFilePathTmp(filePathAbsolute);
140
+ const filePathTmp = getFilePathTmp(filePathAbsoluteFilesystem);
141
141
  fs.writeFileSync(filePathTmp, code);
142
142
  const clean = () => fs.unlinkSync(filePathTmp);
143
143
  let fileExports = {};
@@ -160,7 +160,7 @@ async function executeFile(filePath, code, fileImports, isValueFile) {
160
160
  fileExports = { ...fileExports };
161
161
  if (fileImports && !isValueFile) {
162
162
  assert(filePathRelativeToUserRootDir !== undefined);
163
- const filePathToShowToUser = filePathRelativeToUserRootDir ?? filePathAbsolute;
163
+ const filePathToShowToUser = filePathRelativeToUserRootDir ?? filePathAbsoluteFilesystem;
164
164
  assertImportsAreReExported(fileImports, fileExports, filePathToShowToUser);
165
165
  }
166
166
  return { fileExports };
@@ -93,11 +93,11 @@ type DefinedAtFile = {
93
93
  type DefinedAtFileInfo = // TODO: replace filePathRelativeToUserRootDir and importPathAbsolute with following?
94
94
  ({
95
95
  filePathRelativeToUserRootDir: string;
96
- filePathAbsolute: string;
96
+ filePathAbsoluteFilesystem: string;
97
97
  importPathAbsolute: null;
98
98
  } | {
99
99
  filePathRelativeToUserRootDir: null;
100
- filePathAbsolute: string | null;
100
+ filePathAbsoluteFilesystem: string | null;
101
101
  importPathAbsolute: string;
102
102
  }) & {
103
103
  exportName?: string;
@@ -2,4 +2,4 @@ export { getFilePathAbsolute };
2
2
  export { getFilePathRelativeToUserRootDir };
3
3
  import type { ResolvedConfig } from 'vite';
4
4
  declare function getFilePathAbsolute(filePath: string, config: ResolvedConfig): string;
5
- declare function getFilePathRelativeToUserRootDir(filePathAbsolute: string, userRootDir: string, alwaysRelative?: boolean): string;
5
+ declare function getFilePathRelativeToUserRootDir(filePathAbsoluteFilesystem: string, userRootDir: string, alwaysRelative?: boolean): string;
@@ -30,26 +30,26 @@ function getFilePathAbsolute(filePath, config) {
30
30
  filePathUnresolved = path.posix.join(root, filePath);
31
31
  assertPathIsFilesystemAbsolute(filePathUnresolved);
32
32
  }
33
- let filePathAbsolute;
33
+ let filePathAbsoluteFilesystem;
34
34
  try {
35
- filePathAbsolute = require_.resolve(filePathUnresolved, { paths: [config.root] });
35
+ filePathAbsoluteFilesystem = require_.resolve(filePathUnresolved, { paths: [config.root] });
36
36
  }
37
37
  catch (err) {
38
38
  console.error(err);
39
39
  assert(false);
40
40
  }
41
- filePathAbsolute = toPosixPath(filePathAbsolute);
42
- assertPathIsFilesystemAbsolute(filePathAbsolute);
43
- return filePathAbsolute;
41
+ filePathAbsoluteFilesystem = toPosixPath(filePathAbsoluteFilesystem);
42
+ assertPathIsFilesystemAbsolute(filePathAbsoluteFilesystem);
43
+ return filePathAbsoluteFilesystem;
44
44
  }
45
- function getFilePathRelativeToUserRootDir(filePathAbsolute, userRootDir, alwaysRelative = false) {
46
- assertPosixPath(filePathAbsolute);
45
+ function getFilePathRelativeToUserRootDir(filePathAbsoluteFilesystem, userRootDir, alwaysRelative = false) {
46
+ assertPosixPath(filePathAbsoluteFilesystem);
47
47
  assertPosixPath(userRootDir);
48
- let filePathRelativeToUserRootDir = path.posix.relative(userRootDir, filePathAbsolute);
49
- if (filePathAbsolute.startsWith(userRootDir)) {
48
+ let filePathRelativeToUserRootDir = path.posix.relative(userRootDir, filePathAbsoluteFilesystem);
49
+ if (filePathAbsoluteFilesystem.startsWith(userRootDir)) {
50
50
  assert(!filePathRelativeToUserRootDir.startsWith('.') && !filePathRelativeToUserRootDir.startsWith('/'),
51
51
  // Surprinsingly, this assertion seem to fail sometimes: https://github.com/vikejs/vike/issues/1139
52
- { filePathRelativeToUserRootDir, filePathAbsolute, userRootDir });
52
+ { filePathRelativeToUserRootDir, filePathAbsoluteFilesystem, userRootDir });
53
53
  filePathRelativeToUserRootDir = `/${filePathRelativeToUserRootDir}`;
54
54
  return filePathRelativeToUserRootDir;
55
55
  }
@@ -58,7 +58,7 @@ function getFilePathRelativeToUserRootDir(filePathAbsolute, userRootDir, alwaysR
58
58
  return filePathRelativeToUserRootDir;
59
59
  }
60
60
  else {
61
- return filePathAbsolute;
61
+ return filePathAbsoluteFilesystem;
62
62
  }
63
63
  }
64
64
  }
@@ -51,7 +51,7 @@ function parseUrl(url, baseServer) {
51
51
  const searchAll = {};
52
52
  Array.from(new URLSearchParams(searchOriginal || '')).forEach(([key, val]) => {
53
53
  search[key] = val;
54
- searchAll[key] = [...(searchAll[key] || []), val];
54
+ searchAll[key] = [...(searchAll.hasOwnProperty(key) ? searchAll[key] : []), val];
55
55
  });
56
56
  // Origin + pathname
57
57
  const { origin, pathname: pathnameResolved } = parsePathname(urlWithoutHashNorSearch, baseServer);
@@ -5,7 +5,7 @@ type ProjectVersion = typeof projectInfo.projectVersion;
5
5
  type ProjectTag = `[${PackageName}]` | `[${PackageName}@${ProjectVersion}]`;
6
6
  declare const projectInfo: {
7
7
  projectName: "Vike";
8
- projectVersion: "0.4.144-commit-e40e9b1";
8
+ projectVersion: "0.4.144-commit-d687042";
9
9
  npmPackageName: "vike";
10
10
  githubRepository: "https://github.com/vikejs/vike";
11
11
  };
@@ -1,6 +1,6 @@
1
1
  export { projectInfo };
2
2
  import { onProjectInfo } from './assertSingleInstance.js';
3
- const PROJECT_VERSION = '0.4.144-commit-e40e9b1';
3
+ const PROJECT_VERSION = '0.4.144-commit-d687042';
4
4
  const projectInfo = {
5
5
  projectName: 'Vike',
6
6
  projectVersion: PROJECT_VERSION,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "vike",
3
- "version": "0.4.144-commit-e40e9b1",
3
+ "version": "0.4.144-commit-d687042",
4
4
  "scripts": {
5
5
  "dev": "tsc --watch",
6
6
  "build": "rimraf dist/ && pnpm run build:esm && pnpm run build:cjs",
@@ -162,7 +162,6 @@
162
162
  "vike": "./node/cli/bin-entry.js"
163
163
  },
164
164
  "devDependencies": {
165
- "@brillout/part-regex": "^0.1.2",
166
165
  "@brillout/release-me": "^0.1.8",
167
166
  "@types/estree": "^1.0.0",
168
167
  "@types/jest": "^27.4.1",