vike 0.4.161 → 0.4.162-commit-8995471

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 (159) hide show
  1. package/dist/cjs/__internal/index.js +2 -2
  2. package/dist/cjs/node/plugin/index.js +0 -2
  3. package/dist/cjs/node/plugin/plugins/buildConfig.js +41 -37
  4. package/dist/cjs/node/plugin/plugins/config/index.js +2 -7
  5. package/dist/cjs/node/plugin/plugins/devConfig/determineFsAllowList.js +1 -8
  6. package/dist/cjs/node/plugin/plugins/devConfig/determineOptimizeDeps.js +1 -18
  7. package/dist/cjs/node/plugin/plugins/devConfig/index.js +2 -4
  8. package/dist/cjs/node/plugin/plugins/envVars.js +6 -2
  9. package/dist/cjs/node/plugin/plugins/extractAssetsPlugin.js +10 -22
  10. package/dist/cjs/node/plugin/plugins/extractExportNamesPlugin.js +2 -2
  11. package/dist/cjs/node/plugin/plugins/importBuild/getVikeManifest.js +1 -21
  12. package/dist/cjs/node/plugin/plugins/importBuild/index.js +1 -1
  13. package/dist/cjs/node/plugin/plugins/importUserCode/getVirtualFileImportUserCode.js +29 -95
  14. package/dist/cjs/node/plugin/plugins/importUserCode/index.js +8 -8
  15. package/dist/cjs/node/plugin/plugins/importUserCode/v1-design/getConfigValuesSerialized.js +1 -9
  16. package/dist/cjs/node/plugin/plugins/importUserCode/v1-design/getVikeConfig/configDefinitionsBuiltIn.js +3 -0
  17. package/dist/cjs/node/plugin/plugins/importUserCode/v1-design/getVikeConfig/filesystemRouting.js +1 -1
  18. package/dist/cjs/node/plugin/plugins/importUserCode/v1-design/getVikeConfig/loadFileAtConfigTime.js +4 -4
  19. package/dist/cjs/node/plugin/plugins/importUserCode/v1-design/getVikeConfig/resolveImportPath.js +1 -1
  20. package/dist/cjs/node/plugin/plugins/importUserCode/v1-design/getVikeConfig/transformFileImports.js +35 -36
  21. package/dist/cjs/node/plugin/plugins/importUserCode/v1-design/getVikeConfig/transpileAndExecuteFile.js +109 -104
  22. package/dist/cjs/node/plugin/plugins/importUserCode/v1-design/getVikeConfig.js +39 -33
  23. package/dist/cjs/node/plugin/plugins/setGlobalContext.js +0 -14
  24. package/dist/cjs/node/plugin/shared/rollupSourceMap.js +20 -0
  25. package/dist/cjs/node/plugin/utils.js +0 -1
  26. package/dist/cjs/node/prerender/runPrerender.js +3 -2
  27. package/dist/cjs/node/prerender/utils.js +1 -1
  28. package/dist/cjs/node/runtime/globalContext.js +8 -19
  29. package/dist/cjs/node/runtime/html/serializePageContextClientSide.js +1 -0
  30. package/dist/cjs/node/runtime/renderPage/analyzePage.js +2 -2
  31. package/dist/cjs/node/runtime/renderPage/getPageAssets/assertClientEntryId.js +2 -8
  32. package/dist/cjs/node/runtime/renderPage/getPageAssets/getManifestEntry.js +6 -7
  33. package/dist/cjs/node/runtime/renderPage/getPageAssets/retrieveAssetsProd.js +2 -2
  34. package/dist/cjs/node/runtime/renderPage/getPageAssets.js +23 -28
  35. package/dist/cjs/node/runtime/renderPage/renderPageAlreadyRouted.js +2 -23
  36. package/dist/cjs/node/runtime/utils.js +1 -2
  37. package/dist/cjs/node/shared/assertPluginManifest.js +1 -4
  38. package/dist/cjs/node/shared/assertV1Design.js +26 -0
  39. package/dist/cjs/node/shared/{getClientEntryFilePath.js → getClientEntry.js} +3 -3
  40. package/dist/cjs/node/shared/prependEntriesDir.js +13 -0
  41. package/dist/cjs/node/shared/utils.js +2 -0
  42. package/dist/cjs/node/shared/virtual-files/virtualFileImportUserCode.js +1 -0
  43. package/dist/cjs/shared/hooks/getHook.js +1 -1
  44. package/dist/cjs/shared/page-configs/helpers/getConfigValue.js +1 -0
  45. package/dist/cjs/shared/page-configs/serialize/parseConfigValuesImported.js +1 -1
  46. package/dist/cjs/shared/route/abort.js +1 -0
  47. package/dist/cjs/shared/route/resolvePrecedence.js +1 -0
  48. package/dist/cjs/utils/{nodeEnv.js → assertNodeEnv.js} +3 -0
  49. package/dist/cjs/utils/formatHintLog.js +1 -0
  50. package/dist/cjs/utils/hasProp.js +1 -0
  51. package/dist/cjs/utils/isScriptFile.js +15 -4
  52. package/dist/cjs/utils/projectInfo.js +1 -1
  53. package/dist/esm/__internal/index.js +1 -1
  54. package/dist/esm/client/client-routing-runtime/renderPageClientSide.js +20 -14
  55. package/dist/esm/client/shared/getPageContextProxyForUser.js +19 -2
  56. package/dist/esm/client/shared/loadUserFilesClientSide.js +1 -0
  57. package/dist/esm/node/plugin/index.js +0 -2
  58. package/dist/esm/node/plugin/plugins/buildConfig.js +40 -36
  59. package/dist/esm/node/plugin/plugins/config/index.js +2 -7
  60. package/dist/esm/node/plugin/plugins/devConfig/determineFsAllowList.d.ts +1 -2
  61. package/dist/esm/node/plugin/plugins/devConfig/determineFsAllowList.js +1 -8
  62. package/dist/esm/node/plugin/plugins/devConfig/determineOptimizeDeps.d.ts +1 -2
  63. package/dist/esm/node/plugin/plugins/devConfig/determineOptimizeDeps.js +2 -19
  64. package/dist/esm/node/plugin/plugins/devConfig/index.js +2 -4
  65. package/dist/esm/node/plugin/plugins/envVars.js +6 -2
  66. package/dist/esm/node/plugin/plugins/extractAssetsPlugin.js +11 -23
  67. package/dist/esm/node/plugin/plugins/extractExportNamesPlugin.js +2 -2
  68. package/dist/esm/node/plugin/plugins/importBuild/getVikeManifest.d.ts +1 -2
  69. package/dist/esm/node/plugin/plugins/importBuild/getVikeManifest.js +2 -19
  70. package/dist/esm/node/plugin/plugins/importBuild/index.js +1 -1
  71. package/dist/esm/node/plugin/plugins/importUserCode/getVirtualFileImportUserCode.js +31 -97
  72. package/dist/esm/node/plugin/plugins/importUserCode/index.js +8 -8
  73. package/dist/esm/node/plugin/plugins/importUserCode/v1-design/getConfigValuesSerialized.js +1 -9
  74. package/dist/esm/node/plugin/plugins/importUserCode/v1-design/getVikeConfig/configDefinitionsBuiltIn.js +3 -0
  75. package/dist/esm/node/plugin/plugins/importUserCode/v1-design/getVikeConfig/filesystemRouting.d.ts +3 -3
  76. package/dist/esm/node/plugin/plugins/importUserCode/v1-design/getVikeConfig/filesystemRouting.js +1 -1
  77. package/dist/esm/node/plugin/plugins/importUserCode/v1-design/getVikeConfig/loadFileAtConfigTime.d.ts +1 -1
  78. package/dist/esm/node/plugin/plugins/importUserCode/v1-design/getVikeConfig/loadFileAtConfigTime.js +4 -4
  79. package/dist/esm/node/plugin/plugins/importUserCode/v1-design/getVikeConfig/resolveImportPath.js +1 -1
  80. package/dist/esm/node/plugin/plugins/importUserCode/v1-design/getVikeConfig/transformFileImports.d.ts +1 -13
  81. package/dist/esm/node/plugin/plugins/importUserCode/v1-design/getVikeConfig/transformFileImports.js +35 -36
  82. package/dist/esm/node/plugin/plugins/importUserCode/v1-design/getVikeConfig/transpileAndExecuteFile.d.ts +1 -1
  83. package/dist/esm/node/plugin/plugins/importUserCode/v1-design/getVikeConfig/transpileAndExecuteFile.js +111 -106
  84. package/dist/esm/node/plugin/plugins/importUserCode/v1-design/getVikeConfig.d.ts +3 -3
  85. package/dist/esm/node/plugin/plugins/importUserCode/v1-design/getVikeConfig.js +39 -33
  86. package/dist/esm/node/plugin/plugins/setGlobalContext.js +1 -15
  87. package/dist/esm/node/plugin/shared/rollupSourceMap.d.ts +14 -0
  88. package/dist/esm/node/plugin/shared/rollupSourceMap.js +17 -0
  89. package/dist/esm/node/plugin/utils.d.ts +0 -1
  90. package/dist/esm/node/plugin/utils.js +0 -1
  91. package/dist/esm/node/prerender/runPrerender.d.ts +3 -3
  92. package/dist/esm/node/prerender/runPrerender.js +4 -3
  93. package/dist/esm/node/prerender/utils.d.ts +1 -1
  94. package/dist/esm/node/prerender/utils.js +1 -1
  95. package/dist/esm/node/runtime/globalContext.d.ts +3 -10
  96. package/dist/esm/node/runtime/globalContext.js +7 -18
  97. package/dist/esm/node/runtime/html/serializePageContextClientSide.js +1 -0
  98. package/dist/esm/node/runtime/renderPage/analyzePage.js +2 -2
  99. package/dist/esm/node/runtime/renderPage/getPageAssets/assertClientEntryId.js +2 -8
  100. package/dist/esm/node/runtime/renderPage/getPageAssets/getManifestEntry.d.ts +1 -1
  101. package/dist/esm/node/runtime/renderPage/getPageAssets/getManifestEntry.js +6 -7
  102. package/dist/esm/node/runtime/renderPage/getPageAssets/retrieveAssetsProd.d.ts +1 -1
  103. package/dist/esm/node/runtime/renderPage/getPageAssets/retrieveAssetsProd.js +2 -2
  104. package/dist/esm/node/runtime/renderPage/getPageAssets.js +24 -29
  105. package/dist/esm/node/runtime/renderPage/renderPageAlreadyRouted.js +3 -24
  106. package/dist/esm/node/runtime/utils.d.ts +1 -2
  107. package/dist/esm/node/runtime/utils.js +1 -2
  108. package/dist/esm/node/shared/ViteManifest.d.ts +1 -0
  109. package/dist/esm/node/shared/assertPluginManifest.d.ts +0 -1
  110. package/dist/esm/node/shared/assertPluginManifest.js +2 -5
  111. package/dist/esm/node/shared/assertV1Design.d.ts +4 -0
  112. package/dist/esm/node/shared/assertV1Design.js +23 -0
  113. package/dist/esm/node/shared/getClientEntry.d.ts +3 -0
  114. package/dist/esm/node/shared/{getClientEntryFilePath.js → getClientEntry.js} +2 -2
  115. package/dist/esm/node/shared/prependEntriesDir.d.ts +2 -0
  116. package/dist/esm/node/shared/prependEntriesDir.js +10 -0
  117. package/dist/esm/node/shared/utils.d.ts +2 -0
  118. package/dist/esm/node/shared/utils.js +2 -0
  119. package/dist/esm/node/shared/virtual-files/virtualFileImportUserCode.js +1 -0
  120. package/dist/esm/shared/ConfigVike.d.ts +0 -27
  121. package/dist/esm/shared/hooks/getHook.js +2 -2
  122. package/dist/esm/shared/page-configs/Config.d.ts +5 -0
  123. package/dist/esm/shared/page-configs/PageConfig.d.ts +2 -4
  124. package/dist/esm/shared/page-configs/helpers/getConfigValue.js +1 -0
  125. package/dist/esm/shared/page-configs/serialize/parseConfigValuesImported.js +1 -1
  126. package/dist/esm/shared/route/abort.js +1 -0
  127. package/dist/esm/shared/route/resolvePrecedence.js +1 -0
  128. package/dist/esm/utils/{nodeEnv.js → assertNodeEnv.js} +3 -0
  129. package/dist/esm/utils/debug.d.ts +1 -1
  130. package/dist/esm/utils/formatHintLog.js +1 -0
  131. package/dist/esm/utils/hasProp.js +1 -0
  132. package/dist/esm/utils/isScriptFile.d.ts +3 -1
  133. package/dist/esm/utils/isScriptFile.js +14 -3
  134. package/dist/esm/utils/projectInfo.d.ts +2 -2
  135. package/dist/esm/utils/projectInfo.js +1 -1
  136. package/package.json +4 -3
  137. package/dist/cjs/node/plugin/plugins/config/findConfigVikeFromStemPackages.js +0 -27
  138. package/dist/cjs/node/plugin/plugins/config/resolveExtensions.js +0 -107
  139. package/dist/cjs/node/plugin/plugins/config/stemUtils.js +0 -85
  140. package/dist/cjs/node/plugin/plugins/extensionsAssets.js +0 -101
  141. package/dist/cjs/node/plugin/shared/removeSourceMap.js +0 -12
  142. package/dist/cjs/utils/getDependencyPackageJson.js +0 -91
  143. package/dist/cjs/utils/isStemPackageName.js +0 -14
  144. package/dist/esm/node/plugin/plugins/config/findConfigVikeFromStemPackages.d.ts +0 -3
  145. package/dist/esm/node/plugin/plugins/config/findConfigVikeFromStemPackages.js +0 -24
  146. package/dist/esm/node/plugin/plugins/config/resolveExtensions.d.ts +0 -4
  147. package/dist/esm/node/plugin/plugins/config/resolveExtensions.js +0 -101
  148. package/dist/esm/node/plugin/plugins/config/stemUtils.d.ts +0 -8
  149. package/dist/esm/node/plugin/plugins/config/stemUtils.js +0 -79
  150. package/dist/esm/node/plugin/plugins/extensionsAssets.d.ts +0 -3
  151. package/dist/esm/node/plugin/plugins/extensionsAssets.js +0 -95
  152. package/dist/esm/node/plugin/shared/removeSourceMap.d.ts +0 -7
  153. package/dist/esm/node/plugin/shared/removeSourceMap.js +0 -9
  154. package/dist/esm/node/shared/getClientEntryFilePath.d.ts +0 -3
  155. package/dist/esm/utils/getDependencyPackageJson.d.ts +0 -6
  156. package/dist/esm/utils/getDependencyPackageJson.js +0 -85
  157. package/dist/esm/utils/isStemPackageName.d.ts +0 -1
  158. package/dist/esm/utils/isStemPackageName.js +0 -10
  159. /package/dist/esm/utils/{nodeEnv.d.ts → assertNodeEnv.d.ts} +0 -0
@@ -25,11 +25,10 @@ type PageConfigBase = {
25
25
  routeString: string;
26
26
  definedBy: string;
27
27
  };
28
+ configValues: ConfigValues;
28
29
  };
29
30
  /** Page config data structure available at runtime */
30
31
  type PageConfigRuntime = PageConfigBase & {
31
- /** All loaded config values */
32
- configValues: ConfigValues;
33
32
  /** Load config values that are lazily loaded such as config.Page */
34
33
  loadConfigValuesAll: () => Promise<{
35
34
  configValuesImported: ConfigValueImported[];
@@ -43,7 +42,6 @@ type PageConfigRuntimeLoaded = PageConfigRuntime & {
43
42
  };
44
43
  /** Page config data structure available at build-time */
45
44
  type PageConfigBuildTime = PageConfigBase & {
46
- configValues: ConfigValues;
47
45
  configValueSources: ConfigValueSources;
48
46
  configValuesComputed: ConfigValuesComputed;
49
47
  };
@@ -111,7 +109,7 @@ type FilePath = {
111
109
  *
112
110
  * Its value is equivalent to `filePath.filePathRelativeToUserRootDir ?? filePath.importPathAbsolute`, for example:
113
111
  * - `vike-react/config`, or
114
- * - `/pages/+config.h.js`.
112
+ * - `/pages/+config.js`.
115
113
  */
116
114
  filePathAbsoluteVite: string;
117
115
  /** The file's path, absolute from the filesystem root.
@@ -3,6 +3,7 @@ import { assert, assertUsage, getValuePrintable } from '../../utils.js';
3
3
  import pc from '@brillout/picocolors';
4
4
  import { getConfigDefinedAtString } from './getConfigDefinedAtString.js';
5
5
  // prettier-ignore
6
+ // biome-ignore format:
6
7
  function getConfigValue(pageConfig, configName, type) {
7
8
  const configValue = getConfigValueEntry(pageConfig, configName);
8
9
  if (configValue === null)
@@ -75,7 +75,7 @@ function assertIsNotNull(configValue, configName, importPath) {
75
75
  * - for cumulative values in the future: we don't need this for now because, currently, cumulative values are never imported.
76
76
  assertUsage(
77
77
  configValue !== null,
78
- `Set ${pc.cyan(configName)} to ${pc.cyan('null')} in a +config.h.js file instead of ${importPath}`
78
+ `Set ${pc.cyan(configName)} to ${pc.cyan('null')} in a +config.js file instead of ${importPath}`
79
79
  )
80
80
  */
81
81
  }
@@ -159,6 +159,7 @@ function assertNoInfiniteLoop(pageContextsFromRewrite) {
159
159
  function assertNoInfiniteAbortLoop(rewriteCount, redirectCount) {
160
160
  const abortCalls = [
161
161
  // prettier-ignore
162
+ // biome-ignore format:
162
163
  rewriteCount > 0 && pc.cyan("throw render('/some-url')"),
163
164
  redirectCount > 0 && pc.cyan("throw redirect('/some-url')")
164
165
  ]
@@ -7,6 +7,7 @@ import { isStaticRouteString } from './resolveRouteString.js';
7
7
  // See https://vike.dev/route-function#precedence
8
8
  function resolvePrecendence(routeMatches) {
9
9
  // prettier-ignore
10
+ // biome-ignore format:
10
11
  routeMatches
11
12
  .sort(sortMatches)
12
13
  .sort(makeFirst((routeMatch) => routeMatch.routeType === 'FUNCTION' && !!routeMatch.precedence && routeMatch.precedence < 0))
@@ -1,3 +1,6 @@
1
+ // Utils to manage process.env.NODE_ENV and, most notably, to assert correct usage, which is crucial:
2
+ // - https://github.com/vikejs/vike/issues/1469#issuecomment-1919518096
3
+ // - https://github.com/vitejs/vite/blob/76f30ae23b92f9af910ec02d98e2baaefa12141f/packages/vite/src/node/config.ts#L567
1
4
  export { getNodeEnv };
2
5
  export { setNodeEnvToProduction };
3
6
  export { isNodeEnvDev };
@@ -1,7 +1,7 @@
1
1
  export { createDebugger };
2
2
  export { isDebugEnabled };
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:stem' | 'vike:setup';
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';
5
5
  type Debug = ReturnType<typeof createDebugger>;
6
6
  type Options = {
7
7
  serialization?: {
@@ -7,6 +7,7 @@ function formatHintLog(msg) {
7
7
  const sep = '─'.repeat(msgLength);
8
8
  return [
9
9
  // prettier-ignore
10
+ // biome-ignore format:
10
11
  `┌─${sep}─┐`,
11
12
  `│ ${msg} │`,
12
13
  `└─${sep}─┘`
@@ -4,6 +4,7 @@ export { hasProp };
4
4
  import { isCallable } from './isCallable.js';
5
5
  import { isObject } from './isObject.js';
6
6
  // prettier-ignore
7
+ // biome-ignore format:
7
8
  function hasProp(obj, prop, type = 'unknown') {
8
9
  if (!isObject(obj))
9
10
  return false;
@@ -1,8 +1,10 @@
1
1
  export { isScriptFile };
2
+ export { isJavaScriptFile };
2
3
  export { isTemplateFile };
3
4
  export { scriptFileExtensions };
4
5
  export { scriptFileExtensionList };
5
- declare const scriptFileExtensionList: readonly ["js", "ts", "cjs", "cts", "mjs", "mts", "jsx", "tsx", "cjsx", "ctsx", "mjsx", "mtsx", "vue", "svelte", "marko", "md", "mdx"];
6
+ declare const scriptFileExtensionList: readonly [...string[], "jsx", "tsx", "cjsx", "ctsx", "mjsx", "mtsx", "vue", "svelte", "marko", "md", "mdx"];
6
7
  declare const scriptFileExtensions: string;
7
8
  declare function isScriptFile(filePath: string): boolean;
9
+ declare function isJavaScriptFile(filePath: string): boolean;
8
10
  declare function isTemplateFile(filePath: string): boolean;
@@ -1,4 +1,5 @@
1
1
  export { isScriptFile };
2
+ export { isJavaScriptFile };
2
3
  export { isTemplateFile };
3
4
  export { scriptFileExtensions };
4
5
  export { scriptFileExtensionList };
@@ -13,6 +14,7 @@ import { assert } from './assert.js';
13
14
  // - We cannot implement a blacklist with a glob pattern.
14
15
  // - A post `import.meta.glob()` blacklist filtering doesn't work because Vite would still process the files (e.g. including them in the bundle).
15
16
  // prettier-ignore
17
+ // biome-ignore format:
16
18
  const extJavaScript = [
17
19
  'js',
18
20
  'ts',
@@ -20,6 +22,10 @@ const extJavaScript = [
20
22
  'cts',
21
23
  'mjs',
22
24
  'mts',
25
+ ];
26
+ // prettier-ignore
27
+ // biome-ignore format:
28
+ const extJsx = [
23
29
  'jsx',
24
30
  'tsx',
25
31
  'cjsx',
@@ -28,6 +34,7 @@ const extJavaScript = [
28
34
  'mtsx',
29
35
  ];
30
36
  // prettier-ignore
37
+ // biome-ignore format:
31
38
  const extTemplates = [
32
39
  'vue',
33
40
  'svelte',
@@ -35,15 +42,19 @@ const extTemplates = [
35
42
  'md',
36
43
  'mdx'
37
44
  ];
38
- const scriptFileExtensionList = [...extJavaScript, ...extTemplates];
45
+ const scriptFileExtensionList = [...extJavaScript, ...extJsx, ...extTemplates];
39
46
  const scriptFileExtensions = '(' + scriptFileExtensionList.join('|') + ')';
40
47
  function isScriptFile(filePath) {
41
48
  const yes = scriptFileExtensionList.some((ext) => filePath.endsWith('.' + ext));
42
- assert(!isJavaScriptFile(filePath) || yes);
49
+ if (isJavaScriptFile(filePath))
50
+ assert(yes);
43
51
  return yes;
44
52
  }
45
53
  function isJavaScriptFile(filePath) {
46
- return /\.(c|m)?(j|t)sx?$/.test(filePath);
54
+ const yes1 = /\.(c|m)?(j|t)s$/.test(filePath);
55
+ const yes2 = extJavaScript.some((ext) => filePath.endsWith('.' + ext));
56
+ assert(yes1 === yes2);
57
+ return yes1;
47
58
  }
48
59
  function isTemplateFile(filePath) {
49
60
  return extTemplates.some((ext) => filePath.endsWith('.' + ext));
@@ -1,7 +1,7 @@
1
1
  export { projectInfo };
2
2
  export { PROJECT_VERSION };
3
- declare const PROJECT_VERSION: "0.4.161";
3
+ declare const PROJECT_VERSION: "0.4.162-commit-8995471";
4
4
  declare const projectInfo: {
5
5
  projectName: "Vike";
6
- projectVersion: "0.4.161";
6
+ projectVersion: "0.4.162-commit-8995471";
7
7
  };
@@ -1,7 +1,7 @@
1
1
  export { projectInfo };
2
2
  export { PROJECT_VERSION };
3
3
  import { onProjectInfo } from './assertSingleInstance.js';
4
- const PROJECT_VERSION = '0.4.161';
4
+ const PROJECT_VERSION = '0.4.162-commit-8995471';
5
5
  const projectInfo = {
6
6
  projectName: 'Vike',
7
7
  projectVersion: PROJECT_VERSION
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "vike",
3
- "version": "0.4.161",
3
+ "version": "0.4.162-commit-8995471",
4
4
  "scripts": {
5
5
  "dev": "tsc --watch",
6
6
  "build": "rimraf dist/ && pnpm run build:esm && pnpm run build:cjs",
@@ -16,7 +16,7 @@
16
16
  "@brillout/json-serializer": "^0.5.8",
17
17
  "@brillout/picocolors": "^1.0.10",
18
18
  "@brillout/require-shim": "^0.1.2",
19
- "@brillout/vite-plugin-server-entry": "^0.4.3",
19
+ "@brillout/vite-plugin-server-entry": "^0.4.4",
20
20
  "acorn": "^8.0.0",
21
21
  "cac": "^6.0.0",
22
22
  "es-module-lexer": "^1.0.0",
@@ -187,9 +187,10 @@
187
187
  "@types/node": "^20.10.5",
188
188
  "@types/resolve": "^1.20.6",
189
189
  "@types/source-map-support": "^0.5.10",
190
+ "react-streaming": "^0.3.22",
190
191
  "rimraf": "^5.0.5",
191
192
  "typescript": "^5.3.3",
192
- "vite": "^5.0.10"
193
+ "vite": "npm:@brillout/vite@5.1.0-commit-3dc7abd"
193
194
  },
194
195
  "engines": {
195
196
  "node": ">=16.0.0"
@@ -1,27 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.findConfigVikeFromStemPackages = void 0;
4
- const utils_js_1 = require("../../utils.js");
5
- const stemUtils_js_1 = require("./stemUtils.js");
6
- const debug = (0, utils_js_1.createDebugger)('vike:stem');
7
- async function findConfigVikeFromStemPackages(root) {
8
- if (isDeno())
9
- return [];
10
- const stemPackages = await (0, stemUtils_js_1.getStemPackages)(root);
11
- const configVikeFromStemPackages = [];
12
- debug('Stem packages found:', stemPackages.map(({ stemPackageName, stemPackageRootDir }) => ({ stemPackageName, stemPackageRootDir })));
13
- await Promise.all(stemPackages.map(async ({ loadModule }) => {
14
- const moduleExports = (await loadModule('vike.config.js')) || (await loadModule('vite-plugin-ssr.config.js'));
15
- if (!moduleExports)
16
- return;
17
- const configVike = moduleExports.default;
18
- (0, utils_js_1.assert)((0, utils_js_1.isObject)(configVike));
19
- configVikeFromStemPackages.push(configVike);
20
- }));
21
- return configVikeFromStemPackages;
22
- }
23
- exports.findConfigVikeFromStemPackages = findConfigVikeFromStemPackages;
24
- function isDeno() {
25
- // @ts-ignore
26
- return typeof Deno !== 'undefined' && Deno.env;
27
- }
@@ -1,107 +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.resolveExtensions = void 0;
7
- const utils_js_1 = require("../../utils.js");
8
- const path_1 = __importDefault(require("path"));
9
- const fs_1 = __importDefault(require("fs"));
10
- const fileTypes_js_1 = require("../../../../shared/getPageFiles/fileTypes.js");
11
- const module_1 = require("module");
12
- const picocolors_1 = __importDefault(require("@brillout/picocolors"));
13
- // @ts-ignore Shimmed by dist-cjs-fixup.js for CJS build.
14
- const importMetaUrl = `file://${__filename}`;
15
- const require_ = (0, module_1.createRequire)(importMetaUrl);
16
- function resolveExtensions(configs, config) {
17
- const extensions = configs.map((c) => c.extensions ?? []).flat();
18
- return extensions.map((extension) => {
19
- const { npmPackageName } = extension;
20
- (0, utils_js_1.assertUsage)((0, utils_js_1.isNpmPackageName)(npmPackageName), `vike extension ${picocolors_1.default.cyan(npmPackageName)} doesn't seem to be a valid npm package name`);
21
- const npmPackageRootDir = (0, utils_js_1.getDependencyRootDir)(npmPackageName, config.root);
22
- (0, utils_js_1.assertPosixPath)(npmPackageRootDir);
23
- const pageConfigsDistFiles = resolvePageFilesDist([
24
- ...(extension.pageConfigsDistFiles ?? []),
25
- // TODO/v1-release: remove
26
- ...(extension.pageFilesDist ?? [])
27
- ], npmPackageName, config, npmPackageRootDir);
28
- let pageConfigsSrcDirResolved = null;
29
- {
30
- const pageConfigsSrcDir = extension.pageConfigsSrcDir ?? extension.pageFilesSrc;
31
- if (pageConfigsSrcDir) {
32
- assertPathProvidedByUser('pageConfigsSrcDir', pageConfigsSrcDir, true);
33
- (0, utils_js_1.assert)(pageConfigsSrcDir.endsWith('*'));
34
- pageConfigsSrcDirResolved = path_1.default.posix.join(npmPackageRootDir, pageConfigsSrcDir.slice(0, -1));
35
- }
36
- }
37
- (0, utils_js_1.assertUsage)(pageConfigsSrcDirResolved || pageConfigsDistFiles, `Extension ${npmPackageName} should define either extension[number].pageConfigsDistFiles or extension[number].pageConfigsSrcDir`);
38
- (0, utils_js_1.assertUsage)(!pageConfigsDistFiles || !pageConfigsSrcDirResolved, `Extension ${npmPackageName} shouldn't define extension[number].pageConfigsDistFiles as well extension[number].pageConfigsSrcDir, it should define only one instead`);
39
- const assetsDir = (() => {
40
- if (!extension.assetsDir) {
41
- return null;
42
- }
43
- assertPathProvidedByUser('assetsDir', extension.assetsDir);
44
- (0, utils_js_1.assertPosixPath)(extension.assetsDir);
45
- const assetsDir = path_1.default.posix.join(npmPackageRootDir, extension.assetsDir);
46
- return assetsDir;
47
- })();
48
- (0, utils_js_1.assertUsage)(!(assetsDir && pageConfigsSrcDirResolved), `Extension ${npmPackageName} shouldn't define both extension[number].pageConfigsSrcDir and extension[number].assetsDir`);
49
- const extensionResolved = {
50
- npmPackageName,
51
- npmPackageRootDir,
52
- pageConfigsDistFiles,
53
- pageConfigsSrcDir: pageConfigsSrcDirResolved,
54
- assetsDir
55
- };
56
- return extensionResolved;
57
- });
58
- }
59
- exports.resolveExtensions = resolveExtensions;
60
- function assertPathProvidedByUser(pathName, pathValue, starSuffix) {
61
- const errMsg = `extension[number].${pathName} value ${picocolors_1.default.cyan(pathValue)}`;
62
- (0, utils_js_1.assertUsage)(!pathValue.includes('\\'), `${errMsg} shouldn't contain any backward slahes '\' (replace them with forward slahes '/')`);
63
- (0, utils_js_1.assertUsage)(!starSuffix || pathValue.endsWith('/*'), `${errMsg} should end with '/*'`);
64
- (0, utils_js_1.assertUsage)(pathValue.startsWith('/'), `${errMsg} should start with '/'`);
65
- }
66
- function resolvePageFilesDist(pageConfigsDistFiles, npmPackageName, config, npmPackageRootDir) {
67
- if (!pageConfigsDistFiles || pageConfigsDistFiles.length === 0)
68
- return null;
69
- const pageConfigsDistFilesResolved = [];
70
- pageConfigsDistFiles.forEach((importPath) => {
71
- const errPrefix = `The page file ${picocolors_1.default.cyan(importPath)} (provided in extensions[number].pageFiles) should`;
72
- (0, utils_js_1.assertUsage)(npmPackageName === (0, utils_js_1.getNpmPackageName)(importPath), `${errPrefix} be a ${picocolors_1.default.cyan(npmPackageName)} module (e.g. ${picocolors_1.default.cyan(`${npmPackageName}/renderer/_default.page.server.js`)})`);
73
- (0, utils_js_1.assertUsage)((0, fileTypes_js_1.isValidFileType)(importPath), `${errPrefix} end with '.js', '.js', '.cjs', or '.css'`);
74
- const filePath = resolveImportPath(importPath, npmPackageName, config, npmPackageRootDir);
75
- pageConfigsDistFilesResolved.push({
76
- importPath,
77
- filePath
78
- });
79
- const filePathCSS = getPathCSS(filePath);
80
- if (filePathCSS !== filePath && fs_1.default.existsSync(filePathCSS)) {
81
- const importPathCSS = getPathCSS(importPath);
82
- (0, utils_js_1.assertUsage)(filePathCSS === resolveImportPath(importPathCSS, npmPackageName, config, npmPackageRootDir), `The entry package.json#exports["${importPathCSS}"] in the package.json of ${npmPackageName} (${npmPackageRootDir}/package.json) has a wrong value: make sure it resolves to ${filePathCSS}`);
83
- pageConfigsDistFilesResolved.push({
84
- importPath: importPathCSS,
85
- filePath: filePathCSS
86
- });
87
- }
88
- });
89
- return pageConfigsDistFilesResolved;
90
- }
91
- function resolveImportPath(importPath, npmPackageName, config, npmPackageRootDir) {
92
- let filePath;
93
- try {
94
- filePath = require_.resolve(importPath, { paths: [config.root] });
95
- }
96
- catch (err) {
97
- if (err?.code === 'ERR_PACKAGE_PATH_NOT_EXPORTED') {
98
- (0, utils_js_1.assertUsage)(false, `Define ${importPath} in the package.json#exports of ${npmPackageName} (${npmPackageRootDir}/package.json) with a Node.js export condition (even if it's a browser file such as CSS)`);
99
- }
100
- throw err;
101
- }
102
- filePath = (0, utils_js_1.toPosixPath)(filePath);
103
- return filePath;
104
- }
105
- function getPathCSS(filePath) {
106
- return filePath.split('.').slice(0, -1).join('.') + '.css';
107
- }
@@ -1,85 +0,0 @@
1
- "use strict";
2
- // Move to standalone package? E.g. https://www.npmjs.com/package/stem
3
- var __importDefault = (this && this.__importDefault) || function (mod) {
4
- return (mod && mod.__esModule) ? mod : { "default": mod };
5
- };
6
- Object.defineProperty(exports, "__esModule", { value: true });
7
- exports.getStemPackages = void 0;
8
- const path_1 = __importDefault(require("path"));
9
- const utils_js_1 = require("../../utils.js");
10
- const import_1 = require("@brillout/import");
11
- const module_1 = require("module");
12
- // @ts-ignore Shimmed by dist-cjs-fixup.js for CJS build.
13
- const importMetaUrl = `file://${__filename}`;
14
- const require_ = (0, module_1.createRequire)(importMetaUrl);
15
- async function getStemPackages(userAppRootDir) {
16
- const userRootDir = findUserRootDir(userAppRootDir);
17
- const userPkgJson = getUserPackageJson(userRootDir);
18
- const stemPkgNames = getStemPkgNames(userPkgJson);
19
- const stemPackages = await Promise.all(stemPkgNames.map((stemPackageName) => {
20
- (0, utils_js_1.assert)(stemPackageName.includes('stem-'));
21
- const resolveModulePath = (moduleId) => {
22
- const importPath = `${stemPackageName}/${moduleId}`;
23
- try {
24
- const modulePath = require_.resolve(importPath, { paths: [userRootDir] });
25
- return modulePath;
26
- }
27
- catch (err) {
28
- // - ERR_PACKAGE_PATH_NOT_EXPORTED => package.json#exports[importPath] is missing
29
- // - We assert that Stem packages always define package.json#exports down below
30
- if (err.code === 'ERR_PACKAGE_PATH_NOT_EXPORTED') {
31
- return null;
32
- }
33
- // All other errors such as ERR_MODULE_NOT_FOUND should be thrown
34
- throw err;
35
- }
36
- };
37
- const loadModule = async (moduleId) => {
38
- const modulePath = resolveModulePath(moduleId);
39
- if (modulePath === null)
40
- return null;
41
- const moduleExports = moduleId.endsWith('.json')
42
- ? require_(modulePath)
43
- : await (0, import_1.import_)(modulePath);
44
- return moduleExports;
45
- };
46
- const stemPackageRootDir = (0, utils_js_1.getDependencyRootDir)(stemPackageName, userAppRootDir);
47
- return {
48
- stemPackageName,
49
- stemPackageRootDir,
50
- loadModule
51
- };
52
- }));
53
- return stemPackages;
54
- }
55
- exports.getStemPackages = getStemPackages;
56
- function findUserRootDir(userAppRootDir) {
57
- const userPkgJsonPath = (0, utils_js_1.findFile)('package.json', userAppRootDir);
58
- (0, utils_js_1.assertUsage)(userPkgJsonPath, `Couldn't find package.json in any parent directory starting from ${userAppRootDir}`);
59
- return (0, utils_js_1.toPosixPath)(path_1.default.dirname(userPkgJsonPath));
60
- }
61
- function getStemPkgNames(userPkgJson) {
62
- const stemPkgNames = Object.keys(userPkgJson.dependencies ?? {}).filter((depName) => {
63
- if (depName.startsWith('stem-')) {
64
- (0, utils_js_1.assertWarning)(false, `${depName} should be renamed to @someNpmOrgOrUser/${depName} (to follow the convention that all Stem packages belond to an npm organization)`, { onlyOnce: true });
65
- return true;
66
- }
67
- if (depName.split('/')[1]?.startsWith('stem-')) {
68
- return true;
69
- }
70
- return false;
71
- });
72
- return stemPkgNames;
73
- }
74
- function getUserPackageJson(userRootDir) {
75
- (0, utils_js_1.assertPosixPath)(userRootDir);
76
- const userPkgJsonPath = path_1.default.posix.join(userRootDir, './package.json');
77
- let userPkgJson;
78
- try {
79
- userPkgJson = require_(userPkgJsonPath);
80
- }
81
- catch {
82
- throw new Error(`No package.json found at ${userRootDir}`);
83
- }
84
- return userPkgJson;
85
- }
@@ -1,101 +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.extensionsAssets = void 0;
7
- const utils_js_1 = require("../utils.js");
8
- const fs_1 = __importDefault(require("fs"));
9
- const path_1 = __importDefault(require("path"));
10
- const sirv_1 = __importDefault(require("sirv"));
11
- const getConfigVike_js_1 = require("../../shared/getConfigVike.js");
12
- const isAsset_js_1 = require("../shared/isAsset.js");
13
- const ASSET_DIR = 'assets';
14
- function extensionsAssets() {
15
- let config;
16
- let extensionsAssetsDir;
17
- return {
18
- name: 'vike:extensionsAssets',
19
- async configResolved(config_) {
20
- config = config_;
21
- const configVike = await (0, getConfigVike_js_1.getConfigVike)(config);
22
- extensionsAssetsDir = getExtensionsAssetsDir(config, configVike);
23
- },
24
- configureServer(server) {
25
- if (extensionsAssetsDir.length > 0) {
26
- return () => {
27
- serveExtensionsAssets(server.middlewares, extensionsAssetsDir, config);
28
- };
29
- }
30
- },
31
- writeBundle() {
32
- if (!config.build.ssr && extensionsAssetsDir.length > 0) {
33
- copyExtensionsAssetsDir(config, extensionsAssetsDir);
34
- }
35
- }
36
- };
37
- }
38
- exports.extensionsAssets = extensionsAssets;
39
- function serveExtensionsAssets(middlewares, extensionsAssetsDirs, config) {
40
- (0, utils_js_1.assert)(ASSET_DIR === getAsssetsDirConfig(config));
41
- extensionsAssetsDirs.forEach((assetsDir) => {
42
- const serve = (0, sirv_1.default)(assetsDir);
43
- middlewares.use(async (req, res, next) => {
44
- if (!req.url?.startsWith(`/${ASSET_DIR}/`)) {
45
- next();
46
- return;
47
- }
48
- // https://github.com/lukeed/sirv/issues/148 - [Feature Request] New option base.
49
- req.url = '/' + req.url.slice(`/${ASSET_DIR}/`.length);
50
- serve(req, res, next);
51
- });
52
- });
53
- }
54
- function getExtensionsAssetsDir(config, configVike) {
55
- const { extensions } = configVike;
56
- const extensionsWithAssetsDir = extensions.filter(({ assetsDir }) => assetsDir);
57
- if (0 === extensionsWithAssetsDir.length)
58
- return [];
59
- (0, utils_js_1.assertUsage)(ASSET_DIR === getAsssetsDirConfig(config), 'Cannot modify vite.config.js#build.assetsDir while using ' + extensionsWithAssetsDir[0].npmPackageName);
60
- const extensionsAssetsDir = extensionsWithAssetsDir.map(({ assetsDir }) => {
61
- (0, utils_js_1.assert)(assetsDir);
62
- (0, utils_js_1.assertPosixPath)(assetsDir);
63
- return assetsDir;
64
- });
65
- return extensionsAssetsDir;
66
- }
67
- function getAsssetsDirConfig(config) {
68
- let { assetsDir } = config.build;
69
- (0, utils_js_1.assertPosixPath)(assetsDir);
70
- assetsDir = assetsDir.split('/').filter(Boolean).join('/');
71
- return assetsDir;
72
- }
73
- function copyExtensionsAssetsDir(config, extensionsAssetsDirs) {
74
- (0, utils_js_1.assert)(ASSET_DIR === getAsssetsDirConfig(config));
75
- const { outDirClient } = (0, utils_js_1.getOutDirs)(config);
76
- (0, utils_js_1.assertPosixPath)(outDirClient);
77
- const outDirAssets = path_1.default.posix.join(outDirClient, ASSET_DIR);
78
- extensionsAssetsDirs.forEach((assetsDir) => {
79
- copyAssetFiles(assetsDir, outDirAssets);
80
- });
81
- }
82
- // Adapted from https://github.com/vitejs/vite/blob/e92d025cedabb477687d6a352ee8c9b7d529f623/packages/vite/src/node/utils.ts#L589-L604
83
- function copyAssetFiles(srcDir, destDir) {
84
- let destDirCreated = false;
85
- for (const file of fs_1.default.readdirSync(srcDir)) {
86
- const srcFile = path_1.default.resolve(srcDir, file);
87
- const destFile = path_1.default.resolve(destDir, file);
88
- const stat = fs_1.default.statSync(srcFile);
89
- if (stat.isDirectory()) {
90
- copyAssetFiles(srcFile, destFile);
91
- }
92
- else if ((0, isAsset_js_1.isAsset)(srcFile)) {
93
- (0, utils_js_1.assert)(!(0, utils_js_1.isScriptFile)(srcFile));
94
- if (!destDirCreated) {
95
- fs_1.default.mkdirSync(destDir, { recursive: true });
96
- destDirCreated = true;
97
- }
98
- fs_1.default.copyFileSync(srcFile, destFile);
99
- }
100
- }
101
- }
@@ -1,12 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.removeSourceMap = void 0;
4
- function removeSourceMap(code) {
5
- return {
6
- code,
7
- // Remove Source Map to save KBs
8
- // - https://rollupjs.org/guide/en/#source-code-transformations
9
- map: { mappings: '' }
10
- };
11
- }
12
- exports.removeSourceMap = removeSourceMap;
@@ -1,91 +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.getDependencyRootDir = exports.getDependencyPackageJsonPath = exports.getDependencyPackageJson = void 0;
7
- // There doesn't seem to be any alternative:
8
- // - https://github.com/antfu/local-pkg
9
- // - https://stackoverflow.com/questions/74640378/find-and-read-package-json-of-a-dependency
10
- // - https://stackoverflow.com/questions/58442451/finding-the-root-directory-of-a-dependency-in-npm
11
- // - https://stackoverflow.com/questions/10111163/how-can-i-get-the-path-of-a-module-i-have-loaded-via-require-that-is-not-mine/63441056#63441056
12
- const assert_js_1 = require("./assert.js");
13
- const isNpmPackage_js_1 = require("./isNpmPackage.js");
14
- const filesystemPathHandling_js_1 = require("./filesystemPathHandling.js");
15
- const isObject_js_1 = require("./isObject.js");
16
- const path_1 = __importDefault(require("path"));
17
- const fs_1 = __importDefault(require("fs"));
18
- const assertIsNotProductionRuntime_js_1 = require("./assertIsNotProductionRuntime.js");
19
- const module_1 = require("module");
20
- // @ts-ignore Shimmed by dist-cjs-fixup.js for CJS build.
21
- const importMetaUrl = `file://${__filename}`;
22
- const require_ = (0, module_1.createRequire)(importMetaUrl);
23
- (0, assertIsNotProductionRuntime_js_1.assertIsNotProductionRuntime)();
24
- function getDependencyPackageJson(npmPackageName, userAppRootDir) {
25
- const packageJsonPath = getDependencyPackageJsonPath(npmPackageName, userAppRootDir);
26
- const packageJson = fs_1.default.readFileSync(packageJsonPath, 'utf8');
27
- (0, assert_js_1.assert)((0, isObject_js_1.isObject)(packageJson));
28
- return packageJson;
29
- }
30
- exports.getDependencyPackageJson = getDependencyPackageJson;
31
- function getDependencyRootDir(npmPackageName, userAppRootDir) {
32
- const rootDir = path_1.default.posix.dirname(getDependencyPackageJsonPath(npmPackageName, userAppRootDir));
33
- return rootDir;
34
- }
35
- exports.getDependencyRootDir = getDependencyRootDir;
36
- function getDependencyPackageJsonPath(npmPackageName, userAppRootDir) {
37
- (0, assert_js_1.assert)((0, isNpmPackage_js_1.isNpmPackageName)(npmPackageName));
38
- let packageJsonPath = resolvePackageJsonDirectly(npmPackageName, userAppRootDir);
39
- if (!packageJsonPath) {
40
- packageJsonPath = resolvePackageJsonWithMainEntry(npmPackageName, userAppRootDir);
41
- }
42
- (0, assert_js_1.assertUsage)(packageJsonPath, `Cannot read ${npmPackageName}/package.json. Define package.json#exports["./package.json"] with the value "./package.json" in the package.json of ${npmPackageName}.`);
43
- packageJsonPath = (0, filesystemPathHandling_js_1.toPosixPath)(packageJsonPath);
44
- (0, assert_js_1.assert)(packageJsonPath.endsWith('/package.json'), packageJsonPath); // package.json#exports["package.json"] may point to another file than package.json
45
- return packageJsonPath;
46
- }
47
- exports.getDependencyPackageJsonPath = getDependencyPackageJsonPath;
48
- function resolvePackageJsonDirectly(npmPackageName, userAppRootDir) {
49
- let packageJsonPath;
50
- try {
51
- packageJsonPath = require_.resolve(`${npmPackageName}/package.json`, { paths: [userAppRootDir] });
52
- }
53
- catch (err) {
54
- if (isUnexpectedError(err))
55
- throw err;
56
- return null;
57
- }
58
- return packageJsonPath;
59
- }
60
- function resolvePackageJsonWithMainEntry(npmPackageName, userAppRootDir) {
61
- let mainEntry;
62
- try {
63
- mainEntry = require_.resolve(npmPackageName, { paths: [userAppRootDir] });
64
- }
65
- catch (err) {
66
- if (isUnexpectedError(err))
67
- throw err;
68
- return null;
69
- }
70
- const packageJsonPath = searchPackageJSON(mainEntry);
71
- return packageJsonPath;
72
- }
73
- // If the npm package doesn't define package.json#exports then require.resolve(`${npmPackageName}/package.json`) just works.
74
- // This means we can assume packageJson#exports to be defined and, consequently, we can assume the error code to always be ERR_PACKAGE_PATH_NOT_EXPORTED.
75
- // (If MODULE_NOT_FOUND is thrown then this means that npmPackageName isn't installed.)
76
- function isUnexpectedError(err) {
77
- return err?.code !== 'ERR_PACKAGE_PATH_NOT_EXPORTED';
78
- }
79
- // Copied and adapted from https://github.com/antfu/local-pkg
80
- function searchPackageJSON(dir) {
81
- let packageJsonPath;
82
- while (true) {
83
- (0, assert_js_1.assert)(dir);
84
- const newDir = path_1.default.dirname(dir);
85
- (0, assert_js_1.assert)(newDir !== dir);
86
- dir = newDir;
87
- packageJsonPath = path_1.default.join(dir, 'package.json');
88
- if (fs_1.default.existsSync(packageJsonPath))
89
- return packageJsonPath;
90
- }
91
- }