vike 0.4.220-commit-5c7810f → 0.4.220-commit-af5c91f

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 (120) hide show
  1. package/dist/cjs/node/api/utils.js +1 -1
  2. package/dist/cjs/node/plugin/index.js +1 -1
  3. package/dist/cjs/node/plugin/onLoad.js +1 -1
  4. package/dist/cjs/node/plugin/plugins/buildConfig/fixServerAssets.js +5 -3
  5. package/dist/cjs/node/plugin/plugins/buildConfig.js +7 -5
  6. package/dist/cjs/node/plugin/plugins/buildEntry/index.js +2 -1
  7. package/dist/cjs/node/plugin/plugins/commonConfig.js +1 -2
  8. package/dist/cjs/node/plugin/plugins/extractAssetsPlugin.js +3 -2
  9. package/dist/cjs/node/plugin/plugins/extractExportNamesPlugin.js +2 -1
  10. package/dist/cjs/node/plugin/plugins/importUserCode/getVirtualFileImportUserCode.js +10 -8
  11. package/dist/cjs/node/plugin/plugins/importUserCode/v1-design/getVikeConfig/loadFileAtConfigTime.js +32 -41
  12. package/dist/cjs/node/plugin/plugins/importUserCode/v1-design/getVikeConfig/resolvePointerImport.js +9 -64
  13. package/dist/cjs/node/plugin/plugins/importUserCode/v1-design/getVikeConfig/transpileAndExecuteFile.js +11 -5
  14. package/dist/cjs/node/plugin/plugins/importUserCode/v1-design/getVikeConfig.js +281 -313
  15. package/dist/cjs/node/plugin/plugins/importUserCode/v1-design/getVirtualFilePageConfigValuesAll.js +2 -1
  16. package/dist/cjs/node/plugin/plugins/importUserCode/v1-design/getVirtualFilePageConfigs.js +7 -6
  17. package/dist/cjs/node/plugin/plugins/packageJsonFile.js +2 -2
  18. package/dist/cjs/node/plugin/plugins/previewConfig.js +4 -3
  19. package/dist/cjs/node/plugin/plugins/setGlobalContext.js +2 -1
  20. package/dist/cjs/node/plugin/shared/findPageFiles.js +2 -1
  21. package/dist/cjs/node/plugin/{getOutDirs.js → shared/getOutDirs.js} +24 -27
  22. package/dist/cjs/node/plugin/{resolveClientEntriesDev.js → shared/resolveClientEntriesDev.js} +5 -8
  23. package/dist/cjs/{utils → node/plugin/shared}/viteIsSSR.js +2 -2
  24. package/dist/cjs/node/plugin/utils.js +0 -1
  25. package/dist/cjs/node/prerender/context.js +8 -3
  26. package/dist/cjs/node/prerender/resolvePrerenderConfig.js +26 -5
  27. package/dist/cjs/node/prerender/runPrerender.js +6 -11
  28. package/dist/cjs/node/prerender/utils.js +1 -2
  29. package/dist/cjs/node/runtime/html/injectAssets/getHtmlTags.js +9 -4
  30. package/dist/cjs/node/runtime/renderPage/getEarlyHints.js +2 -27
  31. package/dist/cjs/node/runtime/renderPage/isFontFallback.js +29 -0
  32. package/dist/cjs/node/runtime/utils.js +1 -3
  33. package/dist/cjs/shared/getPageFiles/fileTypes.js +0 -1
  34. package/dist/cjs/shared/getPageFiles/getAllPageIdFiles.js +0 -3
  35. package/dist/cjs/shared/getPageFiles/getPageFileObject.js +0 -5
  36. package/dist/cjs/shared/page-configs/serialize/serializeConfigValues.js +69 -18
  37. package/dist/cjs/shared/utils.js +0 -1
  38. package/dist/cjs/utils/PROJECT_VERSION.js +1 -1
  39. package/dist/cjs/utils/findFile.js +3 -3
  40. package/dist/cjs/utils/isDev.js +2 -5
  41. package/dist/cjs/utils/isFilePathAbsoluteFilesystem.js +2 -2
  42. package/dist/cjs/utils/path.js +48 -0
  43. package/dist/cjs/utils/requireResolve.js +3 -3
  44. package/dist/esm/node/api/utils.d.ts +1 -1
  45. package/dist/esm/node/api/utils.js +1 -1
  46. package/dist/esm/node/plugin/index.js +1 -1
  47. package/dist/esm/node/plugin/onLoad.js +1 -1
  48. package/dist/esm/node/plugin/plugins/buildConfig/fixServerAssets.js +3 -1
  49. package/dist/esm/node/plugin/plugins/buildConfig.js +3 -1
  50. package/dist/esm/node/plugin/plugins/buildEntry/index.js +2 -1
  51. package/dist/esm/node/plugin/plugins/commonConfig.js +2 -3
  52. package/dist/esm/node/plugin/plugins/extractAssetsPlugin.js +2 -1
  53. package/dist/esm/node/plugin/plugins/extractExportNamesPlugin.js +2 -1
  54. package/dist/esm/node/plugin/plugins/importUserCode/getVirtualFileImportUserCode.js +9 -7
  55. package/dist/esm/node/plugin/plugins/importUserCode/v1-design/getVikeConfig/loadFileAtConfigTime.d.ts +14 -11
  56. package/dist/esm/node/plugin/plugins/importUserCode/v1-design/getVikeConfig/loadFileAtConfigTime.js +35 -44
  57. package/dist/esm/node/plugin/plugins/importUserCode/v1-design/getVikeConfig/resolvePointerImport.d.ts +8 -18
  58. package/dist/esm/node/plugin/plugins/importUserCode/v1-design/getVikeConfig/resolvePointerImport.js +10 -65
  59. package/dist/esm/node/plugin/plugins/importUserCode/v1-design/getVikeConfig/transpileAndExecuteFile.d.ts +6 -2
  60. package/dist/esm/node/plugin/plugins/importUserCode/v1-design/getVikeConfig/transpileAndExecuteFile.js +12 -6
  61. package/dist/esm/node/plugin/plugins/importUserCode/v1-design/getVikeConfig.d.ts +8 -6
  62. package/dist/esm/node/plugin/plugins/importUserCode/v1-design/getVikeConfig.js +284 -316
  63. package/dist/esm/node/plugin/plugins/importUserCode/v1-design/getVirtualFilePageConfigValuesAll.js +2 -1
  64. package/dist/esm/node/plugin/plugins/importUserCode/v1-design/getVirtualFilePageConfigs.js +7 -6
  65. package/dist/esm/node/plugin/plugins/packageJsonFile.js +1 -1
  66. package/dist/esm/node/plugin/plugins/previewConfig.js +2 -1
  67. package/dist/esm/node/plugin/plugins/setGlobalContext.js +2 -1
  68. package/dist/esm/node/plugin/shared/findPageFiles.js +2 -1
  69. package/dist/esm/node/plugin/{getOutDirs.js → shared/getOutDirs.js} +2 -5
  70. package/dist/esm/node/plugin/{resolveClientEntriesDev.js → shared/resolveClientEntriesDev.js} +5 -8
  71. package/dist/esm/{utils → node/plugin/shared}/viteIsSSR.js +2 -2
  72. package/dist/esm/node/plugin/utils.d.ts +0 -1
  73. package/dist/esm/node/plugin/utils.js +0 -1
  74. package/dist/esm/node/prerender/context.d.ts +2 -0
  75. package/dist/esm/node/prerender/context.js +8 -3
  76. package/dist/esm/node/prerender/resolvePrerenderConfig.d.ts +8 -1
  77. package/dist/esm/node/prerender/resolvePrerenderConfig.js +26 -5
  78. package/dist/esm/node/prerender/runPrerender.js +7 -12
  79. package/dist/esm/node/prerender/utils.d.ts +1 -2
  80. package/dist/esm/node/prerender/utils.js +1 -2
  81. package/dist/esm/node/runtime/html/injectAssets/getHtmlTags.js +9 -4
  82. package/dist/esm/node/runtime/renderPage/getEarlyHints.js +1 -26
  83. package/dist/esm/node/runtime/renderPage/getPageAssets.d.ts +1 -1
  84. package/dist/esm/node/runtime/renderPage/isFontFallback.d.ts +3 -0
  85. package/dist/esm/node/runtime/renderPage/isFontFallback.js +27 -0
  86. package/dist/esm/node/runtime/utils.d.ts +1 -3
  87. package/dist/esm/node/runtime/utils.js +1 -3
  88. package/dist/esm/shared/getPageFiles/fileTypes.js +1 -2
  89. package/dist/esm/shared/getPageFiles/getAllPageIdFiles.js +0 -3
  90. package/dist/esm/shared/getPageFiles/getPageFileObject.js +0 -5
  91. package/dist/esm/shared/page-configs/PageConfig.d.ts +0 -1
  92. package/dist/esm/shared/page-configs/serialize/serializeConfigValues.d.ts +7 -1
  93. package/dist/esm/shared/page-configs/serialize/serializeConfigValues.js +70 -19
  94. package/dist/esm/shared/utils.d.ts +0 -1
  95. package/dist/esm/shared/utils.js +0 -1
  96. package/dist/esm/utils/PROJECT_VERSION.d.ts +1 -1
  97. package/dist/esm/utils/PROJECT_VERSION.js +1 -1
  98. package/dist/esm/utils/findFile.js +1 -1
  99. package/dist/esm/utils/isDev.js +3 -6
  100. package/dist/esm/utils/isFilePathAbsoluteFilesystem.js +1 -1
  101. package/dist/esm/utils/path.d.ts +14 -0
  102. package/dist/esm/utils/path.js +46 -0
  103. package/dist/esm/utils/projectInfo.d.ts +1 -1
  104. package/dist/esm/utils/requireResolve.js +1 -1
  105. package/package.json +1 -1
  106. package/dist/cjs/node/plugin/plugins/importUserCode/addImportStatement.js +0 -29
  107. package/dist/cjs/shared/assertPageFilePath.js +0 -11
  108. package/dist/cjs/utils/path-shim.js +0 -19
  109. package/dist/cjs/utils/toPosixPath.js +0 -18
  110. package/dist/esm/node/plugin/plugins/importUserCode/addImportStatement.d.ts +0 -14
  111. package/dist/esm/node/plugin/plugins/importUserCode/addImportStatement.js +0 -27
  112. package/dist/esm/shared/assertPageFilePath.d.ts +0 -2
  113. package/dist/esm/shared/assertPageFilePath.js +0 -9
  114. package/dist/esm/utils/path-shim.d.ts +0 -2
  115. package/dist/esm/utils/path-shim.js +0 -17
  116. package/dist/esm/utils/toPosixPath.d.ts +0 -4
  117. package/dist/esm/utils/toPosixPath.js +0 -16
  118. /package/dist/esm/node/plugin/{getOutDirs.d.ts → shared/getOutDirs.d.ts} +0 -0
  119. /package/dist/esm/node/plugin/{resolveClientEntriesDev.d.ts → shared/resolveClientEntriesDev.d.ts} +0 -0
  120. /package/dist/esm/{utils → node/plugin/shared}/viteIsSSR.d.ts +0 -0
@@ -1,8 +1,7 @@
1
1
  export { serializeConfigValues };
2
2
  export { getConfigValuesBase };
3
3
  import { assertIsNotProductionRuntime } from '../../../utils/assertSetup.js';
4
- import { assert, assertUsage, getPropAccessNotation } from '../../../node/plugin/utils.js';
5
- import { addImportStatement } from '../../../node/plugin/plugins/importUserCode/addImportStatement.js';
4
+ import { assert, assertPosixPath, assertUsage, deepEqual, getPropAccessNotation } from '../../../node/plugin/utils.js';
6
5
  import { parsePointerImportData } from '../../../node/plugin/plugins/importUserCode/v1-design/getVikeConfig/transformPointerImports.js';
7
6
  import { getConfigValueFilePathToShowToUser } from '../helpers.js';
8
7
  import { stringify } from '@brillout/json-serializer/stringify';
@@ -13,20 +12,20 @@ const REPLACE_ME_AFTER = '__VIKE__REPLACE_ME_AFTER__';
13
12
  // - vike/shared/page-configs/serialize/parsePageConfigs.ts
14
13
  // - parsePageConfigs() is loaded on both the client- and server-side.
15
14
  assertIsNotProductionRuntime();
16
- function serializeConfigValues(pageConfig, importStatements, isEnvMatch, tabspace, isEager) {
15
+ function serializeConfigValues(pageConfig, importStatements, filesEnv, isEnvMatch, tabspace, isEager) {
17
16
  const lines = [];
18
17
  tabspace += ' ';
19
18
  getConfigValuesBase(pageConfig, isEnvMatch, isEager).forEach((entry) => {
20
19
  if (entry.configValueBase.type === 'computed') {
21
20
  assert('value' in entry); // Help TS
22
- const { configValueBase, value, configName } = entry;
23
- const valueData = getValueSerializedWithJson(value, configName, configValueBase.definedAtData, importStatements);
21
+ const { configValueBase, value, configName, configEnv } = entry;
22
+ const valueData = getValueSerializedWithJson(value, configName, configValueBase.definedAtData, importStatements, filesEnv, configEnv);
24
23
  serializeConfigValue(configValueBase, valueData, configName, lines, tabspace);
25
24
  }
26
25
  if (entry.configValueBase.type === 'standard') {
27
26
  assert('sourceRelevant' in entry); // Help TS
28
27
  const { configValueBase, sourceRelevant, configName } = entry;
29
- const valueData = getValueSerializedFromSource(sourceRelevant, configName, importStatements);
28
+ const valueData = getValueSerializedFromSource(sourceRelevant, configName, importStatements, filesEnv);
30
29
  serializeConfigValue(configValueBase, valueData, configName, lines, tabspace);
31
30
  }
32
31
  if (entry.configValueBase.type === 'cumulative') {
@@ -34,7 +33,7 @@ function serializeConfigValues(pageConfig, importStatements, isEnvMatch, tabspac
34
33
  const { configValueBase, sourcesRelevant, configName } = entry;
35
34
  const valueDataList = [];
36
35
  sourcesRelevant.forEach((source) => {
37
- const valueData = getValueSerializedFromSource(source, configName, importStatements);
36
+ const valueData = getValueSerializedFromSource(source, configName, importStatements, filesEnv);
38
37
  valueDataList.push(valueData);
39
38
  });
40
39
  serializeConfigValue(configValueBase, valueDataList, configName, lines, tabspace);
@@ -42,14 +41,14 @@ function serializeConfigValues(pageConfig, importStatements, isEnvMatch, tabspac
42
41
  });
43
42
  return lines;
44
43
  }
45
- function getValueSerializedFromSource(configValueSource, configName, importStatements) {
44
+ function getValueSerializedFromSource(configValueSource, configName, importStatements, filesEnv) {
46
45
  assert(configValueSource.isOverriden === false);
47
46
  let valueData;
48
47
  if ('value' in configValueSource) {
49
- valueData = getValueSerializedWithJson(configValueSource.value, configName, configValueSource.definedAtFilePath, importStatements);
48
+ valueData = getValueSerializedWithJson(configValueSource.value, configName, configValueSource.definedAtFilePath, importStatements, filesEnv, configValueSource.configEnv);
50
49
  }
51
50
  else {
52
- valueData = getValueSerializedWithImport(configValueSource, importStatements);
51
+ valueData = getValueSerializedWithImport(configValueSource, importStatements, filesEnv, configName);
53
52
  }
54
53
  return valueData;
55
54
  }
@@ -95,27 +94,27 @@ function serializeConfigValue(configValueBase, valueData, configName, lines, tab
95
94
  tabspace = tabspace.slice(2);
96
95
  }
97
96
  }
98
- function getValueSerializedWithImport(configValueSource, importStatements) {
97
+ function getValueSerializedWithImport(configValueSource, importStatements, filesEnv, configName) {
99
98
  assert(!configValueSource.valueIsFilePath);
100
- const { valueIsImportedAtRuntime, valueIsDefinedByPlusFile, definedAtFilePath } = configValueSource;
99
+ const { valueIsImportedAtRuntime, valueIsDefinedByPlusFile, definedAtFilePath, configEnv } = configValueSource;
101
100
  assert(valueIsImportedAtRuntime);
102
101
  const { filePathAbsoluteVite, fileExportName } = definedAtFilePath;
103
102
  if (valueIsDefinedByPlusFile)
104
103
  assert(fileExportName === undefined);
105
- const { importName } = addImportStatement(importStatements, filePathAbsoluteVite, fileExportName || '*');
104
+ const { importName } = addImportStatement(importStatements, filePathAbsoluteVite, fileExportName || '*', filesEnv, configEnv, configName);
106
105
  return {
107
106
  type: valueIsDefinedByPlusFile ? 'plus-file' : 'pointer-import',
108
107
  valueAsJsCode: importName
109
108
  };
110
109
  }
111
- function getValueSerializedWithJson(value, configName, definedAtData, importStatements) {
112
- const valueAsJsCode = valueToJson(value, configName, definedAtData, importStatements);
110
+ function getValueSerializedWithJson(value, configName, definedAtData, importStatements, filesEnv, configEnv) {
111
+ const valueAsJsCode = valueToJson(value, configName, definedAtData, importStatements, filesEnv, configEnv);
113
112
  return {
114
113
  type: 'js-serialized',
115
114
  valueAsJsCode
116
115
  };
117
116
  }
118
- function valueToJson(value, configName, definedAtData, importStatements) {
117
+ function valueToJson(value, configName, definedAtData, importStatements, filesEnv, configEnv) {
119
118
  const valueName = `config${getPropAccessNotation(configName)}`;
120
119
  let configValueSerialized;
121
120
  try {
@@ -130,7 +129,7 @@ function valueToJson(value, configName, definedAtData, importStatements) {
130
129
  if (typeof value === 'string') {
131
130
  const importData = parsePointerImportData(value);
132
131
  if (importData) {
133
- const { importName } = addImportStatement(importStatements, importData.importPath, importData.exportName);
132
+ const { importName } = addImportStatement(importStatements, importData.importPath, importData.exportName, filesEnv, configEnv, configName);
134
133
  const replacement = [REPLACE_ME_BEFORE, importName, REPLACE_ME_AFTER].join('');
135
134
  return { replacement };
136
135
  }
@@ -167,7 +166,8 @@ function logJsonSerializeError(err, configName, definedAtData) {
167
166
  }
168
167
  function getConfigValuesBase(pageConfig, isEnvMatch, isEager) {
169
168
  const fromComputed = Object.entries(pageConfig.configValuesComputed ?? {}).map(([configName, valueInfo]) => {
170
- if (!isEnvMatch(valueInfo.configEnv))
169
+ const { configEnv, value } = valueInfo;
170
+ if (!isEnvMatch(configEnv))
171
171
  return 'SKIP';
172
172
  // Is there a use case for overriding computed values? If yes, then configValeSources has higher precedence
173
173
  if (pageConfig.configValueSources[configName])
@@ -176,7 +176,7 @@ function getConfigValuesBase(pageConfig, isEnvMatch, isEager) {
176
176
  type: 'computed',
177
177
  definedAtData: null
178
178
  };
179
- return { configValueBase, value: valueInfo.value, configName };
179
+ return { configValueBase, value, configName, configEnv };
180
180
  });
181
181
  const fromSources = Object.entries(pageConfig.configValueSources).map(([configName, sources]) => {
182
182
  const configDef = pageConfig.configDefinitions[configName];
@@ -221,3 +221,54 @@ function getDefinedAtFileSource(source) {
221
221
  };
222
222
  return definedAtFile;
223
223
  }
224
+ /*
225
+ * Naming:
226
+ * `import { someExport as someImport } from './some-file'`
227
+ * <=>
228
+ * `{`
229
+ * `importPath: './some-file',`
230
+ * `exportName: 'someExport',`
231
+ * `importName: 'someImport',`
232
+ * `}`
233
+ */
234
+ function addImportStatement(importStatements, importPath, exportName, filesEnv, configEnv, configName) {
235
+ const importCounter = importStatements.length + 1;
236
+ const importName = `import${importCounter}`;
237
+ const importLiteral = (() => {
238
+ if (exportName === '*') {
239
+ return `* as ${importName}`;
240
+ }
241
+ if (exportName === 'default') {
242
+ return importName;
243
+ }
244
+ return `{ ${exportName} as ${importName} }`;
245
+ })();
246
+ const importStatement = `import ${importLiteral} from '${importPath}';`;
247
+ importStatements.push(importStatement);
248
+ assertFileEnv(importPath, configEnv, configName, filesEnv);
249
+ return { importName };
250
+ }
251
+ function assertFileEnv(importPath, configEnv, configName, filesEnv) {
252
+ const key = importPath;
253
+ assert(key);
254
+ assertPosixPath(key);
255
+ assert(!isRelativeImportPath(key));
256
+ if (!filesEnv.has(key)) {
257
+ filesEnv.set(key, []);
258
+ }
259
+ const fileEnvs = filesEnv.get(key);
260
+ const fileEnvNew = { configEnv, configName };
261
+ fileEnvs.push(fileEnvNew);
262
+ const fileEnvDiff = fileEnvs.filter((c) => !deepEqual(c.configEnv, configEnv))[0];
263
+ if (fileEnvDiff) {
264
+ assertUsage(false, [
265
+ `${importPath} defines the value of configs living in different environments:`,
266
+ ...[fileEnvDiff, fileEnvNew].map((c) => ` - config ${pc.code(c.configName)} which value lives in environment ${pc.code(JSON.stringify(c.configEnv))}`),
267
+ 'Defining config values in the same file is allowed only if they live in the same environment, see https://vike.dev/config#pointer-imports'
268
+ ].join('\n'));
269
+ }
270
+ }
271
+ // TODO/now dedupe
272
+ function isRelativeImportPath(importPath) {
273
+ return importPath.startsWith('./') || importPath.startsWith('../');
274
+ }
@@ -12,7 +12,6 @@ export * from '../utils/isPlainObject.js';
12
12
  export * from '../utils/compareString.js';
13
13
  export * from '../utils/isNotNullish.js';
14
14
  export * from '../utils/stringifyStringArray.js';
15
- export * from '../utils/toPosixPath.js';
16
15
  export * from '../utils/cast.js';
17
16
  export * from '../utils/isPropertyGetter.js';
18
17
  export * from '../utils/isPromise.js';
@@ -16,7 +16,6 @@ export * from '../utils/isPlainObject.js';
16
16
  export * from '../utils/compareString.js';
17
17
  export * from '../utils/isNotNullish.js';
18
18
  export * from '../utils/stringifyStringArray.js';
19
- export * from '../utils/toPosixPath.js';
20
19
  export * from '../utils/cast.js';
21
20
  export * from '../utils/isPropertyGetter.js';
22
21
  export * from '../utils/isPromise.js';
@@ -1 +1 @@
1
- export declare const PROJECT_VERSION: "0.4.220-commit-5c7810f";
1
+ export declare const PROJECT_VERSION: "0.4.220-commit-af5c91f";
@@ -1,2 +1,2 @@
1
1
  // Automatically updated by @brillout/release-me
2
- export const PROJECT_VERSION = '0.4.220-commit-5c7810f';
2
+ export const PROJECT_VERSION = '0.4.220-commit-af5c91f';
@@ -2,7 +2,7 @@ export { findFile };
2
2
  import path from 'path';
3
3
  import fs from 'fs';
4
4
  import { isArray } from './isArray.js';
5
- import { assertPosixPath } from './toPosixPath.js';
5
+ import { assertPosixPath } from './path.js';
6
6
  function findFile(arg, cwd) {
7
7
  assertPosixPath(cwd);
8
8
  const filenames = isArray(arg) ? arg : [arg];
@@ -1,14 +1,11 @@
1
1
  export { isDevCheck };
2
2
  export { applyDev };
3
3
  export { applyPreview };
4
- import { assert } from './assert.js';
5
- import { version } from 'vite';
4
+ import { assertUsage } from './assert.js';
6
5
  function isDevCheck(configEnv) {
7
6
  const { isPreview, command } = configEnv;
8
- // Released at vite@5.1.0 which is guaranteed with `assertVersion('Vite', version, '5.1.0')`
9
- // - Release: https://github.com/vitejs/vite/blob/6f7466e6211027686f40ad7e4ce6ec8477414546/packages/vite/CHANGELOG.md#510-beta4-2024-01-26:~:text=fix(preview)%3A-,set%20isPreview%20true,-(%2315695)%20(93fce55
10
- // - Surprisingly, this assert() can fail: https://github.com/vikejs/vike/issues/2135
11
- assert(typeof isPreview === 'boolean', { isPreview, version });
7
+ // `assertVersion('Vite', version, '5.1.0')` isn't enough: https://github.com/vitejs/vite/pull/19355
8
+ assertUsage(typeof isPreview === 'boolean', 'You are using an old Vite version; make sure to use Vite 5.1.0 or above.');
12
9
  return command === 'serve' && !isPreview;
13
10
  }
14
11
  function applyDev(_, env) {
@@ -2,7 +2,7 @@ export { assertFilePathAbsoluteFilesystem };
2
2
  export { isFilePathAbsolute };
3
3
  import path from 'path';
4
4
  import { assert } from './assert.js';
5
- import { assertPosixPath } from './toPosixPath.js';
5
+ import { assertPosixPath } from './path.js';
6
6
  /**
7
7
  * Asserts that `filePath` is an absolute file path starting from the filesystem root.
8
8
  *
@@ -0,0 +1,14 @@
1
+ export { pathJoin };
2
+ export { pathIsRelative };
3
+ export { toPosixPath };
4
+ export { assertPosixPath };
5
+ /**********************/
6
+ /****** SHIMS *********/
7
+ /**********************/
8
+ declare function pathJoin(path1: string, path2: string): string;
9
+ /**********************/
10
+ /****** UTILS *********/
11
+ /**********************/
12
+ declare function toPosixPath(path: string): string;
13
+ declare function assertPosixPath(path: string): void;
14
+ declare function pathIsRelative(importPath: string): boolean;
@@ -0,0 +1,46 @@
1
+ export { pathJoin };
2
+ export { pathIsRelative };
3
+ export { toPosixPath };
4
+ export { assertPosixPath };
5
+ // Utilites for handling file paths.
6
+ // - Shims `import * from "node:path"` for server runtime.
7
+ // - Robust shim reference: https://github.com/unjs/pathe
8
+ import { assert } from './assert.js';
9
+ import { assertIsNotBrowser } from './assertIsNotBrowser.js';
10
+ assertIsNotBrowser();
11
+ /**********************/
12
+ /****** SHIMS *********/
13
+ /**********************/
14
+ function pathJoin(path1, path2) {
15
+ assert(!path1.includes('\\'));
16
+ assert(!path2.includes('\\'));
17
+ let joined = [...path1.split('/'), ...path2.split('/')].filter(Boolean).join('/');
18
+ if (path1.startsWith('/'))
19
+ joined = '/' + joined;
20
+ return joined;
21
+ }
22
+ /* https://github.com/brillout/telefunc/blob/0fd44322acbd07857ae29361ba7c998607f17dd5/telefunc/utils/path-shim.ts#L17-L21
23
+ const IS_ABSOLUTE_RE = /^[/\\](?![/\\])|^[/\\]{2}(?!\.)|^[A-Za-z]:[/\\]/
24
+ function pathIsAbsolute(filePath: string) {
25
+ return IS_ABSOLUTE_RE.test(filePath)
26
+ }
27
+ //*/
28
+ /**********************/
29
+ /****** UTILS *********/
30
+ /**********************/
31
+ function toPosixPath(path) {
32
+ const pathPosix = path.split('\\').join('/');
33
+ assertPosixPath(pathPosix);
34
+ return pathPosix;
35
+ }
36
+ function assertPosixPath(path) {
37
+ const errMsg = (msg) => `Not a posix path: ${msg}`;
38
+ assert(path !== null, errMsg('null'));
39
+ assert(typeof path === 'string', errMsg(`typeof path === ${JSON.stringify(typeof path)}`));
40
+ assert(path !== '', errMsg('(empty string)'));
41
+ assert(path);
42
+ assert(!path.includes('\\'), errMsg(path));
43
+ }
44
+ function pathIsRelative(importPath) {
45
+ return importPath.startsWith('./') || importPath.startsWith('../');
46
+ }
@@ -1,4 +1,4 @@
1
1
  export declare const projectInfo: {
2
2
  projectName: "Vike";
3
- projectVersion: "0.4.220-commit-5c7810f";
3
+ projectVersion: "0.4.220-commit-af5c91f";
4
4
  };
@@ -2,7 +2,7 @@ export { requireResolve };
2
2
  import { assert } from './assert.js';
3
3
  import { assertIsNotBrowser } from './assertIsNotBrowser.js';
4
4
  import { assertIsNotProductionRuntime } from './assertSetup.js';
5
- import { assertPosixPath, toPosixPath } from './toPosixPath.js';
5
+ import { assertPosixPath, toPosixPath } from './path.js';
6
6
  import { scriptFileExtensionList } from './isScriptFile.js';
7
7
  import { createRequire } from 'module';
8
8
  // @ts-ignore Shimmed by dist-cjs-fixup.js for CJS build.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "vike",
3
- "version": "0.4.220-commit-5c7810f",
3
+ "version": "0.4.220-commit-af5c91f",
4
4
  "repository": "https://github.com/vikejs/vike",
5
5
  "exports": {
6
6
  "./server": {
@@ -1,29 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.addImportStatement = addImportStatement;
4
- /**
5
- * Naming:
6
- * `import { someExport as someImport } from './some-file'`
7
- * <=>
8
- * `{`
9
- * `importPath: './some-file',`
10
- * `exportName: 'someExport',`
11
- * `importName: 'someImport',`
12
- * `}`
13
- */
14
- function addImportStatement(importStatements, importPath, exportName) {
15
- const importCounter = importStatements.length + 1;
16
- const importName = `import${importCounter}`;
17
- const importLiteral = (() => {
18
- if (exportName === '*') {
19
- return `* as ${importName}`;
20
- }
21
- if (exportName === 'default') {
22
- return importName;
23
- }
24
- return `{ ${exportName} as ${importName} }`;
25
- })();
26
- const importStatement = `import ${importLiteral} from '${importPath}';`;
27
- importStatements.push(importStatement);
28
- return { importName };
29
- }
@@ -1,11 +0,0 @@
1
- "use strict";
2
- // TODO/v1-release: remove
3
- Object.defineProperty(exports, "__esModule", { value: true });
4
- exports.assertPageFilePath = assertPageFilePath;
5
- const utils_js_1 = require("./utils.js");
6
- function assertPageFilePath(filePath) {
7
- (0, utils_js_1.assertPosixPath)(filePath);
8
- /* This assert() is skipped to reduce client-side bundle size
9
- assert(filePath.startsWith('/') || isNpmPackageImport(filePath), { filePath })
10
- */
11
- }
@@ -1,19 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.pathJoin = pathJoin;
4
- // Simple shim for `import * from "node:path"` used by the server runtime.
5
- // Robust alternative: https://github.com/unjs/pathe
6
- const assert_js_1 = require("./assert.js");
7
- function pathJoin(path1, path2) {
8
- (0, assert_js_1.assert)(!path1.includes('\\'));
9
- (0, assert_js_1.assert)(!path2.includes('\\'));
10
- let joined = [...path1.split('/'), ...path2.split('/')].filter(Boolean).join('/');
11
- if (path1.startsWith('/'))
12
- joined = '/' + joined;
13
- return joined;
14
- }
15
- /* https://github.com/brillout/telefunc/blob/0fd44322acbd07857ae29361ba7c998607f17dd5/telefunc/utils/path-shim.ts#L17-L21
16
- function isAbsolute(filePath: string) {
17
- // ...
18
- }
19
- */
@@ -1,18 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.toPosixPath = toPosixPath;
4
- exports.assertPosixPath = assertPosixPath;
5
- const assert_js_1 = require("./assert.js");
6
- function toPosixPath(path) {
7
- const pathPosix = path.split('\\').join('/');
8
- assertPosixPath(pathPosix);
9
- return pathPosix;
10
- }
11
- function assertPosixPath(path) {
12
- const errMsg = (msg) => `Not a posix path: ${msg}`;
13
- (0, assert_js_1.assert)(path !== null, errMsg('null'));
14
- (0, assert_js_1.assert)(typeof path === 'string', errMsg(`typeof path === ${JSON.stringify(typeof path)}`));
15
- (0, assert_js_1.assert)(path !== '', errMsg('(empty string)'));
16
- (0, assert_js_1.assert)(path);
17
- (0, assert_js_1.assert)(!path.includes('\\'), errMsg(path));
18
- }
@@ -1,14 +0,0 @@
1
- export { addImportStatement };
2
- /**
3
- * Naming:
4
- * `import { someExport as someImport } from './some-file'`
5
- * <=>
6
- * `{`
7
- * `importPath: './some-file',`
8
- * `exportName: 'someExport',`
9
- * `importName: 'someImport',`
10
- * `}`
11
- */
12
- declare function addImportStatement(importStatements: string[], importPath: string, exportName: string): {
13
- importName: string;
14
- };
@@ -1,27 +0,0 @@
1
- export { addImportStatement };
2
- /**
3
- * Naming:
4
- * `import { someExport as someImport } from './some-file'`
5
- * <=>
6
- * `{`
7
- * `importPath: './some-file',`
8
- * `exportName: 'someExport',`
9
- * `importName: 'someImport',`
10
- * `}`
11
- */
12
- function addImportStatement(importStatements, importPath, exportName) {
13
- const importCounter = importStatements.length + 1;
14
- const importName = `import${importCounter}`;
15
- const importLiteral = (() => {
16
- if (exportName === '*') {
17
- return `* as ${importName}`;
18
- }
19
- if (exportName === 'default') {
20
- return importName;
21
- }
22
- return `{ ${exportName} as ${importName} }`;
23
- })();
24
- const importStatement = `import ${importLiteral} from '${importPath}';`;
25
- importStatements.push(importStatement);
26
- return { importName };
27
- }
@@ -1,2 +0,0 @@
1
- export { assertPageFilePath };
2
- declare function assertPageFilePath(filePath: string): void;
@@ -1,9 +0,0 @@
1
- // TODO/v1-release: remove
2
- export { assertPageFilePath };
3
- import { assertPosixPath } from './utils.js';
4
- function assertPageFilePath(filePath) {
5
- assertPosixPath(filePath);
6
- /* This assert() is skipped to reduce client-side bundle size
7
- assert(filePath.startsWith('/') || isNpmPackageImport(filePath), { filePath })
8
- */
9
- }
@@ -1,2 +0,0 @@
1
- export { pathJoin };
2
- declare function pathJoin(path1: string, path2: string): string;
@@ -1,17 +0,0 @@
1
- export { pathJoin };
2
- // Simple shim for `import * from "node:path"` used by the server runtime.
3
- // Robust alternative: https://github.com/unjs/pathe
4
- import { assert } from './assert.js';
5
- function pathJoin(path1, path2) {
6
- assert(!path1.includes('\\'));
7
- assert(!path2.includes('\\'));
8
- let joined = [...path1.split('/'), ...path2.split('/')].filter(Boolean).join('/');
9
- if (path1.startsWith('/'))
10
- joined = '/' + joined;
11
- return joined;
12
- }
13
- /* https://github.com/brillout/telefunc/blob/0fd44322acbd07857ae29361ba7c998607f17dd5/telefunc/utils/path-shim.ts#L17-L21
14
- function isAbsolute(filePath: string) {
15
- // ...
16
- }
17
- */
@@ -1,4 +0,0 @@
1
- export { toPosixPath };
2
- export { assertPosixPath };
3
- declare function toPosixPath(path: string): string;
4
- declare function assertPosixPath(path: string): void;
@@ -1,16 +0,0 @@
1
- export { toPosixPath };
2
- export { assertPosixPath };
3
- import { assert } from './assert.js';
4
- function toPosixPath(path) {
5
- const pathPosix = path.split('\\').join('/');
6
- assertPosixPath(pathPosix);
7
- return pathPosix;
8
- }
9
- function assertPosixPath(path) {
10
- const errMsg = (msg) => `Not a posix path: ${msg}`;
11
- assert(path !== null, errMsg('null'));
12
- assert(typeof path === 'string', errMsg(`typeof path === ${JSON.stringify(typeof path)}`));
13
- assert(path !== '', errMsg('(empty string)'));
14
- assert(path);
15
- assert(!path.includes('\\'), errMsg(path));
16
- }