vike 0.4.238 → 0.4.239-commit-33e55d4

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 (197) hide show
  1. package/dist/cjs/node/prerender/resolvePrerenderConfig.js +3 -2
  2. package/dist/cjs/node/prerender/runPrerender.js +1 -0
  3. package/dist/cjs/node/runtime/globalContext.js +10 -0
  4. package/dist/cjs/node/runtime/index.js +3 -3
  5. package/dist/cjs/node/runtime/page-files/setup.js +3 -1
  6. package/dist/cjs/node/runtime/renderPage/createHttpResponse.js +2 -9
  7. package/dist/cjs/node/runtime/renderPage/createPageContextServerSide.js +2 -2
  8. package/dist/cjs/node/runtime/renderPage/csp.js +47 -0
  9. package/dist/cjs/node/runtime/renderPage/execHookOnRenderHtml.js +2 -2
  10. package/dist/cjs/node/runtime/renderPage/getEarlyHints.js +1 -1
  11. package/dist/cjs/node/runtime/renderPage/getHttpResponseBody.js +2 -2
  12. package/dist/cjs/node/runtime/renderPage/headersResponse.js +48 -0
  13. package/dist/cjs/node/runtime/{html → renderPage/html}/injectAssets/getHtmlTags.js +16 -13
  14. package/dist/cjs/node/runtime/{html → renderPage/html}/injectAssets/getViteDevScript.js +1 -1
  15. package/dist/cjs/node/runtime/{html → renderPage/html}/injectAssets/inferHtmlTags.js +8 -6
  16. package/dist/cjs/node/runtime/{html → renderPage/html}/injectAssets/injectAssets__public.js +1 -1
  17. package/dist/cjs/node/runtime/{html → renderPage/html}/injectAssets/injectHtmlTags.js +1 -1
  18. package/dist/cjs/node/runtime/{html → renderPage/html}/injectAssets/mergeScriptTags.js +5 -3
  19. package/dist/cjs/node/runtime/{html → renderPage/html}/injectAssets.js +2 -2
  20. package/dist/cjs/node/runtime/{html → renderPage/html}/propKeys.js +1 -1
  21. package/dist/cjs/node/runtime/{html → renderPage/html}/renderHtml.js +1 -1
  22. package/dist/cjs/node/runtime/{html → renderPage/html}/serializeContext.js +6 -6
  23. package/dist/cjs/node/runtime/{html → renderPage/html}/stream/react-streaming.js +1 -1
  24. package/dist/cjs/node/runtime/{html → renderPage/html}/stream.js +1 -1
  25. package/dist/cjs/node/runtime/renderPage/loadPageConfigsLazyServerSide.js +17 -38
  26. package/dist/cjs/node/runtime/renderPage/renderPageAfterRoute.js +2 -2
  27. package/dist/cjs/node/runtime/renderPage.js +1 -1
  28. package/dist/cjs/node/vite/onLoad.js +1 -1
  29. package/dist/cjs/node/vite/plugins/pluginBaseUrls.js +32 -28
  30. package/dist/cjs/node/vite/plugins/pluginBuild/handleAssetsManifest.js +1 -1
  31. package/dist/cjs/node/vite/plugins/pluginBuild/pluginBuildApp.js +24 -20
  32. package/dist/cjs/node/vite/plugins/pluginBuild/pluginBuildConfig.js +4 -2
  33. package/dist/cjs/node/vite/plugins/pluginBuild/pluginDistFileNames.js +76 -74
  34. package/dist/cjs/node/vite/plugins/pluginBuild/pluginDistPackageJsonFile.js +18 -14
  35. package/dist/cjs/node/vite/plugins/pluginBuild/pluginModuleBanner.js +17 -9
  36. package/dist/cjs/node/vite/plugins/pluginBuild/pluginProdBuildEntry.js +4 -2
  37. package/dist/cjs/node/vite/plugins/pluginBuild/pluginSuppressRollupWarning.js +20 -18
  38. package/dist/cjs/node/vite/plugins/pluginCommon.js +7 -21
  39. package/dist/cjs/node/vite/plugins/pluginDev.js +51 -47
  40. package/dist/cjs/node/vite/plugins/pluginEnvVars.js +62 -57
  41. package/dist/cjs/node/vite/plugins/pluginExtractAssets.js +107 -93
  42. package/dist/cjs/node/vite/plugins/pluginExtractExportNames.js +27 -13
  43. package/dist/cjs/node/vite/plugins/pluginFileEnv.js +107 -84
  44. package/dist/cjs/node/vite/plugins/pluginNonRunnableDev.js +40 -21
  45. package/dist/cjs/node/vite/plugins/pluginPreview.js +30 -24
  46. package/dist/cjs/node/vite/plugins/pluginReplaceConstants.js +59 -33
  47. package/dist/cjs/node/vite/plugins/pluginSetGlobalContext.js +4 -2
  48. package/dist/cjs/node/vite/plugins/pluginVirtualFiles/generateVirtualFileGlobalEntryWithOldDesign.js +1 -1
  49. package/dist/cjs/node/vite/plugins/pluginVirtualFiles.js +54 -36
  50. package/dist/cjs/node/vite/plugins/pluginWorkaroundCssModuleHmr.js +8 -6
  51. package/dist/cjs/node/vite/shared/resolveVikeConfigInternal/configDefinitionsBuiltIn.js +3 -0
  52. package/dist/cjs/node/vite/shared/resolveVikeConfigInternal/crawlPlusFiles.js +1 -1
  53. package/dist/cjs/node/vite/shared/resolveVikeConfigInternal.js +20 -22
  54. package/dist/cjs/shared/createGlobalContextShared.js +4 -22
  55. package/dist/cjs/shared/createPageContextShared.js +2 -2
  56. package/dist/cjs/shared/page-configs/resolveVikeConfigPublic.js +62 -43
  57. package/dist/cjs/utils/PROJECT_VERSION.js +1 -1
  58. package/dist/cjs/utils/assert.js +16 -1
  59. package/dist/cjs/utils/assertNodeVersion.js +3 -1
  60. package/dist/cjs/utils/assertVersion.js +26 -5
  61. package/dist/cjs/utils/joinEnglish.js +2 -1
  62. package/dist/cjs/utils/virtualFileId.js +15 -11
  63. package/dist/esm/client/runtime-client-routing/createPageContextClientSide.d.ts +40 -17
  64. package/dist/esm/client/runtime-client-routing/createPageContextClientSide.js +1 -1
  65. package/dist/esm/client/runtime-client-routing/getPageContextCurrent.d.ts +2 -2
  66. package/dist/esm/client/runtime-client-routing/getPageContextFromHooks.d.ts +99 -85
  67. package/dist/esm/client/runtime-client-routing/globalContext.d.ts +39 -11
  68. package/dist/esm/client/runtime-client-routing/prefetch/getPrefetchSettings.d.ts +2 -2
  69. package/dist/esm/client/runtime-client-routing/prefetch.d.ts +2 -2
  70. package/dist/esm/client/runtime-client-routing/prefetch.js +2 -2
  71. package/dist/esm/client/runtime-client-routing/preparePageContextForPublicUsageClient.d.ts +2 -2
  72. package/dist/esm/client/runtime-client-routing/renderPageClientSide.d.ts +44 -29
  73. package/dist/esm/client/runtime-server-routing/createPageContextClientSide.d.ts +40 -17
  74. package/dist/esm/client/runtime-server-routing/createPageContextClientSide.js +1 -1
  75. package/dist/esm/client/runtime-server-routing/globalContext.d.ts +39 -11
  76. package/dist/esm/client/runtime-server-routing/preparePageContextForPublicUsageClient.d.ts +2 -2
  77. package/dist/esm/client/shared/createGetGlobalContextClient.d.ts +39 -11
  78. package/dist/esm/client/shared/execHookOnRenderClient.d.ts +2 -2
  79. package/dist/esm/client/shared/loadPageConfigsLazyClientSide.d.ts +1 -1
  80. package/dist/esm/client/shared/loadPageConfigsLazyClientSide.js +2 -3
  81. package/dist/esm/client/shared/preparePageContextForPublicUsageClientShared.d.ts +2 -2
  82. package/dist/esm/node/prerender/resolvePrerenderConfig.js +4 -3
  83. package/dist/esm/node/prerender/runPrerender.d.ts +61 -16
  84. package/dist/esm/node/prerender/runPrerender.js +2 -1
  85. package/dist/esm/node/runtime/globalContext.d.ts +167 -42
  86. package/dist/esm/node/runtime/globalContext.js +11 -1
  87. package/dist/esm/node/runtime/index.d.ts +3 -3
  88. package/dist/esm/node/runtime/index.js +3 -3
  89. package/dist/esm/node/runtime/page-files/setup.js +3 -1
  90. package/dist/esm/node/runtime/renderPage/createHttpResponse.d.ts +1 -1
  91. package/dist/esm/node/runtime/renderPage/createHttpResponse.js +2 -9
  92. package/dist/esm/node/runtime/renderPage/createPageContextServerSide.d.ts +56 -12
  93. package/dist/esm/node/runtime/renderPage/createPageContextServerSide.js +2 -2
  94. package/dist/esm/node/runtime/renderPage/csp.d.ts +12 -0
  95. package/dist/esm/node/runtime/renderPage/csp.js +45 -0
  96. package/dist/esm/node/runtime/renderPage/execHookOnRenderHtml.d.ts +2 -2
  97. package/dist/esm/node/runtime/renderPage/execHookOnRenderHtml.js +2 -2
  98. package/dist/esm/node/runtime/renderPage/execHookServer.d.ts +2 -2
  99. package/dist/esm/node/runtime/renderPage/getEarlyHints.js +1 -1
  100. package/dist/esm/node/runtime/renderPage/getHttpResponseBody.d.ts +2 -2
  101. package/dist/esm/node/runtime/renderPage/getHttpResponseBody.js +2 -2
  102. package/dist/esm/node/runtime/renderPage/headersResponse.d.ts +10 -0
  103. package/dist/esm/node/runtime/renderPage/headersResponse.js +46 -0
  104. package/dist/esm/node/runtime/{html → renderPage/html}/injectAssets/getHtmlTags.d.ts +1 -1
  105. package/dist/esm/node/runtime/{html → renderPage/html}/injectAssets/getHtmlTags.js +16 -13
  106. package/dist/esm/node/runtime/{html → renderPage/html}/injectAssets/getViteDevScript.d.ts +1 -1
  107. package/dist/esm/node/runtime/{html → renderPage/html}/injectAssets/getViteDevScript.js +1 -1
  108. package/dist/esm/node/runtime/renderPage/html/injectAssets/inferHtmlTags.d.ts +10 -0
  109. package/dist/esm/node/runtime/{html → renderPage/html}/injectAssets/inferHtmlTags.js +7 -5
  110. package/dist/esm/node/runtime/{html → renderPage/html}/injectAssets/injectAssets__public.js +1 -1
  111. package/dist/esm/node/runtime/{html → renderPage/html}/injectAssets/injectHtmlTags.js +1 -1
  112. package/dist/esm/node/runtime/renderPage/html/injectAssets/mergeScriptTags.d.ts +3 -0
  113. package/dist/esm/node/runtime/{html → renderPage/html}/injectAssets/mergeScriptTags.js +6 -4
  114. package/dist/esm/node/runtime/{html → renderPage/html}/injectAssets.d.ts +2 -2
  115. package/dist/esm/node/runtime/{html → renderPage/html}/injectAssets.js +2 -2
  116. package/dist/esm/node/runtime/{html → renderPage/html}/propKeys.js +1 -1
  117. package/dist/esm/node/runtime/{html → renderPage/html}/renderHtml.d.ts +1 -1
  118. package/dist/esm/node/runtime/{html → renderPage/html}/renderHtml.js +1 -1
  119. package/dist/esm/node/runtime/{html → renderPage/html}/serializeContext.d.ts +6 -5
  120. package/dist/esm/node/runtime/{html → renderPage/html}/serializeContext.js +6 -6
  121. package/dist/esm/node/runtime/{html → renderPage/html}/stream/react-streaming.js +1 -1
  122. package/dist/esm/node/runtime/{html → renderPage/html}/stream.js +1 -1
  123. package/dist/esm/node/runtime/renderPage/loadPageConfigsLazyServerSide.d.ts +66 -17
  124. package/dist/esm/node/runtime/renderPage/loadPageConfigsLazyServerSide.js +18 -39
  125. package/dist/esm/node/runtime/renderPage/preparePageContextForPublicUsageServer.d.ts +2 -2
  126. package/dist/esm/node/runtime/renderPage/renderPageAfterRoute.d.ts +122 -32
  127. package/dist/esm/node/runtime/renderPage/renderPageAfterRoute.js +2 -2
  128. package/dist/esm/node/runtime/renderPage.d.ts +56 -12
  129. package/dist/esm/node/runtime/renderPage.js +1 -1
  130. package/dist/esm/node/vite/onLoad.js +1 -1
  131. package/dist/esm/node/vite/plugins/pluginBaseUrls.js +32 -28
  132. package/dist/esm/node/vite/plugins/pluginBuild/handleAssetsManifest.js +1 -1
  133. package/dist/esm/node/vite/plugins/pluginBuild/pluginBuildApp.js +24 -20
  134. package/dist/esm/node/vite/plugins/pluginBuild/pluginBuildConfig.js +4 -2
  135. package/dist/esm/node/vite/plugins/pluginBuild/pluginDistFileNames.js +76 -74
  136. package/dist/esm/node/vite/plugins/pluginBuild/pluginDistPackageJsonFile.js +18 -14
  137. package/dist/esm/node/vite/plugins/pluginBuild/pluginModuleBanner.js +18 -10
  138. package/dist/esm/node/vite/plugins/pluginBuild/pluginProdBuildEntry.js +4 -2
  139. package/dist/esm/node/vite/plugins/pluginBuild/pluginSuppressRollupWarning.js +20 -18
  140. package/dist/esm/node/vite/plugins/pluginCommon.js +8 -22
  141. package/dist/esm/node/vite/plugins/pluginDev.js +51 -47
  142. package/dist/esm/node/vite/plugins/pluginEnvVars.js +62 -57
  143. package/dist/esm/node/vite/plugins/pluginExtractAssets.js +107 -91
  144. package/dist/esm/node/vite/plugins/pluginExtractExportNames.js +27 -13
  145. package/dist/esm/node/vite/plugins/pluginFileEnv.js +107 -84
  146. package/dist/esm/node/vite/plugins/pluginNonRunnableDev.js +41 -22
  147. package/dist/esm/node/vite/plugins/pluginPreview.js +30 -24
  148. package/dist/esm/node/vite/plugins/pluginReplaceConstants.d.ts +11 -0
  149. package/dist/esm/node/vite/plugins/pluginReplaceConstants.js +58 -33
  150. package/dist/esm/node/vite/plugins/pluginSetGlobalContext.js +4 -2
  151. package/dist/esm/node/vite/plugins/pluginVirtualFiles/generateVirtualFileGlobalEntryWithOldDesign.js +2 -2
  152. package/dist/esm/node/vite/plugins/pluginVirtualFiles.js +56 -38
  153. package/dist/esm/node/vite/plugins/pluginWorkaroundCssModuleHmr.js +8 -6
  154. package/dist/esm/node/vite/shared/resolveVikeConfigInternal/configDefinitionsBuiltIn.js +3 -0
  155. package/dist/esm/node/vite/shared/resolveVikeConfigInternal/crawlPlusFiles.js +2 -2
  156. package/dist/esm/node/vite/shared/resolveVikeConfigInternal.d.ts +4 -8
  157. package/dist/esm/node/vite/shared/resolveVikeConfigInternal.js +22 -24
  158. package/dist/esm/shared/createGlobalContextShared.d.ts +75 -19
  159. package/dist/esm/shared/createGlobalContextShared.js +5 -23
  160. package/dist/esm/shared/createPageContextShared.d.ts +2 -7
  161. package/dist/esm/shared/createPageContextShared.js +2 -2
  162. package/dist/esm/shared/getPageFiles.d.ts +1 -1
  163. package/dist/esm/shared/hooks/execHook.d.ts +2 -2
  164. package/dist/esm/shared/hooks/getHook.d.ts +3 -3
  165. package/dist/esm/shared/page-configs/resolveVikeConfigPublic.d.ts +91 -31
  166. package/dist/esm/shared/page-configs/resolveVikeConfigPublic.js +62 -43
  167. package/dist/esm/types/Config/ConfigResolved.d.ts +8 -0
  168. package/dist/esm/types/Config.d.ts +14 -6
  169. package/dist/esm/types/PageContext.d.ts +8 -25
  170. package/dist/esm/types/VikeNamespace.d.ts +0 -27
  171. package/dist/esm/types/index.d.ts +2 -2
  172. package/dist/esm/utils/PROJECT_VERSION.d.ts +1 -1
  173. package/dist/esm/utils/PROJECT_VERSION.js +1 -1
  174. package/dist/esm/utils/assert.js +16 -1
  175. package/dist/esm/utils/assertNodeVersion.js +3 -1
  176. package/dist/esm/utils/assertVersion.d.ts +4 -3
  177. package/dist/esm/utils/assertVersion.js +23 -5
  178. package/dist/esm/utils/joinEnglish.js +2 -1
  179. package/dist/esm/utils/virtualFileId.d.ts +4 -0
  180. package/dist/esm/utils/virtualFileId.js +14 -11
  181. package/package.json +5 -5
  182. package/dist/cjs/types/Config/helpers.js +0 -2
  183. package/dist/esm/node/runtime/html/injectAssets/inferHtmlTags.d.ts +0 -9
  184. package/dist/esm/node/runtime/html/injectAssets/mergeScriptTags.d.ts +0 -2
  185. package/dist/esm/types/Config/PageContextConfig.d.ts +0 -15
  186. package/dist/esm/types/Config/helpers.d.ts +0 -10
  187. package/dist/esm/types/Config/helpers.js +0 -1
  188. /package/dist/cjs/node/runtime/{html → renderPage/html}/injectAssets/sanitizeJson.js +0 -0
  189. /package/dist/cjs/types/Config/{PageContextConfig.js → ConfigResolved.js} +0 -0
  190. /package/dist/esm/node/runtime/{html → renderPage/html}/injectAssets/injectAssets__public.d.ts +0 -0
  191. /package/dist/esm/node/runtime/{html → renderPage/html}/injectAssets/injectHtmlTags.d.ts +0 -0
  192. /package/dist/esm/node/runtime/{html → renderPage/html}/injectAssets/sanitizeJson.d.ts +0 -0
  193. /package/dist/esm/node/runtime/{html → renderPage/html}/injectAssets/sanitizeJson.js +0 -0
  194. /package/dist/esm/node/runtime/{html → renderPage/html}/propKeys.d.ts +0 -0
  195. /package/dist/esm/node/runtime/{html → renderPage/html}/stream/react-streaming.d.ts +0 -0
  196. /package/dist/esm/node/runtime/{html → renderPage/html}/stream.d.ts +0 -0
  197. /package/dist/esm/types/Config/{PageContextConfig.js → ConfigResolved.js} +0 -0
@@ -13,73 +13,100 @@ const parseEsModule_js_1 = require("../shared/parseEsModule.js");
13
13
  const normalizeId_js_1 = require("../shared/normalizeId.js");
14
14
  const resolveVikeConfigInternal_js_1 = require("../shared/resolveVikeConfigInternal.js");
15
15
  const isViteServerSide_js_1 = require("../shared/isViteServerSide.js");
16
+ const skipNodeModules = '/node_modules/'; // Only apply `.server.js` and `.client.js` to user files
17
+ const filterRolldown = {
18
+ id: {
19
+ include: ['client', 'server'].map((env) => `**/*${getSuffix(env)}*`),
20
+ exclude: [`**${skipNodeModules}**`],
21
+ },
22
+ };
23
+ const filterFunction = (id) => {
24
+ if (id.includes(skipNodeModules))
25
+ return false;
26
+ if (!id.includes(getSuffix('client')) && !id.includes(getSuffix('server')))
27
+ return false;
28
+ return true;
29
+ };
16
30
  function pluginFileEnv() {
17
31
  let config;
18
32
  let viteDevServer;
19
33
  return {
20
34
  name: 'vike:pluginFileEnv',
21
- load(id, options) {
22
- // In build, we use generateBundle() instead of the load() hook. Using load() works for dynamic imports in dev thanks to Vite's lazy transpiling, but it doesn't work in build because Rollup transpiles any dynamically imported module even if it's never actually imported.
23
- if (!viteDevServer)
24
- return;
25
- if (!(0, resolveVikeConfigInternal_js_1.isV1Design)())
26
- return;
27
- if (skip(id))
28
- return;
29
- // For `.vue` files: https://github.com/vikejs/vike/issues/1912#issuecomment-2394981475
30
- if (id.endsWith('?direct'))
31
- id = id.slice(0, -1 * '?direct'.length);
32
- const moduleInfo = viteDevServer.moduleGraph.getModuleById(id);
33
- (0, utils_js_1.assert)(moduleInfo);
34
- const importers = Array.from(moduleInfo.importers)
35
- .map((m) => m.id)
36
- .filter((id) => id !== null);
37
- assertFileEnv(id, (0, isViteServerSide_js_1.isViteServerSide_extraSafe)(config, this.environment, options), importers,
38
- // In dev, we only show a warning because we don't want to disrupt when the user plays with settings such as [ssr](https://vike.dev/ssr).
39
- true);
35
+ load: {
36
+ filter: filterRolldown,
37
+ handler(id, options) {
38
+ // In build, we use generateBundle() instead of the load() hook. Using load() works for dynamic imports in dev thanks to Vite's lazy transpiling, but it doesn't work in build because Rollup transpiles any dynamically imported module even if it's never actually imported.
39
+ if (!viteDevServer)
40
+ return;
41
+ if (!(0, resolveVikeConfigInternal_js_1.isV1Design)())
42
+ return;
43
+ if (skip(id, config.root))
44
+ return;
45
+ // For `.vue` files: https://github.com/vikejs/vike/issues/1912#issuecomment-2394981475
46
+ if (id.endsWith('?direct'))
47
+ id = id.slice(0, -1 * '?direct'.length);
48
+ const moduleInfo = viteDevServer.moduleGraph.getModuleById(id);
49
+ (0, utils_js_1.assert)(moduleInfo);
50
+ const importers = Array.from(moduleInfo.importers)
51
+ .map((m) => m.id)
52
+ .filter((id) => id !== null);
53
+ assertFileEnv(id, (0, isViteServerSide_js_1.isViteServerSide_extraSafe)(config, this.environment, options), importers,
54
+ // In dev, we only show a warning because we don't want to disrupt when the user plays with settings such as [ssr](https://vike.dev/ssr).
55
+ true);
56
+ },
40
57
  },
41
58
  // In production, we have to use transform() to replace modules with a runtime error because generateBundle() doesn't work for dynamic imports. In production, dynamic imports can only be verified at runtime.
42
- async transform(code, id, options) {
43
- id = (0, normalizeId_js_1.normalizeId)(id);
44
- // In dev, only using load() is enough as it also works for dynamic imports (see sibling comment).
45
- if (viteDevServer)
46
- return;
47
- if (skip(id))
48
- return;
49
- const isServerSide = (0, isViteServerSide_js_1.isViteServerSide_extraSafe)(config, this.environment, options);
50
- if (!isWrongEnv(id, isServerSide))
51
- return;
52
- const { importers } = this.getModuleInfo(id);
53
- // Throwing a verbose error doesn't waste client-side KBs as dynamic imports are code split.
54
- const errMsg = getErrorMessage(id, isServerSide, importers, false, true);
55
- // We have to inject empty exports to avoid Rollup complaining about missing exports, see https://gist.github.com/brillout/5ea45776e65bd65100a52ecd7bfda3ff
56
- const { exportNames } = await (0, parseEsModule_js_1.getExportNames)(code);
57
- return (0, utils_js_1.rollupSourceMapRemove)([
58
- `throw new Error(${JSON.stringify(errMsg)});`,
59
- ...exportNames.map((name) => name === 'default' ? 'export default undefined;' : `export const ${name} = undefined;`),
60
- ].join('\n'));
61
- },
62
- generateBundle() {
63
- Array.from(this.getModuleIds())
64
- .filter((id) => !skip(id))
65
- .forEach((moduleId) => {
66
- const mod = this.getModuleInfo(moduleId);
67
- const { importers } = mod;
68
- if (importers.length === 0) {
69
- // Dynamic imports can only be verified at runtime
70
- /* This assertion can fail: https://github.com/vikejs/vike/issues/2227
71
- assert(dynamicImporters.length > 0)
72
- */
59
+ transform: {
60
+ filter: filterRolldown,
61
+ async handler(code, id, options) {
62
+ id = (0, normalizeId_js_1.normalizeId)(id);
63
+ // In dev, only using load() is enough as it also works for dynamic imports (see sibling comment).
64
+ if (viteDevServer)
65
+ return;
66
+ if (skip(id, config.root))
73
67
  return;
74
- }
75
- assertFileEnv(moduleId, (0, isViteServerSide_js_1.isViteServerSide)(config, this.environment), importers, false);
76
- });
68
+ const isServerSide = (0, isViteServerSide_js_1.isViteServerSide_extraSafe)(config, this.environment, options);
69
+ if (!isWrongEnv(id, isServerSide))
70
+ return;
71
+ const { importers } = this.getModuleInfo(id);
72
+ // Throwing a verbose error doesn't waste client-side KBs as dynamic imports are code split.
73
+ const errMsg = getErrorMessage(id, isServerSide, importers, false, true);
74
+ // We have to inject empty exports to avoid Rollup complaining about missing exports, see https://gist.github.com/brillout/5ea45776e65bd65100a52ecd7bfda3ff
75
+ const { exportNames } = await (0, parseEsModule_js_1.getExportNames)(code);
76
+ return (0, utils_js_1.rollupSourceMapRemove)([
77
+ `throw new Error(${JSON.stringify(errMsg)});`,
78
+ ...exportNames.map((name) => name === 'default' ? 'export default undefined;' : `export const ${name} = undefined;`),
79
+ ].join('\n'));
80
+ },
81
+ },
82
+ generateBundle: {
83
+ handler() {
84
+ Array.from(this.getModuleIds())
85
+ .filter(filterFunction)
86
+ .filter((id) => !skip(id, config.root))
87
+ .forEach((moduleId) => {
88
+ const mod = this.getModuleInfo(moduleId);
89
+ const { importers } = mod;
90
+ if (importers.length === 0) {
91
+ // Dynamic imports can only be verified at runtime
92
+ /* This assertion can fail: https://github.com/vikejs/vike/issues/2227
93
+ assert(dynamicImporters.length > 0)
94
+ */
95
+ return;
96
+ }
97
+ assertFileEnv(moduleId, (0, isViteServerSide_js_1.isViteServerSide)(config, this.environment), importers, false);
98
+ });
99
+ },
77
100
  },
78
- configResolved(config_) {
79
- config = config_;
101
+ configResolved: {
102
+ handler(config_) {
103
+ config = config_;
104
+ },
80
105
  },
81
- configureServer(viteDevServer_) {
82
- viteDevServer = viteDevServer_;
106
+ configureServer: {
107
+ handler(viteDevServer_) {
108
+ viteDevServer = viteDevServer_;
109
+ },
83
110
  },
84
111
  };
85
112
  function assertFileEnv(moduleId, isServerSide, importers, onlyWarn) {
@@ -119,31 +146,27 @@ function pluginFileEnv() {
119
146
  }
120
147
  return errMsg;
121
148
  }
122
- function isWrongEnv(moduleId, isServerSide) {
123
- const modulePath = getModulePath(moduleId);
124
- const suffixWrong = getSuffix(isServerSide ? 'client' : 'server');
125
- return modulePath.includes(suffixWrong);
126
- }
127
- function skip(id) {
128
- // TO-DO/next-major-release: remove
129
- if (pluginExtractAssets_js_1.extractAssetsRE.test(id) || pluginExtractExportNames_js_1.extractExportNamesRE.test(id))
130
- return true;
131
- if (!id.includes(getSuffix('client')) && !id.includes(getSuffix('server')))
132
- return true;
133
- if (getModulePath(id).endsWith('.css'))
134
- return true;
135
- // Apply `.server.js` and `.client.js` only to user files
136
- if (id.includes('/node_modules/'))
137
- return true;
138
- // Only user files
139
- if (!id.startsWith(config.root))
140
- return true;
141
- return false;
142
- }
143
- function getSuffix(env) {
144
- return `.${env}.`;
145
- }
146
- function getModulePath(moduleId) {
147
- return moduleId.split('?')[0];
148
- }
149
+ }
150
+ function isWrongEnv(moduleId, isServerSide) {
151
+ const modulePath = getModulePath(moduleId);
152
+ const suffixWrong = getSuffix(isServerSide ? 'client' : 'server');
153
+ return modulePath.includes(suffixWrong);
154
+ }
155
+ function skip(id, userRootDir) {
156
+ (0, utils_js_1.assert)(filterFunction(id));
157
+ // TO-DO/next-major-release: remove
158
+ if (pluginExtractAssets_js_1.extractAssetsRE.test(id) || pluginExtractExportNames_js_1.extractExportNamesRE.test(id))
159
+ return true;
160
+ if (getModulePath(id).endsWith('.css'))
161
+ return true;
162
+ // Skip linked dependencies
163
+ if (!id.startsWith(userRootDir))
164
+ return true;
165
+ return false;
166
+ }
167
+ function getSuffix(env) {
168
+ return `.${env}.`;
169
+ }
170
+ function getModulePath(moduleId) {
171
+ return moduleId.split('?')[0];
149
172
  }
@@ -6,6 +6,17 @@ const retrievePageAssetsDev_js_1 = require("../../runtime/renderPage/getPageAsse
6
6
  const getViteConfigRuntime_js_1 = require("../shared/getViteConfigRuntime.js");
7
7
  const getMagicString_js_1 = require("../shared/getMagicString.js");
8
8
  (0, utils_js_1.assertIsNotProductionRuntime)();
9
+ const distFileIsNonRunnableDev = (0, utils_js_1.requireResolveDistFile)('dist/esm/utils/isNonRunnableDev.js');
10
+ const distFileGlobalContext = (0, utils_js_1.requireResolveDistFile)('dist/esm/node/runtime/globalContext.js');
11
+ const filterRolldown = {
12
+ id: {
13
+ include: [distFileIsNonRunnableDev, distFileGlobalContext].map((filePath) => new RegExp(`^${(0, utils_js_1.escapeRegex)(filePath)}($|${(0, utils_js_1.escapeRegex)('?')}.*)`)),
14
+ },
15
+ };
16
+ const filterFunction = (id) => {
17
+ const idWithoutQuery = getIdWithoutQuery(id);
18
+ return idWithoutQuery === distFileIsNonRunnableDev || idWithoutQuery === distFileGlobalContext;
19
+ };
9
20
  function getViteRpcFunctions(viteDevServer) {
10
21
  return {
11
22
  async transformIndexHtmlRPC(html) {
@@ -20,32 +31,40 @@ function getViteRpcFunctions(viteDevServer) {
20
31
  };
21
32
  }
22
33
  function pluginNonRunnableDev() {
23
- const distFileIsNonRunnableDev = (0, utils_js_1.requireResolveDistFile)('dist/esm/utils/isNonRunnableDev.js');
24
- const distFileGlobalContext = (0, utils_js_1.requireResolveDistFile)('dist/esm/node/runtime/globalContext.js');
25
34
  let config;
26
35
  return {
27
36
  name: 'vike:pluginNonRunnableDev',
28
- configureServer(viteDevServer) {
29
- (0, utils_js_1.createViteRPC)(viteDevServer, getViteRpcFunctions);
37
+ apply: (_, configEnv) => (0, utils_js_1.isDevCheck)(configEnv),
38
+ configureServer: {
39
+ handler(viteDevServer) {
40
+ (0, utils_js_1.createViteRPC)(viteDevServer, getViteRpcFunctions);
41
+ },
30
42
  },
31
- configResolved(config_) {
32
- config = config_;
43
+ configResolved: {
44
+ handler(config_) {
45
+ config = config_;
46
+ },
33
47
  },
34
- transform(code, id) {
35
- if (!config._isDev)
36
- return;
37
- if (id !== distFileIsNonRunnableDev && id !== distFileGlobalContext)
38
- return;
39
- if ((0, utils_js_1.isRunnableDevEnvironment)(this.environment))
40
- return;
41
- const { magicString, getMagicStringResult } = (0, getMagicString_js_1.getMagicString)(code, id);
42
- if (id === distFileIsNonRunnableDev) {
43
- magicString.replaceAll('__VIKE__IS_NON_RUNNABLE_DEV', JSON.stringify(true));
44
- }
45
- if (id === distFileGlobalContext) {
46
- magicString.replaceAll('__VIKE__DYNAMIC_IMPORT', 'import');
47
- }
48
- return getMagicStringResult();
48
+ transform: {
49
+ filter: filterRolldown,
50
+ handler(code, id) {
51
+ (0, utils_js_1.assert)(config._isDev);
52
+ (0, utils_js_1.assert)(filterFunction(id));
53
+ const idWithoutQuery = getIdWithoutQuery(id);
54
+ if ((0, utils_js_1.isRunnableDevEnvironment)(this.environment))
55
+ return;
56
+ const { magicString, getMagicStringResult } = (0, getMagicString_js_1.getMagicString)(code, id);
57
+ if (idWithoutQuery === distFileIsNonRunnableDev) {
58
+ magicString.replaceAll('__VIKE__IS_NON_RUNNABLE_DEV', JSON.stringify(true));
59
+ }
60
+ if (idWithoutQuery === distFileGlobalContext) {
61
+ magicString.replaceAll('__VIKE__DYNAMIC_IMPORT', 'import');
62
+ }
63
+ return getMagicStringResult();
64
+ },
49
65
  },
50
66
  };
51
67
  }
68
+ function getIdWithoutQuery(id) {
69
+ return id.split('?')[0];
70
+ }
@@ -19,32 +19,38 @@ function pluginPreview() {
19
19
  return {
20
20
  name: 'vike:pluginPreview',
21
21
  apply: utils_js_1.applyPreview,
22
- config() {
23
- return {
24
- appType: 'custom',
25
- };
22
+ config: {
23
+ handler() {
24
+ return {
25
+ appType: 'custom',
26
+ };
27
+ },
26
28
  },
27
- async configResolved(config_) {
28
- config = config_;
29
- vikeConfig = await (0, resolveVikeConfigInternal_js_1.getVikeConfigInternal)();
30
- (0, pluginDev_js_1.logDockerHint)(config.preview.host);
31
- // vikeConfig = await getVikeConfig(config)
29
+ configResolved: {
30
+ async handler(config_) {
31
+ config = config_;
32
+ vikeConfig = await (0, resolveVikeConfigInternal_js_1.getVikeConfigInternal)();
33
+ (0, pluginDev_js_1.logDockerHint)(config.preview.host);
34
+ // vikeConfig = await getVikeConfig(config)
35
+ },
32
36
  },
33
- configurePreviewServer(server) {
34
- /* - Couldn't make `appType: 'mpa'` work as of npm:@brillout/vite@5.0.0-beta.14.0426910c
35
- - This ugly hack to set appType for preview won't be need once https://github.com/vitejs/vite/pull/14855 is merged.
36
- config.appType = 'mpa'
37
- */
38
- return () => {
39
- const { isPrerenderingEnabledForAllPages, isPrerenderingEnabled } = vikeConfig.prerenderContext;
40
- assertDist(isPrerenderingEnabledForAllPages);
41
- // We cannot re-use Vite's static middleware: https://github.com/vitejs/vite/pull/14836#issuecomment-1788540300
42
- addStaticAssetsMiddleware(server.middlewares);
43
- if (!isPrerenderingEnabledForAllPages) {
44
- (0, addSsrMiddleware_js_1.addSsrMiddleware)(server.middlewares, config, true, isPrerenderingEnabled);
45
- }
46
- addStatic404Middleware(server.middlewares);
47
- };
37
+ configurePreviewServer: {
38
+ handler(server) {
39
+ /* - Couldn't make `appType: 'mpa'` work as of npm:@brillout/vite@5.0.0-beta.14.0426910c
40
+ - This ugly hack to set appType for preview won't be need once https://github.com/vitejs/vite/pull/14855 is merged.
41
+ config.appType = 'mpa'
42
+ */
43
+ return () => {
44
+ const { isPrerenderingEnabledForAllPages, isPrerenderingEnabled } = vikeConfig.prerenderContext;
45
+ assertDist(isPrerenderingEnabledForAllPages);
46
+ // We cannot re-use Vite's static middleware: https://github.com/vitejs/vite/pull/14836#issuecomment-1788540300
47
+ addStaticAssetsMiddleware(server.middlewares);
48
+ if (!isPrerenderingEnabledForAllPages) {
49
+ (0, addSsrMiddleware_js_1.addSsrMiddleware)(server.middlewares, config, true, isPrerenderingEnabled);
50
+ }
51
+ addStatic404Middleware(server.middlewares);
52
+ };
53
+ },
48
54
  },
49
55
  };
50
56
  function assertDist(isPrerenderingEnabledForAllPages) {
@@ -1,51 +1,77 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.filterRolldown = exports.filterFunction = void 0;
3
4
  exports.pluginReplaceConstants = pluginReplaceConstants;
4
5
  const utils_js_1 = require("../utils.js");
5
6
  const normalizeId_js_1 = require("../shared/normalizeId.js");
6
7
  const isViteServerSide_js_1 = require("../shared/isViteServerSide.js");
7
8
  const getMagicString_js_1 = require("../shared/getMagicString.js");
9
+ const skipNodeModules = '/node_modules/';
10
+ const skipIrrelevant = '({}).';
11
+ const filterRolldown = {
12
+ id: {
13
+ exclude: `**${skipNodeModules}**`,
14
+ },
15
+ code: {
16
+ include: skipIrrelevant,
17
+ },
18
+ };
19
+ exports.filterRolldown = filterRolldown;
20
+ const filterFunction = (id, code) => {
21
+ if (id.includes(skipNodeModules))
22
+ return false;
23
+ if (!code.includes(skipIrrelevant))
24
+ return false;
25
+ return true;
26
+ };
27
+ exports.filterFunction = filterFunction;
8
28
  function pluginReplaceConstants() {
9
29
  let config;
10
30
  return {
11
31
  name: 'vike:pluginReplaceConstants',
12
32
  enforce: 'post',
13
33
  apply: 'build',
14
- configResolved(config_) {
15
- config = config_;
34
+ configResolved: {
35
+ handler(config_) {
36
+ config = config_;
37
+ },
16
38
  },
17
- transform(code, id, options) {
18
- id = (0, normalizeId_js_1.normalizeId)(id);
19
- (0, utils_js_1.assertPosixPath)(id);
20
- if (id.includes('/node_modules/'))
21
- return;
22
- (0, utils_js_1.assertPosixPath)(config.root);
23
- if (!id.startsWith(config.root))
24
- return;
25
- if (!code.includes('({}).'))
26
- return;
27
- const isBuild = config.command === 'build';
28
- (0, utils_js_1.assert)(isBuild);
29
- // Used by vike.dev
30
- // https://github.com/vikejs/vike/blob/08a1ff55c80ddca64ca6d4417fefd45fefeb4ffb/docs/vite.config.ts#L12
31
- // @ts-expect-error
32
- if (config._skipVikeReplaceConstants?.(id))
33
- return;
34
- const { magicString, getMagicStringResult } = (0, getMagicString_js_1.getMagicString)(code, id);
35
- const constantsMap = [];
36
- constantsMap.push({
37
- constants: ['pageContext.isClientSide', 'globalContext.isClientSide', 'pageContext.globalContext.isClientSide'],
38
- replacement: !(0, isViteServerSide_js_1.isViteServerSide_extraSafe)(config, this.environment, options),
39
- });
40
- constantsMap.forEach(({ constants, replacement }) => {
41
- if (!constants.some((c) => code.includes(c)))
39
+ transform: {
40
+ filter: filterRolldown,
41
+ handler(code, id, options) {
42
+ id = (0, normalizeId_js_1.normalizeId)(id);
43
+ (0, utils_js_1.assertPosixPath)(id);
44
+ (0, utils_js_1.assertPosixPath)(config.root);
45
+ if (!id.startsWith(config.root))
46
+ return; // skip linked dependencies
47
+ (0, utils_js_1.assert)(filterFunction(id, code));
48
+ const isBuild = config.command === 'build';
49
+ (0, utils_js_1.assert)(isBuild);
50
+ // Used by vike.dev
51
+ // https://github.com/vikejs/vike/blob/08a1ff55c80ddca64ca6d4417fefd45fefeb4ffb/docs/vite.config.ts#L12
52
+ // @ts-expect-error
53
+ if (config._skipVikeReplaceConstants?.(id))
42
54
  return;
43
- const regExp = getConstantRegExp(constants);
44
- magicString.replaceAll(regExp, JSON.stringify(replacement));
45
- });
46
- if (!magicString.hasChanged())
47
- return null;
48
- return getMagicStringResult();
55
+ const { magicString, getMagicStringResult } = (0, getMagicString_js_1.getMagicString)(code, id);
56
+ const constantsMap = [];
57
+ constantsMap.push({
58
+ constants: [
59
+ 'pageContext.isClientSide',
60
+ 'globalContext.isClientSide',
61
+ 'pageContext.globalContext.isClientSide',
62
+ ],
63
+ replacement: !(0, isViteServerSide_js_1.isViteServerSide_extraSafe)(config, this.environment, options),
64
+ });
65
+ constantsMap.forEach(({ constants, replacement }) => {
66
+ if (!constants.some((c) => code.includes(c)))
67
+ return;
68
+ const regExp = getConstantRegExp(constants);
69
+ magicString.replaceAll(regExp, JSON.stringify(replacement));
70
+ });
71
+ if (!magicString.hasChanged())
72
+ return null;
73
+ return getMagicStringResult();
74
+ },
49
75
  },
50
76
  };
51
77
  }
@@ -22,8 +22,10 @@ function pluginSetGlobalContext() {
22
22
  (0, utils_js_1.markSetup_viteDevServer)();
23
23
  },
24
24
  },
25
- configurePreviewServer() {
26
- (0, utils_js_1.markSetup_vitePreviewServer)();
25
+ configurePreviewServer: {
26
+ handler() {
27
+ (0, utils_js_1.markSetup_vitePreviewServer)();
28
+ },
27
29
  },
28
30
  config: {
29
31
  order: 'pre',
@@ -144,7 +144,7 @@ function getGlobs(globRoots, isBuild, fileType, query, isV1Design) {
144
144
  const globExcludePath = globRoot.excludeDir ? `'!${getGlobPath(globRoot.excludeDir, fileType)}'` : null;
145
145
  const globOptions = { eager: isEager };
146
146
  if (query) {
147
- const isNewViteInterface = (0, utils_js_1.isVersionOrAbove)(vite_1.version, '5.1.0');
147
+ const isNewViteInterface = (0, utils_js_1.isVersionMatch)(vite_1.version, ['5.1.0']);
148
148
  if (isNewViteInterface &&
149
149
  // When used for the old design, the new syntax breaks Vike's CI (surprinsigly so). I couldn't reproduce locally (I didn't dig much).
150
150
  isV1Design) {
@@ -17,51 +17,67 @@ const globalContext_js_1 = require("../../runtime/globalContext.js");
17
17
  const crawlPlusFiles_js_1 = require("../shared/resolveVikeConfigInternal/crawlPlusFiles.js");
18
18
  const transpileAndExecuteFile_js_1 = require("../shared/resolveVikeConfigInternal/transpileAndExecuteFile.js");
19
19
  const getVikeConfigError_js_1 = require("../../shared/getVikeConfigError.js");
20
+ const filterRolldown = {
21
+ id: {
22
+ include: new RegExp(`^(${(0, utils_js_1.escapeRegex)(utils_js_1.virtualFileIdPrefix1)}|${(0, utils_js_1.escapeRegex)(utils_js_1.virtualFileIdPrefix2)})`),
23
+ },
24
+ };
25
+ const filterFunction = (id) => (0, utils_js_1.isVirtualFileId)(id);
20
26
  function pluginVirtualFiles() {
21
27
  let config;
22
28
  return {
23
29
  name: 'vike:pluginVirtualFiles',
24
- async configResolved(config_) {
25
- config = config_;
26
- // TO-DO/next-major-release: remove
27
- if (!(0, resolveVikeConfigInternal_js_1.isV1Design)())
28
- config.experimental.importGlobRestoreExtension = true;
30
+ configResolved: {
31
+ async handler(config_) {
32
+ config = config_;
33
+ // TO-DO/next-major-release: remove
34
+ if (!(0, resolveVikeConfigInternal_js_1.isV1Design)())
35
+ config.experimental.importGlobRestoreExtension = true;
36
+ },
29
37
  },
30
- resolveId(id) {
31
- if ((0, utils_js_1.isVirtualFileId)(id)) {
38
+ resolveId: {
39
+ filter: filterRolldown,
40
+ handler(id) {
41
+ (0, utils_js_1.assert)(filterFunction(id));
32
42
  return (0, utils_js_1.addVirtualFileIdPrefix)(id);
33
- }
34
- },
35
- async handleHotUpdate(ctx) {
36
- try {
37
- return await handleHotUpdate(ctx, config);
38
- }
39
- catch (err) {
40
- // Vite swallows errors thrown by handleHotUpdate()
41
- console.error(err);
42
- throw err;
43
- }
43
+ },
44
44
  },
45
- async load(id, options) {
46
- if (!(0, utils_js_1.isVirtualFileId)(id))
47
- return undefined;
48
- id = (0, utils_js_1.removeVirtualFileIdPrefix)(id);
49
- const isDev = config._isDev;
50
- (0, utils_js_1.assert)(typeof isDev === 'boolean');
51
- const idParsed = (0, virtualFileId_js_1.parseVirtualFileId)(id);
52
- if (idParsed) {
53
- if (idParsed.type === 'page-entry') {
54
- const code = await (0, generateVirtualFilePageEntry_js_1.generateVirtualFilePageEntry)(id, isDev);
55
- return code;
45
+ handleHotUpdate: {
46
+ async handler(ctx) {
47
+ try {
48
+ return await handleHotUpdate(ctx, config);
56
49
  }
57
- if (idParsed.type === 'global-entry') {
58
- const code = await (0, generateVirtualFileGlobalEntryWithOldDesign_js_1.generateVirtualFileGlobalEntryWithOldDesign)(id, options, config, this.environment, isDev);
59
- return code;
50
+ catch (err) {
51
+ // Vite swallows errors thrown by handleHotUpdate()
52
+ console.error(err);
53
+ throw err;
60
54
  }
61
- }
55
+ },
56
+ },
57
+ load: {
58
+ filter: filterRolldown,
59
+ async handler(id, options) {
60
+ (0, utils_js_1.assert)(filterFunction(id));
61
+ id = (0, utils_js_1.removeVirtualFileIdPrefix)(id);
62
+ const isDev = config._isDev;
63
+ (0, utils_js_1.assert)(typeof isDev === 'boolean');
64
+ const idParsed = (0, virtualFileId_js_1.parseVirtualFileId)(id);
65
+ if (idParsed) {
66
+ if (idParsed.type === 'page-entry') {
67
+ const code = await (0, generateVirtualFilePageEntry_js_1.generateVirtualFilePageEntry)(id, isDev);
68
+ return code;
69
+ }
70
+ if (idParsed.type === 'global-entry') {
71
+ const code = await (0, generateVirtualFileGlobalEntryWithOldDesign_js_1.generateVirtualFileGlobalEntryWithOldDesign)(id, options, config, this.environment, isDev);
72
+ return code;
73
+ }
74
+ }
75
+ },
62
76
  },
63
- configureServer(server) {
64
- handleFileAddRemove(server, config);
77
+ configureServer: {
78
+ handler(server) {
79
+ handleFileAddRemove(server, config);
80
+ },
65
81
  },
66
82
  };
67
83
  }
@@ -130,7 +146,9 @@ async function handleHotUpdate(ctx, config) {
130
146
  // Ensure we invalidate `file` *before* server.ssrLoadModule() in updateUserFiles()
131
147
  // Vite already invalidates it, but *after* handleHotUpdate() and thus after server.ssrLoadModule()
132
148
  ctx.modules.forEach((mod) => server.moduleGraph.invalidateModule(mod));
133
- (0, globalContext_js_1.updateUserFiles)();
149
+ if ((0, globalContext_js_1.isRunnable)(server)) {
150
+ await (0, globalContext_js_1.updateUserFiles)();
151
+ }
134
152
  }
135
153
  }
136
154
  }
@@ -4,12 +4,14 @@ exports.pluginWorkaroundCssModuleHmr = pluginWorkaroundCssModuleHmr;
4
4
  function pluginWorkaroundCssModuleHmr() {
5
5
  return {
6
6
  name: 'vike:pluginWorkaroundCssModuleHmr',
7
- handleHotUpdate(ctx) {
8
- // prevent full reload due to non self-accepting css module.
9
- // here only "?direct" module should be filtered out as it doesn't have a parent module.
10
- if (ctx.file.includes('module.css')) {
11
- return ctx.modules.filter((m) => !m.id?.includes('?direct'));
12
- }
7
+ handleHotUpdate: {
8
+ handler(ctx) {
9
+ // prevent full reload due to non self-accepting css module.
10
+ // here only "?direct" module should be filtered out as it doesn't have a parent module.
11
+ if (ctx.file.includes('module.css')) {
12
+ return ctx.modules.filter((m) => !m.id?.includes('?direct'));
13
+ }
14
+ },
13
15
  },
14
16
  };
15
17
  }
@@ -173,6 +173,9 @@ const configDefinitionsBuiltIn = {
173
173
  env: { config: true },
174
174
  global: true,
175
175
  },
176
+ csp: {
177
+ env: { server: true },
178
+ },
176
179
  injectScriptsAt: {
177
180
  env: { server: true },
178
181
  },