vike 0.4.166 → 0.4.167

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 (97) hide show
  1. package/dist/cjs/node/plugin/plugins/buildConfig.js +11 -6
  2. package/dist/cjs/node/plugin/plugins/commonConfig/assertResolveAlias.js +2 -1
  3. package/dist/cjs/node/plugin/plugins/devConfig/determineOptimizeDeps.js +17 -22
  4. package/dist/cjs/node/plugin/plugins/envVars.js +3 -2
  5. package/dist/cjs/node/plugin/plugins/extractAssetsPlugin.js +11 -13
  6. package/dist/cjs/node/plugin/plugins/extractExportNamesPlugin.js +2 -4
  7. package/dist/cjs/node/plugin/plugins/fileEnv.js +6 -3
  8. package/dist/cjs/node/plugin/plugins/importUserCode/index.js +6 -2
  9. package/dist/cjs/node/plugin/plugins/importUserCode/v1-design/getConfigFileExport.js +3 -3
  10. package/dist/cjs/node/plugin/plugins/importUserCode/v1-design/getVikeConfig/loadFileAtConfigTime.js +5 -1
  11. package/dist/cjs/node/plugin/plugins/importUserCode/v1-design/getVikeConfig/resolveImportPath.js +21 -17
  12. package/dist/cjs/node/plugin/plugins/importUserCode/v1-design/getVikeConfig/transpileAndExecuteFile.js +12 -11
  13. package/dist/cjs/node/plugin/plugins/importUserCode/v1-design/getVikeConfig.js +6 -2
  14. package/dist/cjs/node/plugin/shared/getFilePath.js +83 -29
  15. package/dist/cjs/node/plugin/shared/isErrorDebug.js +1 -1
  16. package/dist/cjs/node/plugin/shared/loggerNotProd/errorWithCodeSnippet.js +3 -8
  17. package/dist/cjs/node/plugin/shared/loggerNotProd.js +2 -1
  18. package/dist/cjs/node/plugin/utils.js +1 -1
  19. package/dist/cjs/node/prerender/runPrerender.js +6 -7
  20. package/dist/cjs/node/prerender/utils.js +2 -1
  21. package/dist/cjs/node/runtime/html/stream.js +5 -5
  22. package/dist/cjs/node/runtime/renderPage/executeOnBeforeRenderAndDataHooks.js +3 -3
  23. package/dist/cjs/node/runtime/renderPage/executeOnRenderHtmlHook.js +2 -1
  24. package/dist/cjs/node/runtime/renderPage/getPageAssets/getManifestEntry.js +5 -9
  25. package/dist/cjs/node/runtime/renderPage/getPageAssets/retrieveAssetsProd.js +9 -8
  26. package/dist/cjs/node/runtime/renderPage/getPageAssets.js +6 -12
  27. package/dist/cjs/node/runtime/utils.js +0 -1
  28. package/dist/cjs/shared/page-configs/assertPlusFileExport.js +1 -3
  29. package/dist/cjs/shared/route/abort.js +2 -1
  30. package/dist/cjs/shared/route/executeGuardHook.js +2 -1
  31. package/dist/cjs/shared/route/executeOnBeforeRouteHook.js +2 -1
  32. package/dist/cjs/shared/route/index.js +2 -3
  33. package/dist/cjs/shared/route/utils.js +0 -1
  34. package/dist/cjs/utils/assertIsNotProductionRuntime.js +5 -5
  35. package/dist/cjs/utils/assertPathIsFilesystemAbsolute.js +1 -0
  36. package/dist/cjs/utils/debug.js +48 -14
  37. package/dist/cjs/utils/isNpmPackage.js +11 -2
  38. package/dist/cjs/utils/projectInfo.js +1 -1
  39. package/dist/cjs/utils/trackLogs.js +1 -1
  40. package/dist/esm/client/client-routing-runtime/renderPageClientSide.js +31 -24
  41. package/dist/esm/node/plugin/plugins/buildConfig.js +12 -7
  42. package/dist/esm/node/plugin/plugins/commonConfig/assertResolveAlias.js +2 -1
  43. package/dist/esm/node/plugin/plugins/devConfig/determineOptimizeDeps.js +18 -23
  44. package/dist/esm/node/plugin/plugins/envVars.js +4 -3
  45. package/dist/esm/node/plugin/plugins/extractAssetsPlugin.js +12 -14
  46. package/dist/esm/node/plugin/plugins/extractExportNamesPlugin.js +3 -5
  47. package/dist/esm/node/plugin/plugins/fileEnv.js +7 -4
  48. package/dist/esm/node/plugin/plugins/importUserCode/index.js +7 -3
  49. package/dist/esm/node/plugin/plugins/importUserCode/v1-design/debug.d.ts +1 -1
  50. package/dist/esm/node/plugin/plugins/importUserCode/v1-design/getConfigFileExport.js +4 -4
  51. package/dist/esm/node/plugin/plugins/importUserCode/v1-design/getVikeConfig/loadFileAtConfigTime.js +5 -1
  52. package/dist/esm/node/plugin/plugins/importUserCode/v1-design/getVikeConfig/resolveImportPath.js +21 -17
  53. package/dist/esm/node/plugin/plugins/importUserCode/v1-design/getVikeConfig/transpileAndExecuteFile.js +12 -11
  54. package/dist/esm/node/plugin/plugins/importUserCode/v1-design/getVikeConfig.js +6 -2
  55. package/dist/esm/node/plugin/shared/getFilePath.d.ts +10 -9
  56. package/dist/esm/node/plugin/shared/getFilePath.js +83 -29
  57. package/dist/esm/node/plugin/shared/isErrorDebug.js +2 -2
  58. package/dist/esm/node/plugin/shared/loggerNotProd/errorWithCodeSnippet.js +4 -9
  59. package/dist/esm/node/plugin/shared/loggerNotProd.js +2 -1
  60. package/dist/esm/node/plugin/utils.d.ts +1 -1
  61. package/dist/esm/node/plugin/utils.js +1 -1
  62. package/dist/esm/node/prerender/runPrerender.js +2 -3
  63. package/dist/esm/node/prerender/utils.d.ts +2 -1
  64. package/dist/esm/node/prerender/utils.js +2 -1
  65. package/dist/esm/node/runtime/html/stream.js +5 -5
  66. package/dist/esm/node/runtime/renderPage/executeOnBeforeRenderAndDataHooks.js +1 -1
  67. package/dist/esm/node/runtime/renderPage/executeOnRenderHtmlHook.js +2 -1
  68. package/dist/esm/node/runtime/renderPage/getPageAssets/getManifestEntry.js +6 -10
  69. package/dist/esm/node/runtime/renderPage/getPageAssets/retrieveAssetsProd.js +9 -8
  70. package/dist/esm/node/runtime/renderPage/getPageAssets.js +7 -13
  71. package/dist/esm/node/runtime/utils.d.ts +0 -1
  72. package/dist/esm/node/runtime/utils.js +0 -1
  73. package/dist/esm/shared/page-configs/FilePath.d.ts +41 -29
  74. package/dist/esm/shared/page-configs/assertPlusFileExport.js +1 -3
  75. package/dist/esm/shared/route/abort.js +2 -1
  76. package/dist/esm/shared/route/executeGuardHook.js +2 -1
  77. package/dist/esm/shared/route/executeOnBeforeRouteHook.js +2 -1
  78. package/dist/esm/shared/route/index.js +2 -3
  79. package/dist/esm/shared/route/utils.d.ts +0 -1
  80. package/dist/esm/shared/route/utils.js +0 -1
  81. package/dist/esm/utils/assertIsNotProductionRuntime.js +5 -5
  82. package/dist/esm/utils/assertPathIsFilesystemAbsolute.js +1 -0
  83. package/dist/esm/utils/debug.d.ts +5 -4
  84. package/dist/esm/utils/debug.js +45 -14
  85. package/dist/esm/utils/debugGlob.d.ts +1 -1
  86. package/dist/esm/utils/isNpmPackage.d.ts +5 -1
  87. package/dist/esm/utils/isNpmPackage.js +10 -1
  88. package/dist/esm/utils/projectInfo.d.ts +2 -2
  89. package/dist/esm/utils/projectInfo.js +1 -1
  90. package/dist/esm/utils/trackLogs.js +2 -2
  91. package/package.json +1 -1
  92. package/dist/cjs/node/runtime/renderPage/getPageAssets/assertClientEntryId.js +0 -19
  93. package/dist/cjs/utils/getFilePathAbsolute.js +0 -70
  94. package/dist/esm/node/runtime/renderPage/getPageAssets/assertClientEntryId.d.ts +0 -2
  95. package/dist/esm/node/runtime/renderPage/getPageAssets/assertClientEntryId.js +0 -16
  96. package/dist/esm/utils/getFilePathAbsolute.d.ts +0 -5
  97. package/dist/esm/utils/getFilePathAbsolute.js +0 -64
@@ -23,9 +23,7 @@ function assertPlusFileExport(fileExports, filePathToShowToUser, configName) {
23
23
  }
24
24
  else {
25
25
  assert(exportsAll.length === 2); // because `exportsInvalid.length === 0`
26
- assertWarning(false, `${filePathToShowToUser} remove ${exportNamed} or ${exportDefault}`, {
27
- onlyOnce: true
28
- });
26
+ assertWarning(false, `The exports of ${filePathToShowToUser} are ambiguous: remove ${exportDefault} or ${exportNamed}`, { onlyOnce: true });
29
27
  }
30
28
  }
31
29
  else {
@@ -7,7 +7,8 @@ export { logAbortErrorHandled };
7
7
  export { getPageContextFromAllRewrites };
8
8
  export { AbortRender };
9
9
  export { assertNoInfiniteAbortLoop };
10
- import { assert, assertInfo, assertUsage, assertWarning, checkType, hasProp, isUriWithProtocol, isUserHookError, joinEnglish, objectAssign, truncateString } from './utils.js';
10
+ import { isUserHookError } from '../hooks/executeHook.js';
11
+ import { assert, assertInfo, assertUsage, assertWarning, checkType, hasProp, isUriWithProtocol, joinEnglish, objectAssign, truncateString } from './utils.js';
11
12
  import pc from '@brillout/picocolors';
12
13
  /**
13
14
  * Abort the rendering of the current page, and redirect the user to another URL instead.
@@ -1,6 +1,7 @@
1
1
  export { executeGuardHook };
2
2
  import { getHook, getHookTimeoutDefault } from '../hooks/getHook.js';
3
- import { assert, assertUsage, executeHook, isCallable } from './utils.js';
3
+ import { assert, assertUsage, isCallable } from './utils.js';
4
+ import { executeHook } from '../hooks/executeHook.js';
4
5
  const errIntro = 'The guard() hook defined by';
5
6
  async function executeGuardHook(pageContext, prepareForUserConsumption) {
6
7
  let hook;
@@ -1,8 +1,9 @@
1
1
  export { executeOnBeforeRouteHook };
2
2
  import { assertPageContextProvidedByUser } from '../assertPageContextProvidedByUser.js';
3
- import { assertUsage, hasProp, isObjectWithKeys, objectAssign, assertWarning, assertUsageUrl, joinEnglish, assert, executeHook } from './utils.js';
3
+ import { assertUsage, hasProp, isObjectWithKeys, objectAssign, assertWarning, assertUsageUrl, joinEnglish, assert } from './utils.js';
4
4
  import { assertRouteParams, assertSyncRouting } from './resolveRouteFunction.js';
5
5
  import pc from '@brillout/picocolors';
6
+ import { executeHook } from '../hooks/executeHook.js';
6
7
  async function executeOnBeforeRouteHook(pageContext) {
7
8
  const pageContextFromOnBeforeRouteHook = {};
8
9
  if (!pageContext._onBeforeRouteHook)
@@ -34,9 +34,8 @@ async function route(pageContextForRoute) {
34
34
  objectAssign(pageContext, pageContextFromOnBeforeRouteHook);
35
35
  // Vike's routing
36
36
  const allPageIds = pageContext._allPageIds;
37
- assert(allPageIds.length >= 0);
38
- assertUsage(pageContext._pageFilesAll.length > 0 || pageContext._pageConfigs.length > 0, 'No *.page.js file found. You must create at least one *.page.js file.');
39
- assertUsage(allPageIds.length > 0, "You must create at least one *.page.js file that isn't _default.page.*");
37
+ assertUsage(allPageIds.length > 0, 'No page found. You must create at least one page.');
38
+ assert(pageContext._pageFilesAll.length > 0 || pageContext._pageConfigs.length > 0);
40
39
  const { urlPathname } = pageContext;
41
40
  assert(urlPathname.startsWith('/'));
42
41
  const routeMatches = [];
@@ -10,7 +10,6 @@ export * from '../../utils/isStringRecord.js';
10
10
  export * from '../../utils/unique.js';
11
11
  export * from '../../utils/isBrowser.js';
12
12
  export * from '../../utils/parseUrl.js';
13
- export * from '../hooks/executeHook.js';
14
13
  export * from '../../utils/checkType.js';
15
14
  export * from '../../utils/joinEnglish.js';
16
15
  export * from '../../utils/projectInfo.js';
@@ -19,7 +19,6 @@ export * from '../../utils/isStringRecord.js';
19
19
  export * from '../../utils/unique.js';
20
20
  export * from '../../utils/isBrowser.js';
21
21
  export * from '../../utils/parseUrl.js';
22
- export * from '../hooks/executeHook.js';
23
22
  export * from '../../utils/checkType.js';
24
23
  export * from '../../utils/joinEnglish.js';
25
24
  export * from '../../utils/projectInfo.js';
@@ -16,31 +16,31 @@ const vikeVitePluginLoadedInProductionError = `Loading Vike's Vite plugin (the v
16
16
  const env = getGlobalObject('utils/assertIsNotProductionRuntime.ts', {});
17
17
  // Called by Vike modules that want to ensure that they aren't loaded by the server runtime in production
18
18
  function assertIsNotProductionRuntime() {
19
- if (debug.isEnabled)
19
+ if (debug.isActivated)
20
20
  debug('assertIsNotProductionRuntime()', new Error().stack);
21
21
  env.shouldNotBeProduction = true;
22
22
  }
23
23
  // Called by Vite hook configureServer()
24
24
  function markEnvAsViteDev() {
25
- if (debug.isEnabled)
25
+ if (debug.isActivated)
26
26
  debug('markEnvAsViteDev()', new Error().stack);
27
27
  env.isViteDev = true;
28
28
  }
29
29
  // Called by Vite hook configurePreviewServer()
30
30
  function markEnvAsVitePreview() {
31
- if (debug.isEnabled)
31
+ if (debug.isActivated)
32
32
  debug('markEnvAsVitePreview()', new Error().stack);
33
33
  env.isVitePreview = true;
34
34
  }
35
35
  // Called by ../node/plugin/index.ts
36
36
  function markEnvAsVikePluginLoaded() {
37
- if (debug.isEnabled)
37
+ if (debug.isActivated)
38
38
  debug('markEnvAsVikePluginLoaded()', new Error().stack);
39
39
  env.isVikePluginLoaded = true;
40
40
  }
41
41
  // Called by ../node/runtime/index.ts
42
42
  function assertEnv() {
43
- if (debug.isEnabled)
43
+ if (debug.isActivated)
44
44
  debug('assertEnv()', new Error().stack);
45
45
  if (isVitest())
46
46
  return;
@@ -5,6 +5,7 @@ import { assertPosixPath } from './filesystemPathHandling.js';
5
5
  /** Assert path is absolute from the filesystem root */
6
6
  function assertPathIsFilesystemAbsolute(p) {
7
7
  assertPosixPath(p);
8
+ assert(!p.startsWith('/@fs/'));
8
9
  if (process.platform === 'win32') {
9
10
  assert(path.win32.isAbsolute(p));
10
11
  }
@@ -1,7 +1,8 @@
1
1
  export { createDebugger };
2
- export { isDebugEnabled };
2
+ export { isDebugActivated };
3
3
  export type { Debug };
4
- type Flag = 'vike:routing' | 'vike:error' | 'vike:stream' | 'vike:log' | 'vike:virtual-files' | 'vike:outDir' | 'vike:extractExportNames' | 'vike:extractAssets' | 'vike:glob' | 'vike:pageFiles' | 'vike:setup' | 'vike:pointer-imports';
4
+ declare const flags: readonly ["vike:error", "vike:extractAssets", "vike:extractExportNames", "vike:glob", "vike:log", "vike:optimizeDeps", "vike:outDir", "vike:pageFiles", "vike:pointer-imports", "vike:routing", "vike:setup", "vike:stream", "vike:virtual-files"];
5
+ type Flag = (typeof flags)[number];
5
6
  type Debug = ReturnType<typeof createDebugger>;
6
7
  type Options = {
7
8
  serialization?: {
@@ -10,6 +11,6 @@ type Options = {
10
11
  };
11
12
  declare function createDebugger(flag: Flag, optionsGlobal?: Options): ((...msgs: unknown[]) => void) & {
12
13
  options: (optionsLocal: Options) => (...msgs: unknown[]) => void;
13
- isEnabled: boolean;
14
+ isActivated: boolean;
14
15
  };
15
- declare function isDebugEnabled(flag: Flag): boolean;
16
+ declare function isDebugActivated(flag: Flag): boolean;
@@ -1,16 +1,35 @@
1
1
  export { createDebugger };
2
- export { isDebugEnabled };
2
+ export { isDebugActivated };
3
3
  import { isBrowser } from './isBrowser.js';
4
4
  import { isCallable } from './isCallable.js';
5
5
  import { objectAssign } from './objectAssign.js';
6
- import { assert } from './assert.js';
6
+ import { assert, assertUsage } from './assert.js';
7
7
  import { checkType } from './checkType.js';
8
8
  import { getTerminalWidth } from './getTerminWidth.js';
9
+ import pc from '@brillout/picocolors';
9
10
  // Avoid this to be loaded in the browser. For isomorphic code: instead of `import { createDebugger } from './utils.js'`, use `globalThis.createDebugger()`.
10
11
  assert(!isBrowser());
11
12
  globalThis.__brillout_debug_createDebugger = createDebugger;
13
+ const flags = [
14
+ 'vike:error',
15
+ 'vike:extractAssets',
16
+ 'vike:extractExportNames',
17
+ 'vike:glob',
18
+ 'vike:log',
19
+ 'vike:optimizeDeps',
20
+ 'vike:outDir',
21
+ 'vike:pageFiles',
22
+ 'vike:pointer-imports',
23
+ 'vike:routing',
24
+ 'vike:setup',
25
+ 'vike:stream',
26
+ 'vike:virtual-files'
27
+ ];
28
+ const flagRegex = /\bvike:[a-zA-Z-]+/g;
29
+ assertDEBUG();
12
30
  function createDebugger(flag, optionsGlobal) {
13
31
  checkType(flag);
32
+ assert(flags.includes(flag));
14
33
  const debugWithOptions = (optionsLocal) => {
15
34
  return (...msgs) => {
16
35
  const options = { ...optionsGlobal, ...optionsLocal };
@@ -18,11 +37,11 @@ function createDebugger(flag, optionsGlobal) {
18
37
  };
19
38
  };
20
39
  const debug = (...msgs) => debugWithOptions({})(...msgs);
21
- objectAssign(debug, { options: debugWithOptions, isEnabled: isDebugEnabled(flag) });
40
+ objectAssign(debug, { options: debugWithOptions, isActivated: isDebugActivated(flag) });
22
41
  return debug;
23
42
  }
24
43
  function debug_(flag, options, ...msgs) {
25
- if (!isDebugEnabled(flag))
44
+ if (!isDebugActivated(flag))
26
45
  return;
27
46
  let [msgFirst, ...msgsRest] = msgs;
28
47
  const padding = ' '.repeat(flag.length + 1);
@@ -47,17 +66,12 @@ function debug_(flag, options, ...msgs) {
47
66
  console.log(msg);
48
67
  });
49
68
  }
50
- function isDebugEnabled(flag) {
69
+ function isDebugActivated(flag) {
51
70
  checkType(flag);
52
- let DEBUG;
53
- // - `process` can be undefined in edge workers
54
- // - We want bundlers to be able to statically replace `process.env.*`
55
- try {
56
- DEBUG = process.env.DEBUG;
57
- }
58
- catch { }
59
- const isEnabled = DEBUG?.includes(flag) ?? false;
60
- return isEnabled;
71
+ assert(flags.includes(flag));
72
+ const DEBUG = getDEBUG();
73
+ const isActivated = DEBUG?.includes(flag) ?? false;
74
+ return isActivated;
61
75
  }
62
76
  function formatMsg(info, options, padding, position) {
63
77
  if (info === undefined) {
@@ -119,3 +133,20 @@ function replaceFunctionSerializer(_key, value) {
119
133
  }
120
134
  return value;
121
135
  }
136
+ function assertDEBUG() {
137
+ const DEBUG = getDEBUG() ?? '';
138
+ const flagsActivated = DEBUG.match(flagRegex) ?? [];
139
+ flagsActivated.forEach((flag) => {
140
+ assertUsage(flags.includes(flag), `Unknown DEBUG flag ${pc.cyan(flag)}. Valid flags:\n${flags.map((f) => ` ${pc.cyan(f)}`).join('\n')}`);
141
+ });
142
+ }
143
+ function getDEBUG() {
144
+ let DEBUG;
145
+ // - `process` can be undefined in edge workers
146
+ // - We want bundlers to be able to statically replace `process.env.*`
147
+ try {
148
+ DEBUG = process.env.DEBUG;
149
+ }
150
+ catch { }
151
+ return DEBUG;
152
+ }
@@ -4,5 +4,5 @@ export declare const debugGlob: ((...msgs: unknown[]) => void) & {
4
4
  emptyArray?: string | undefined;
5
5
  } | undefined;
6
6
  }) => (...msgs: unknown[]) => void;
7
- isEnabled: boolean;
7
+ isActivated: boolean;
8
8
  };
@@ -1,8 +1,12 @@
1
1
  export { isNpmPackageImport };
2
+ export { assertIsNpmPackageImport };
2
3
  export { isValidPathAlias };
3
4
  export { parse };
4
5
  export { isDistinguishable };
5
- declare function isNpmPackageImport(str: string): boolean;
6
+ declare function isNpmPackageImport(str: string, { cannotBePathAlias }: {
7
+ cannotBePathAlias: true;
8
+ }): boolean;
9
+ declare function assertIsNpmPackageImport(str: string): void;
6
10
  declare function isValidPathAlias(alias: string): boolean;
7
11
  declare function isDistinguishable(alias: string): boolean;
8
12
  declare function parse(str: string | undefined): null | {
@@ -1,4 +1,5 @@
1
1
  export { isNpmPackageImport };
2
+ export { assertIsNpmPackageImport };
2
3
  export { isValidPathAlias };
3
4
  /* Currently not used
4
5
  export { isNpmPackageName }
@@ -11,10 +12,18 @@ export { isDistinguishable };
11
12
  import { assert } from './assert.js';
12
13
  import { assertIsNotBrowser } from './assertIsNotBrowser.js';
13
14
  assertIsNotBrowser();
14
- function isNpmPackageImport(str) {
15
+ function isNpmPackageImport(str, { cannotBePathAlias }) {
16
+ // We cannot distinguish path alises that look like npm package imports
17
+ assert(cannotBePathAlias);
15
18
  const res = parse(str);
16
19
  return res !== null;
17
20
  }
21
+ function assertIsNpmPackageImport(str) {
22
+ assert(isNpmPackageImport(str, {
23
+ // If `str` is a path alias that looks like an npm package => assertIsNpmPackageImport() is erroneous but that's okay because the assertion will eventually fail for some other user using a disambiguated path alias.
24
+ cannotBePathAlias: true
25
+ }));
26
+ }
18
27
  function isNpmPackageName(str) {
19
28
  const res = parse(str);
20
29
  return res !== null && res.importPath === null;
@@ -1,7 +1,7 @@
1
1
  export { projectInfo };
2
2
  export { PROJECT_VERSION };
3
- declare const PROJECT_VERSION: "0.4.166";
3
+ declare const PROJECT_VERSION: "0.4.167";
4
4
  declare const projectInfo: {
5
5
  projectName: "Vike";
6
- projectVersion: "0.4.166";
6
+ projectVersion: "0.4.167";
7
7
  };
@@ -1,6 +1,6 @@
1
1
  export { projectInfo };
2
2
  export { PROJECT_VERSION };
3
- const PROJECT_VERSION = '0.4.166';
3
+ const PROJECT_VERSION = '0.4.167';
4
4
  const projectInfo = {
5
5
  projectName: 'Vike',
6
6
  projectVersion: PROJECT_VERSION
@@ -1,8 +1,8 @@
1
- import { isDebugEnabled } from './debug.js';
1
+ import { isDebugActivated } from './debug.js';
2
2
  import pc from '@brillout/picocolors';
3
3
  import { assertIsNotBrowser } from './assertIsNotBrowser.js';
4
4
  assertIsNotBrowser();
5
- if (isDebugEnabled('vike:log')) {
5
+ if (isDebugActivated('vike:log')) {
6
6
  trackLogs();
7
7
  }
8
8
  // https://stackoverflow.com/questions/45395369/how-to-get-console-log-line-numbers-shown-in-nodejs/75109905#75109905
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "vike",
3
- "version": "0.4.166",
3
+ "version": "0.4.167",
4
4
  "scripts": {
5
5
  "dev": "tsc --watch",
6
6
  "build": "rimraf dist/ && pnpm run build:esm && pnpm run build:cjs",
@@ -1,19 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.assertClientEntryId = void 0;
4
- const utils_js_1 = require("../../utils.js");
5
- const virtualFilePageConfigValuesAll_js_1 = require("../../../shared/virtual-files/virtualFilePageConfigValuesAll.js");
6
- function assertClientEntryId(id) {
7
- (0, utils_js_1.assertPosixPath)(id);
8
- (0, utils_js_1.assert)(!id.startsWith('/@fs'), id);
9
- (0, utils_js_1.assert)(
10
- // Client entry
11
- id.startsWith('@@vike/') ||
12
- // User files
13
- id.startsWith('/') ||
14
- // Page code importer
15
- (0, virtualFilePageConfigValuesAll_js_1.isVirtualFileIdPageConfigValuesAll)(id) ||
16
- // Import
17
- (0, utils_js_1.isNpmPackageImport)(id), id);
18
- }
19
- exports.assertClientEntryId = assertClientEntryId;
@@ -1,70 +0,0 @@
1
- "use strict";
2
- var __importDefault = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
4
- };
5
- Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.getFilePathAbsoluteUserRootDir = exports.getFilePathAbsoluteFilesystem = void 0;
7
- const filesystemPathHandling_js_1 = require("./filesystemPathHandling.js");
8
- const assert_js_1 = require("./assert.js");
9
- const path_1 = __importDefault(require("path"));
10
- const assertIsNotProductionRuntime_js_1 = require("./assertIsNotProductionRuntime.js");
11
- const isNpmPackage_js_1 = require("./isNpmPackage.js");
12
- const assertPathIsFilesystemAbsolute_js_1 = require("./assertPathIsFilesystemAbsolute.js");
13
- const module_1 = require("module");
14
- // @ts-ignore Shimmed by dist-cjs-fixup.js for CJS build.
15
- const importMetaUrl = `file://${__filename}`;
16
- const require_ = (0, module_1.createRequire)(importMetaUrl);
17
- (0, assertIsNotProductionRuntime_js_1.assertIsNotProductionRuntime)();
18
- // Vite handles paths such as /pages/index.page.js which are relative to `config.root`.
19
- // Make them absolute starting from the filesystem root.
20
- // Also resolve plus files living in npm packages such as restack/renderer/+onRenderHtml.js
21
- function getFilePathAbsoluteFilesystem(filePath, config) {
22
- (0, filesystemPathHandling_js_1.assertPosixPath)(filePath);
23
- if (filePath.startsWith('/@fs/')) {
24
- return filePath;
25
- }
26
- let filePathUnresolved;
27
- if ((0, isNpmPackage_js_1.isNpmPackageImport)(filePath)) {
28
- filePathUnresolved = filePath;
29
- }
30
- else {
31
- (0, assert_js_1.assert)(filePath.startsWith('/'));
32
- const { root } = config;
33
- (0, assertPathIsFilesystemAbsolute_js_1.assertPathIsFilesystemAbsolute)(root);
34
- filePathUnresolved = path_1.default.posix.join(root, filePath);
35
- (0, assertPathIsFilesystemAbsolute_js_1.assertPathIsFilesystemAbsolute)(filePathUnresolved);
36
- }
37
- let filePathAbsoluteFilesystem;
38
- try {
39
- filePathAbsoluteFilesystem = require_.resolve(filePathUnresolved, { paths: [config.root] });
40
- }
41
- catch (err) {
42
- console.error(err);
43
- (0, assert_js_1.assert)(false);
44
- }
45
- filePathAbsoluteFilesystem = (0, filesystemPathHandling_js_1.toPosixPath)(filePathAbsoluteFilesystem);
46
- (0, assertPathIsFilesystemAbsolute_js_1.assertPathIsFilesystemAbsolute)(filePathAbsoluteFilesystem);
47
- return filePathAbsoluteFilesystem;
48
- }
49
- exports.getFilePathAbsoluteFilesystem = getFilePathAbsoluteFilesystem;
50
- function getFilePathAbsoluteUserRootDir(filePathAbsoluteFilesystem, userRootDir, alwaysRelative = false) {
51
- (0, filesystemPathHandling_js_1.assertPosixPath)(filePathAbsoluteFilesystem);
52
- (0, filesystemPathHandling_js_1.assertPosixPath)(userRootDir);
53
- let filePathAbsoluteUserRootDir = path_1.default.posix.relative(userRootDir, filePathAbsoluteFilesystem);
54
- if (filePathAbsoluteFilesystem.startsWith(userRootDir)) {
55
- (0, assert_js_1.assert)(!filePathAbsoluteUserRootDir.startsWith('.') && !filePathAbsoluteUserRootDir.startsWith('/'),
56
- // Surprinsingly, this assertion seem to fail sometimes: https://github.com/vikejs/vike/issues/1139
57
- { filePathAbsoluteUserRootDir, filePathAbsoluteFilesystem, userRootDir });
58
- filePathAbsoluteUserRootDir = `/${filePathAbsoluteUserRootDir}`;
59
- return filePathAbsoluteUserRootDir;
60
- }
61
- else {
62
- if (alwaysRelative) {
63
- return filePathAbsoluteUserRootDir;
64
- }
65
- else {
66
- return filePathAbsoluteFilesystem;
67
- }
68
- }
69
- }
70
- exports.getFilePathAbsoluteUserRootDir = getFilePathAbsoluteUserRootDir;
@@ -1,2 +0,0 @@
1
- export { assertClientEntryId };
2
- declare function assertClientEntryId(id: string): void;
@@ -1,16 +0,0 @@
1
- export { assertClientEntryId };
2
- import { assert, assertPosixPath, isNpmPackageImport } from '../../utils.js';
3
- import { isVirtualFileIdPageConfigValuesAll } from '../../../shared/virtual-files/virtualFilePageConfigValuesAll.js';
4
- function assertClientEntryId(id) {
5
- assertPosixPath(id);
6
- assert(!id.startsWith('/@fs'), id);
7
- assert(
8
- // Client entry
9
- id.startsWith('@@vike/') ||
10
- // User files
11
- id.startsWith('/') ||
12
- // Page code importer
13
- isVirtualFileIdPageConfigValuesAll(id) ||
14
- // Import
15
- isNpmPackageImport(id), id);
16
- }
@@ -1,5 +0,0 @@
1
- export { getFilePathAbsoluteFilesystem };
2
- export { getFilePathAbsoluteUserRootDir };
3
- import type { ResolvedConfig } from 'vite';
4
- declare function getFilePathAbsoluteFilesystem(filePath: string, config: ResolvedConfig): string;
5
- declare function getFilePathAbsoluteUserRootDir(filePathAbsoluteFilesystem: string, userRootDir: string, alwaysRelative?: boolean): string;
@@ -1,64 +0,0 @@
1
- export { getFilePathAbsoluteFilesystem };
2
- export { getFilePathAbsoluteUserRootDir };
3
- import { assertPosixPath, toPosixPath } from './filesystemPathHandling.js';
4
- import { assert } from './assert.js';
5
- import path from 'path';
6
- import { assertIsNotProductionRuntime } from './assertIsNotProductionRuntime.js';
7
- import { isNpmPackageImport } from './isNpmPackage.js';
8
- import { assertPathIsFilesystemAbsolute } from './assertPathIsFilesystemAbsolute.js';
9
- import { createRequire } from 'module';
10
- // @ts-ignore Shimmed by dist-cjs-fixup.js for CJS build.
11
- const importMetaUrl = import.meta.url;
12
- const require_ = createRequire(importMetaUrl);
13
- assertIsNotProductionRuntime();
14
- // Vite handles paths such as /pages/index.page.js which are relative to `config.root`.
15
- // Make them absolute starting from the filesystem root.
16
- // Also resolve plus files living in npm packages such as restack/renderer/+onRenderHtml.js
17
- function getFilePathAbsoluteFilesystem(filePath, config) {
18
- assertPosixPath(filePath);
19
- if (filePath.startsWith('/@fs/')) {
20
- return filePath;
21
- }
22
- let filePathUnresolved;
23
- if (isNpmPackageImport(filePath)) {
24
- filePathUnresolved = filePath;
25
- }
26
- else {
27
- assert(filePath.startsWith('/'));
28
- const { root } = config;
29
- assertPathIsFilesystemAbsolute(root);
30
- filePathUnresolved = path.posix.join(root, filePath);
31
- assertPathIsFilesystemAbsolute(filePathUnresolved);
32
- }
33
- let filePathAbsoluteFilesystem;
34
- try {
35
- filePathAbsoluteFilesystem = require_.resolve(filePathUnresolved, { paths: [config.root] });
36
- }
37
- catch (err) {
38
- console.error(err);
39
- assert(false);
40
- }
41
- filePathAbsoluteFilesystem = toPosixPath(filePathAbsoluteFilesystem);
42
- assertPathIsFilesystemAbsolute(filePathAbsoluteFilesystem);
43
- return filePathAbsoluteFilesystem;
44
- }
45
- function getFilePathAbsoluteUserRootDir(filePathAbsoluteFilesystem, userRootDir, alwaysRelative = false) {
46
- assertPosixPath(filePathAbsoluteFilesystem);
47
- assertPosixPath(userRootDir);
48
- let filePathAbsoluteUserRootDir = path.posix.relative(userRootDir, filePathAbsoluteFilesystem);
49
- if (filePathAbsoluteFilesystem.startsWith(userRootDir)) {
50
- assert(!filePathAbsoluteUserRootDir.startsWith('.') && !filePathAbsoluteUserRootDir.startsWith('/'),
51
- // Surprinsingly, this assertion seem to fail sometimes: https://github.com/vikejs/vike/issues/1139
52
- { filePathAbsoluteUserRootDir, filePathAbsoluteFilesystem, userRootDir });
53
- filePathAbsoluteUserRootDir = `/${filePathAbsoluteUserRootDir}`;
54
- return filePathAbsoluteUserRootDir;
55
- }
56
- else {
57
- if (alwaysRelative) {
58
- return filePathAbsoluteUserRootDir;
59
- }
60
- else {
61
- return filePathAbsoluteFilesystem;
62
- }
63
- }
64
- }