vike 0.4.238 → 0.4.239-commit-050a4a3

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 (191) hide show
  1. package/dist/cjs/node/prerender/resolvePrerenderConfig.js +3 -2
  2. package/dist/cjs/node/runtime/globalContext.js +1 -0
  3. package/dist/cjs/node/runtime/index.js +3 -3
  4. package/dist/cjs/node/runtime/page-files/setup.js +3 -1
  5. package/dist/cjs/node/runtime/renderPage/createHttpResponse.js +2 -9
  6. package/dist/cjs/node/runtime/renderPage/createPageContextServerSide.js +2 -2
  7. package/dist/cjs/node/runtime/renderPage/csp.js +47 -0
  8. package/dist/cjs/node/runtime/renderPage/execHookOnRenderHtml.js +2 -2
  9. package/dist/cjs/node/runtime/renderPage/getEarlyHints.js +1 -1
  10. package/dist/cjs/node/runtime/renderPage/getHttpResponseBody.js +2 -2
  11. package/dist/cjs/node/runtime/renderPage/headersResponse.js +48 -0
  12. package/dist/cjs/node/runtime/{html → renderPage/html}/injectAssets/getHtmlTags.js +16 -13
  13. package/dist/cjs/node/runtime/{html → renderPage/html}/injectAssets/getViteDevScript.js +1 -1
  14. package/dist/cjs/node/runtime/{html → renderPage/html}/injectAssets/inferHtmlTags.js +8 -6
  15. package/dist/cjs/node/runtime/{html → renderPage/html}/injectAssets/injectAssets__public.js +1 -1
  16. package/dist/cjs/node/runtime/{html → renderPage/html}/injectAssets/injectHtmlTags.js +1 -1
  17. package/dist/cjs/node/runtime/{html → renderPage/html}/injectAssets/mergeScriptTags.js +5 -3
  18. package/dist/cjs/node/runtime/{html → renderPage/html}/injectAssets.js +2 -2
  19. package/dist/cjs/node/runtime/{html → renderPage/html}/propKeys.js +1 -1
  20. package/dist/cjs/node/runtime/{html → renderPage/html}/renderHtml.js +1 -1
  21. package/dist/cjs/node/runtime/{html → renderPage/html}/serializeContext.js +6 -6
  22. package/dist/cjs/node/runtime/{html → renderPage/html}/stream/react-streaming.js +1 -1
  23. package/dist/cjs/node/runtime/{html → renderPage/html}/stream.js +1 -1
  24. package/dist/cjs/node/runtime/renderPage/loadPageConfigsLazyServerSide.js +17 -38
  25. package/dist/cjs/node/runtime/renderPage/renderPageAfterRoute.js +2 -2
  26. package/dist/cjs/node/runtime/renderPage.js +1 -1
  27. package/dist/cjs/node/vite/onLoad.js +1 -1
  28. package/dist/cjs/node/vite/plugins/pluginBaseUrls.js +32 -28
  29. package/dist/cjs/node/vite/plugins/pluginBuild/handleAssetsManifest.js +1 -1
  30. package/dist/cjs/node/vite/plugins/pluginBuild/pluginBuildApp.js +24 -20
  31. package/dist/cjs/node/vite/plugins/pluginBuild/pluginBuildConfig.js +4 -2
  32. package/dist/cjs/node/vite/plugins/pluginBuild/pluginDistFileNames.js +76 -74
  33. package/dist/cjs/node/vite/plugins/pluginBuild/pluginDistPackageJsonFile.js +18 -14
  34. package/dist/cjs/node/vite/plugins/pluginBuild/pluginModuleBanner.js +4 -2
  35. package/dist/cjs/node/vite/plugins/pluginBuild/pluginProdBuildEntry.js +4 -2
  36. package/dist/cjs/node/vite/plugins/pluginBuild/pluginSuppressRollupWarning.js +20 -18
  37. package/dist/cjs/node/vite/plugins/pluginCommon.js +7 -21
  38. package/dist/cjs/node/vite/plugins/pluginDev.js +51 -47
  39. package/dist/cjs/node/vite/plugins/pluginEnvVars.js +63 -57
  40. package/dist/cjs/node/vite/plugins/pluginExtractAssets.js +101 -91
  41. package/dist/cjs/node/vite/plugins/pluginExtractExportNames.js +24 -16
  42. package/dist/cjs/node/vite/plugins/pluginFileEnv.js +67 -57
  43. package/dist/cjs/node/vite/plugins/pluginNonRunnableDev.js +26 -19
  44. package/dist/cjs/node/vite/plugins/pluginPreview.js +30 -24
  45. package/dist/cjs/node/vite/plugins/pluginReplaceConstants.js +41 -33
  46. package/dist/cjs/node/vite/plugins/pluginSetGlobalContext.js +4 -2
  47. package/dist/cjs/node/vite/plugins/pluginVirtualFiles/generateVirtualFileGlobalEntryWithOldDesign.js +1 -1
  48. package/dist/cjs/node/vite/plugins/pluginVirtualFiles.js +50 -37
  49. package/dist/cjs/node/vite/plugins/pluginWorkaroundCssModuleHmr.js +8 -6
  50. package/dist/cjs/node/vite/shared/resolveVikeConfigInternal/configDefinitionsBuiltIn.js +3 -0
  51. package/dist/cjs/node/vite/shared/resolveVikeConfigInternal/crawlPlusFiles.js +1 -1
  52. package/dist/cjs/node/vite/shared/resolveVikeConfigInternal.js +20 -22
  53. package/dist/cjs/shared/createGlobalContextShared.js +4 -22
  54. package/dist/cjs/shared/createPageContextShared.js +2 -2
  55. package/dist/cjs/shared/page-configs/resolveVikeConfigPublic.js +62 -43
  56. package/dist/cjs/utils/PROJECT_VERSION.js +1 -1
  57. package/dist/cjs/utils/assert.js +16 -1
  58. package/dist/cjs/utils/assertNodeVersion.js +3 -1
  59. package/dist/cjs/utils/assertVersion.js +26 -5
  60. package/dist/cjs/utils/joinEnglish.js +2 -1
  61. package/dist/esm/client/runtime-client-routing/createPageContextClientSide.d.ts +39 -16
  62. package/dist/esm/client/runtime-client-routing/createPageContextClientSide.js +1 -1
  63. package/dist/esm/client/runtime-client-routing/getPageContextCurrent.d.ts +2 -2
  64. package/dist/esm/client/runtime-client-routing/getPageContextFromHooks.d.ts +97 -83
  65. package/dist/esm/client/runtime-client-routing/globalContext.d.ts +38 -10
  66. package/dist/esm/client/runtime-client-routing/prefetch/getPrefetchSettings.d.ts +2 -2
  67. package/dist/esm/client/runtime-client-routing/prefetch.d.ts +2 -2
  68. package/dist/esm/client/runtime-client-routing/prefetch.js +2 -2
  69. package/dist/esm/client/runtime-client-routing/preparePageContextForPublicUsageClient.d.ts +2 -2
  70. package/dist/esm/client/runtime-client-routing/renderPageClientSide.d.ts +43 -28
  71. package/dist/esm/client/runtime-server-routing/createPageContextClientSide.d.ts +39 -16
  72. package/dist/esm/client/runtime-server-routing/createPageContextClientSide.js +1 -1
  73. package/dist/esm/client/runtime-server-routing/globalContext.d.ts +38 -10
  74. package/dist/esm/client/runtime-server-routing/preparePageContextForPublicUsageClient.d.ts +2 -2
  75. package/dist/esm/client/shared/createGetGlobalContextClient.d.ts +38 -10
  76. package/dist/esm/client/shared/execHookOnRenderClient.d.ts +2 -2
  77. package/dist/esm/client/shared/loadPageConfigsLazyClientSide.d.ts +1 -1
  78. package/dist/esm/client/shared/loadPageConfigsLazyClientSide.js +2 -3
  79. package/dist/esm/client/shared/preparePageContextForPublicUsageClientShared.d.ts +2 -2
  80. package/dist/esm/node/prerender/resolvePrerenderConfig.js +4 -3
  81. package/dist/esm/node/prerender/runPrerender.d.ts +57 -14
  82. package/dist/esm/node/runtime/globalContext.d.ts +154 -40
  83. package/dist/esm/node/runtime/globalContext.js +1 -0
  84. package/dist/esm/node/runtime/index.d.ts +3 -3
  85. package/dist/esm/node/runtime/index.js +3 -3
  86. package/dist/esm/node/runtime/page-files/setup.js +3 -1
  87. package/dist/esm/node/runtime/renderPage/createHttpResponse.d.ts +1 -1
  88. package/dist/esm/node/runtime/renderPage/createHttpResponse.js +2 -9
  89. package/dist/esm/node/runtime/renderPage/createPageContextServerSide.d.ts +52 -10
  90. package/dist/esm/node/runtime/renderPage/createPageContextServerSide.js +2 -2
  91. package/dist/esm/node/runtime/renderPage/csp.d.ts +12 -0
  92. package/dist/esm/node/runtime/renderPage/csp.js +45 -0
  93. package/dist/esm/node/runtime/renderPage/execHookOnRenderHtml.d.ts +2 -2
  94. package/dist/esm/node/runtime/renderPage/execHookOnRenderHtml.js +2 -2
  95. package/dist/esm/node/runtime/renderPage/execHookServer.d.ts +2 -2
  96. package/dist/esm/node/runtime/renderPage/getEarlyHints.js +1 -1
  97. package/dist/esm/node/runtime/renderPage/getHttpResponseBody.d.ts +2 -2
  98. package/dist/esm/node/runtime/renderPage/getHttpResponseBody.js +2 -2
  99. package/dist/esm/node/runtime/renderPage/headersResponse.d.ts +10 -0
  100. package/dist/esm/node/runtime/renderPage/headersResponse.js +46 -0
  101. package/dist/esm/node/runtime/{html → renderPage/html}/injectAssets/getHtmlTags.d.ts +1 -1
  102. package/dist/esm/node/runtime/{html → renderPage/html}/injectAssets/getHtmlTags.js +16 -13
  103. package/dist/esm/node/runtime/{html → renderPage/html}/injectAssets/getViteDevScript.d.ts +1 -1
  104. package/dist/esm/node/runtime/{html → renderPage/html}/injectAssets/getViteDevScript.js +1 -1
  105. package/dist/esm/node/runtime/renderPage/html/injectAssets/inferHtmlTags.d.ts +10 -0
  106. package/dist/esm/node/runtime/{html → renderPage/html}/injectAssets/inferHtmlTags.js +7 -5
  107. package/dist/esm/node/runtime/{html → renderPage/html}/injectAssets/injectAssets__public.js +1 -1
  108. package/dist/esm/node/runtime/{html → renderPage/html}/injectAssets/injectHtmlTags.js +1 -1
  109. package/dist/esm/node/runtime/renderPage/html/injectAssets/mergeScriptTags.d.ts +3 -0
  110. package/dist/esm/node/runtime/{html → renderPage/html}/injectAssets/mergeScriptTags.js +6 -4
  111. package/dist/esm/node/runtime/{html → renderPage/html}/injectAssets.d.ts +2 -2
  112. package/dist/esm/node/runtime/{html → renderPage/html}/injectAssets.js +2 -2
  113. package/dist/esm/node/runtime/{html → renderPage/html}/propKeys.js +1 -1
  114. package/dist/esm/node/runtime/{html → renderPage/html}/renderHtml.d.ts +1 -1
  115. package/dist/esm/node/runtime/{html → renderPage/html}/renderHtml.js +1 -1
  116. package/dist/esm/node/runtime/{html → renderPage/html}/serializeContext.d.ts +6 -5
  117. package/dist/esm/node/runtime/{html → renderPage/html}/serializeContext.js +6 -6
  118. package/dist/esm/node/runtime/{html → renderPage/html}/stream/react-streaming.js +1 -1
  119. package/dist/esm/node/runtime/{html → renderPage/html}/stream.js +1 -1
  120. package/dist/esm/node/runtime/renderPage/loadPageConfigsLazyServerSide.d.ts +62 -15
  121. package/dist/esm/node/runtime/renderPage/loadPageConfigsLazyServerSide.js +18 -39
  122. package/dist/esm/node/runtime/renderPage/preparePageContextForPublicUsageServer.d.ts +2 -2
  123. package/dist/esm/node/runtime/renderPage/renderPageAfterRoute.d.ts +114 -28
  124. package/dist/esm/node/runtime/renderPage/renderPageAfterRoute.js +2 -2
  125. package/dist/esm/node/runtime/renderPage.d.ts +52 -10
  126. package/dist/esm/node/runtime/renderPage.js +1 -1
  127. package/dist/esm/node/vite/onLoad.js +1 -1
  128. package/dist/esm/node/vite/plugins/pluginBaseUrls.js +32 -28
  129. package/dist/esm/node/vite/plugins/pluginBuild/handleAssetsManifest.js +1 -1
  130. package/dist/esm/node/vite/plugins/pluginBuild/pluginBuildApp.js +24 -20
  131. package/dist/esm/node/vite/plugins/pluginBuild/pluginBuildConfig.js +4 -2
  132. package/dist/esm/node/vite/plugins/pluginBuild/pluginDistFileNames.js +76 -74
  133. package/dist/esm/node/vite/plugins/pluginBuild/pluginDistPackageJsonFile.js +18 -14
  134. package/dist/esm/node/vite/plugins/pluginBuild/pluginModuleBanner.js +4 -2
  135. package/dist/esm/node/vite/plugins/pluginBuild/pluginProdBuildEntry.js +4 -2
  136. package/dist/esm/node/vite/plugins/pluginBuild/pluginSuppressRollupWarning.js +20 -18
  137. package/dist/esm/node/vite/plugins/pluginCommon.js +8 -22
  138. package/dist/esm/node/vite/plugins/pluginDev.js +51 -47
  139. package/dist/esm/node/vite/plugins/pluginEnvVars.js +63 -57
  140. package/dist/esm/node/vite/plugins/pluginExtractAssets.js +101 -91
  141. package/dist/esm/node/vite/plugins/pluginExtractExportNames.js +24 -16
  142. package/dist/esm/node/vite/plugins/pluginFileEnv.js +67 -57
  143. package/dist/esm/node/vite/plugins/pluginNonRunnableDev.js +26 -19
  144. package/dist/esm/node/vite/plugins/pluginPreview.js +30 -24
  145. package/dist/esm/node/vite/plugins/pluginReplaceConstants.js +41 -33
  146. package/dist/esm/node/vite/plugins/pluginSetGlobalContext.js +4 -2
  147. package/dist/esm/node/vite/plugins/pluginVirtualFiles/generateVirtualFileGlobalEntryWithOldDesign.js +2 -2
  148. package/dist/esm/node/vite/plugins/pluginVirtualFiles.js +51 -38
  149. package/dist/esm/node/vite/plugins/pluginWorkaroundCssModuleHmr.js +8 -6
  150. package/dist/esm/node/vite/shared/resolveVikeConfigInternal/configDefinitionsBuiltIn.js +3 -0
  151. package/dist/esm/node/vite/shared/resolveVikeConfigInternal/crawlPlusFiles.js +2 -2
  152. package/dist/esm/node/vite/shared/resolveVikeConfigInternal.d.ts +4 -8
  153. package/dist/esm/node/vite/shared/resolveVikeConfigInternal.js +22 -24
  154. package/dist/esm/shared/createGlobalContextShared.d.ts +73 -17
  155. package/dist/esm/shared/createGlobalContextShared.js +5 -23
  156. package/dist/esm/shared/createPageContextShared.d.ts +2 -7
  157. package/dist/esm/shared/createPageContextShared.js +2 -2
  158. package/dist/esm/shared/getPageFiles.d.ts +1 -1
  159. package/dist/esm/shared/hooks/execHook.d.ts +2 -2
  160. package/dist/esm/shared/hooks/getHook.d.ts +3 -3
  161. package/dist/esm/shared/page-configs/resolveVikeConfigPublic.d.ts +91 -31
  162. package/dist/esm/shared/page-configs/resolveVikeConfigPublic.js +62 -43
  163. package/dist/esm/types/Config/ConfigResolved.d.ts +8 -0
  164. package/dist/esm/types/Config.d.ts +14 -6
  165. package/dist/esm/types/PageContext.d.ts +8 -25
  166. package/dist/esm/types/VikeNamespace.d.ts +0 -27
  167. package/dist/esm/types/index.d.ts +2 -2
  168. package/dist/esm/utils/PROJECT_VERSION.d.ts +1 -1
  169. package/dist/esm/utils/PROJECT_VERSION.js +1 -1
  170. package/dist/esm/utils/assert.js +16 -1
  171. package/dist/esm/utils/assertNodeVersion.js +3 -1
  172. package/dist/esm/utils/assertVersion.d.ts +4 -3
  173. package/dist/esm/utils/assertVersion.js +23 -5
  174. package/dist/esm/utils/joinEnglish.js +2 -1
  175. package/package.json +2 -2
  176. package/dist/cjs/types/Config/helpers.js +0 -2
  177. package/dist/esm/node/runtime/html/injectAssets/inferHtmlTags.d.ts +0 -9
  178. package/dist/esm/node/runtime/html/injectAssets/mergeScriptTags.d.ts +0 -2
  179. package/dist/esm/types/Config/PageContextConfig.d.ts +0 -15
  180. package/dist/esm/types/Config/helpers.d.ts +0 -10
  181. package/dist/esm/types/Config/helpers.js +0 -1
  182. /package/dist/cjs/node/runtime/{html → renderPage/html}/injectAssets/sanitizeJson.js +0 -0
  183. /package/dist/cjs/types/Config/{PageContextConfig.js → ConfigResolved.js} +0 -0
  184. /package/dist/esm/node/runtime/{html → renderPage/html}/injectAssets/injectAssets__public.d.ts +0 -0
  185. /package/dist/esm/node/runtime/{html → renderPage/html}/injectAssets/injectHtmlTags.d.ts +0 -0
  186. /package/dist/esm/node/runtime/{html → renderPage/html}/injectAssets/sanitizeJson.d.ts +0 -0
  187. /package/dist/esm/node/runtime/{html → renderPage/html}/injectAssets/sanitizeJson.js +0 -0
  188. /package/dist/esm/node/runtime/{html → renderPage/html}/propKeys.d.ts +0 -0
  189. /package/dist/esm/node/runtime/{html → renderPage/html}/stream/react-streaming.d.ts +0 -0
  190. /package/dist/esm/node/runtime/{html → renderPage/html}/stream.d.ts +0 -0
  191. /package/dist/esm/types/Config/{PageContextConfig.js → ConfigResolved.js} +0 -0
@@ -22,66 +22,72 @@ function pluginEnvVars() {
22
22
  return {
23
23
  name: 'vike:pluginEnvVars',
24
24
  enforce: 'post',
25
- configResolved(config_) {
26
- config = config_;
27
- envsAll = (0, vite_1.loadEnv)(config.mode, config.envDir || config.root, '');
28
- config.plugins.sort((0, utils_js_1.lowerFirst)((plugin) => (plugin.name === 'vite:define' ? 1 : 0)));
25
+ configResolved: {
26
+ handler(config_) {
27
+ config = config_;
28
+ envsAll = (0, vite_1.loadEnv)(config.mode, config.envDir || config.root, '');
29
+ config.plugins.sort((0, utils_js_1.lowerFirst)((plugin) => (plugin.name === 'vite:define' ? 1 : 0)));
30
+ },
29
31
  },
30
- transform(code, id, options) {
31
- id = (0, normalizeId_js_1.normalizeId)(id);
32
- (0, utils_js_1.assertPosixPath)(id);
33
- if (id.includes('/node_modules/'))
34
- return;
35
- (0, utils_js_1.assertPosixPath)(config.root);
36
- if (!id.startsWith(config.root))
37
- return;
38
- if (!code.includes('({}).'))
39
- return;
40
- const isBuild = config.command === 'build';
41
- const isClientSide = !(0, isViteServerSide_js_1.isViteServerSide_extraSafe)(config, this.environment, options);
42
- const { magicString, getMagicStringResult } = (0, getMagicString_js_1.getMagicString)(code, id);
43
- // Find & check
44
- const replacements = Object.entries(envsAll)
45
- .filter(([key]) => {
46
- // Already handled by Vite
47
- const envPrefix = !config.envPrefix ? [] : (0, utils_js_1.isArray)(config.envPrefix) ? config.envPrefix : [config.envPrefix];
48
- return !envPrefix.some((prefix) => key.startsWith(prefix));
49
- })
50
- .map(([envName, envVal]) => {
51
- const envStatement = `({}).${envName}`;
52
- const envStatementRegExpStr = (0, utils_js_1.escapeRegex)(envStatement) + '\\b';
53
- // Security check
54
- {
55
- const isPrivate = !envName.startsWith(PUBLIC_ENV_PREFIX) && !PUBLIC_ENV_ALLOWLIST.includes(envName);
56
- if (isPrivate && isClientSide) {
57
- if (!new RegExp(envStatementRegExpStr).test(code))
58
- return;
59
- const modulePath = (0, getFilePath_js_1.getModuleFilePathAbsolute)(id, config);
60
- const errMsgAddendum = isBuild ? '' : ' (Vike will prevent your app from building for production)';
61
- const keyPublic = `${PUBLIC_ENV_PREFIX}${envName}`;
62
- const errMsg = `${envStatement} is used in client-side file ${modulePath} which means that the environment variable ${envName} will be included in client-side bundles and, therefore, ${envName} will be publicly exposed which can be a security leak${errMsgAddendum}. Use ${envStatement} only in server-side files, or rename ${envName} to ${keyPublic}, see https://vike.dev/env`;
63
- if (isBuild) {
64
- (0, utils_js_1.assertUsage)(false, errMsg);
65
- }
66
- else {
67
- // - Only a warning for faster development DX (e.g. when user toggles `ssr: boolean` or `onBeforeRenderIsomorph: boolean`).
68
- // - But only showing a warning can be confusing: https://github.com/vikejs/vike/issues/1641
69
- (0, utils_js_1.assertWarning)(false, errMsg, { onlyOnce: true });
32
+ transform: {
33
+ handler(code, id, options) {
34
+ id = (0, normalizeId_js_1.normalizeId)(id);
35
+ (0, utils_js_1.assertPosixPath)(id);
36
+ if (id.includes('/node_modules/'))
37
+ return;
38
+ (0, utils_js_1.assertPosixPath)(config.root);
39
+ if (!id.startsWith(config.root))
40
+ return;
41
+ if (!code.includes('({}).'))
42
+ return;
43
+ const isBuild = config.command === 'build';
44
+ const isClientSide = !(0, isViteServerSide_js_1.isViteServerSide_extraSafe)(config, this.environment, options);
45
+ const { magicString, getMagicStringResult } = (0, getMagicString_js_1.getMagicString)(code, id);
46
+ // Find & check
47
+ const replacements = Object.entries(envsAll)
48
+ .filter(([key]) => {
49
+ // Already handled by Vite
50
+ const envPrefix = !config.envPrefix ? [] : (0, utils_js_1.isArray)(config.envPrefix) ? config.envPrefix : [config.envPrefix];
51
+ return !envPrefix.some((prefix) => key.startsWith(prefix));
52
+ })
53
+ .map(([envName, envVal]) => {
54
+ const envStatement = `({}).${envName}`;
55
+ const envStatementRegExpStr = (0, utils_js_1.escapeRegex)(envStatement) + '\\b';
56
+ // Security check
57
+ {
58
+ const isPrivate = !envName.startsWith(PUBLIC_ENV_PREFIX) && !PUBLIC_ENV_ALLOWLIST.includes(envName);
59
+ if (isPrivate && isClientSide) {
60
+ if (!new RegExp(envStatementRegExpStr).test(code))
61
+ return;
62
+ const modulePath = (0, getFilePath_js_1.getModuleFilePathAbsolute)(id, config);
63
+ const errMsgAddendum = isBuild
64
+ ? ''
65
+ : ' (Vike will prevent your app from building for production)';
66
+ const keyPublic = `${PUBLIC_ENV_PREFIX}${envName}`;
67
+ const errMsg = `${envStatement} is used in client-side file ${modulePath} which means that the environment variable ${envName} will be included in client-side bundles and, therefore, ${envName} will be publicly exposed which can be a security leak${errMsgAddendum}. Use ${envStatement} only in server-side files, or rename ${envName} to ${keyPublic}, see https://vike.dev/env`;
68
+ if (isBuild) {
69
+ (0, utils_js_1.assertUsage)(false, errMsg);
70
+ }
71
+ else {
72
+ // - Only a warning for faster development DX (e.g. when user toggles `ssr: boolean` or `onBeforeRenderIsomorph: boolean`).
73
+ // - But only showing a warning can be confusing: https://github.com/vikejs/vike/issues/1641
74
+ (0, utils_js_1.assertWarning)(false, errMsg, { onlyOnce: true });
75
+ }
70
76
  }
77
+ // Double check
78
+ (0, utils_js_1.assert)(!(isPrivate && isClientSide) || !isBuild);
71
79
  }
72
- // Double check
73
- (0, utils_js_1.assert)(!(isPrivate && isClientSide) || !isBuild);
74
- }
75
- return { regExpStr: envStatementRegExpStr, replacement: envVal };
76
- })
77
- .filter(utils_js_1.isNotNullish);
78
- // Apply
79
- replacements.forEach(({ regExpStr, replacement }) => {
80
- magicString.replaceAll(new RegExp(regExpStr, 'g'), JSON.stringify(replacement));
81
- });
82
- if (!magicString.hasChanged())
83
- return null;
84
- return getMagicStringResult();
80
+ return { regExpStr: envStatementRegExpStr, replacement: envVal };
81
+ })
82
+ .filter(utils_js_1.isNotNullish);
83
+ // Apply
84
+ replacements.forEach(({ regExpStr, replacement }) => {
85
+ magicString.replaceAll(new RegExp(regExpStr, 'g'), JSON.stringify(replacement));
86
+ });
87
+ if (!magicString.hasChanged())
88
+ return null;
89
+ return getMagicStringResult();
90
+ },
85
91
  },
86
92
  };
87
93
  }
@@ -35,24 +35,26 @@ function pluginExtractAssets() {
35
35
  // In dev, things just work. (Because Vite's module graph erroneously conflates the Vite server-side importees with the client-side importees.)
36
36
  apply: 'build',
37
37
  enforce: 'post',
38
- async transform(src, id, options) {
39
- id = (0, normalizeId_js_1.normalizeId)(id);
40
- if (!extractAssetsRE.test(id)) {
41
- return;
42
- }
43
- if (isFixEnabled) {
44
- // I'm guessing isFixEnabled can only be true when mixing both designs: https://github.com/vikejs/vike/issues/1480
45
- (0, assertV1Design_js_1.assertV1Design)(vikeConfig._pageConfigs, true);
46
- (0, utils_js_1.assert)(false);
47
- }
48
- const includeAssetsImportedByServer = (0, retrievePageAssetsProd_js_1.resolveIncludeAssetsImportedByServer)(vikeConfig.config);
49
- (0, utils_js_1.assert)(includeAssetsImportedByServer);
50
- (0, utils_js_1.assert)(!(0, isViteServerSide_js_1.isViteServerSide_extraSafe)(config, this.environment, options));
51
- const importStatements = await (0, parseEsModule_js_1.getImportStatements)(src);
52
- const moduleNames = getImportedModules(importStatements);
53
- const code = moduleNames.map((moduleName) => `import '${moduleName}';`).join('\n');
54
- debugTransformResult(id, code, importStatements);
55
- return (0, utils_js_1.rollupSourceMapRemove)(code);
38
+ transform: {
39
+ async handler(src, id, options) {
40
+ id = (0, normalizeId_js_1.normalizeId)(id);
41
+ if (!extractAssetsRE.test(id)) {
42
+ return;
43
+ }
44
+ if (isFixEnabled) {
45
+ // I'm guessing isFixEnabled can only be true when mixing both designs: https://github.com/vikejs/vike/issues/1480
46
+ (0, assertV1Design_js_1.assertV1Design)(vikeConfig._pageConfigs, true);
47
+ (0, utils_js_1.assert)(false);
48
+ }
49
+ const includeAssetsImportedByServer = (0, retrievePageAssetsProd_js_1.resolveIncludeAssetsImportedByServer)(vikeConfig.config);
50
+ (0, utils_js_1.assert)(includeAssetsImportedByServer);
51
+ (0, utils_js_1.assert)(!(0, isViteServerSide_js_1.isViteServerSide_extraSafe)(config, this.environment, options));
52
+ const importStatements = await (0, parseEsModule_js_1.getImportStatements)(src);
53
+ const moduleNames = getImportedModules(importStatements);
54
+ const code = moduleNames.map((moduleName) => `import '${moduleName}';`).join('\n');
55
+ debugTransformResult(id, code, importStatements);
56
+ return (0, utils_js_1.rollupSourceMapRemove)(code);
57
+ },
56
58
  },
57
59
  },
58
60
  // This plugin appends `?extractAssets` to module IDs
@@ -63,89 +65,97 @@ function pluginExtractAssets() {
63
65
  // - rollup's `alias` plugin; https://github.com/rollup/plugins/blob/5363f55aa1933b6c650832b08d6a54cb9ea64539/packages/alias/src/index.ts
64
66
  // - Vite's `vite:resolve` plugin; https://github.com/vitejs/vite/blob/d649daba7682791178b711d9a3e44a6b5d00990c/packages/vite/src/node/plugins/resolve.ts#L105
65
67
  enforce: 'pre',
66
- async resolveId(source, importer, options) {
67
- if ((0, isViteServerSide_js_1.isViteServerSide_extraSafe)(config, this.environment, options)) {
68
- // When building for the server, there should never be a `?extractAssets` query
69
- (0, utils_js_1.assert)(!extractAssetsRE.test(source));
70
- (0, utils_js_1.assert)(importer === undefined || !extractAssetsRE.test(importer));
71
- return;
72
- }
73
- // If there is no `importer` then `module` is an entry.
74
- // We don't need to append `?extractAssets` to entries because they already have `?extractAssets` as Vike appends `?extractAssets` to entries by using `import.meta.glob('/**/*.page.server.js', { as: "extractAssets" })` (see `generateImportGlobs.ts`).
75
- if (!importer) {
76
- return;
77
- }
78
- // We only append `?extractAssets` if the parent module has `?extractAssets`
79
- if (!extractAssetsRE.test(importer)) {
80
- return;
81
- }
82
- const includeAssetsImportedByServer = (0, retrievePageAssetsProd_js_1.resolveIncludeAssetsImportedByServer)(vikeConfig.config);
83
- (0, utils_js_1.assert)(includeAssetsImportedByServer);
84
- let resolution = null;
85
- try {
86
- resolution = await this.resolve(source, importer, { skipSelf: true, ...options });
87
- }
88
- catch { }
89
- // Sometimes Rollup fails to resolve. If it fails to resolve, we assume the dependency to be an npm package and we skip it. (I guess Rollup should always be able to resolve local dependencies?)
90
- if (!resolution)
91
- return emptyModule(source, importer);
92
- const { id: file, external } = resolution;
93
- // Nothing is externalized when building for the client-side
94
- (0, utils_js_1.assert)(external === false);
95
- // We include:
96
- // - CSS(/LESS/SCSS/...) files
97
- // - Asset files (`.svg`, `.pdf`, ...)
98
- // - URL imports (e.g. `import scriptUrl from './script.js?url.js'`)
99
- if (utils_js_1.styleFileRE.test(file) || (0, isAsset_js_1.isAsset)(file) || urlRE.test(file)) {
100
- debugOperation('INCLUDED', file, importer);
101
- return resolution;
102
- }
103
- // We erase `source` if its file doesn't contain JavaScript
104
- if (!(0, utils_js_1.isScriptFile)(file)) {
105
- return emptyModule(file, importer);
106
- }
107
- // If the import path resolves to a file in `node_modules/`, we ignore that file:
108
- // - Direct CSS dependencies are included though, such as `import 'bootstrap/theme/dark.css'`. (Because the above if-branch for CSS files will add the file.)
109
- // - Loading CSS from a library (living in `node_modules/`) in a non-direct way is unconventional; we can safely not support this case. (I'm not aware of any library that does this.)
110
- (0, utils_js_1.assertPosixPath)(file);
111
- if (file.includes('/node_modules/')) {
112
- return emptyModule(file, importer);
113
- }
114
- // When a library is symlinked, it lives outside `root`.
115
- (0, utils_js_1.assertPosixPath)(config.root);
116
- if (!file.startsWith(config.root)) {
117
- return emptyModule(file, importer);
118
- }
119
- return appendExtractAssetsQuery(file, importer);
68
+ resolveId: {
69
+ async handler(source, importer, options) {
70
+ if ((0, isViteServerSide_js_1.isViteServerSide_extraSafe)(config, this.environment, options)) {
71
+ // When building for the server, there should never be a `?extractAssets` query
72
+ (0, utils_js_1.assert)(!extractAssetsRE.test(source));
73
+ (0, utils_js_1.assert)(importer === undefined || !extractAssetsRE.test(importer));
74
+ return;
75
+ }
76
+ // If there is no `importer` then `module` is an entry.
77
+ // We don't need to append `?extractAssets` to entries because they already have `?extractAssets` as Vike appends `?extractAssets` to entries by using `import.meta.glob('/**/*.page.server.js', { as: "extractAssets" })` (see `generateImportGlobs.ts`).
78
+ if (!importer) {
79
+ return;
80
+ }
81
+ // We only append `?extractAssets` if the parent module has `?extractAssets`
82
+ if (!extractAssetsRE.test(importer)) {
83
+ return;
84
+ }
85
+ const includeAssetsImportedByServer = (0, retrievePageAssetsProd_js_1.resolveIncludeAssetsImportedByServer)(vikeConfig.config);
86
+ (0, utils_js_1.assert)(includeAssetsImportedByServer);
87
+ let resolution = null;
88
+ try {
89
+ resolution = await this.resolve(source, importer, { skipSelf: true, ...options });
90
+ }
91
+ catch { }
92
+ // Sometimes Rollup fails to resolve. If it fails to resolve, we assume the dependency to be an npm package and we skip it. (I guess Rollup should always be able to resolve local dependencies?)
93
+ if (!resolution)
94
+ return emptyModule(source, importer);
95
+ const { id: file, external } = resolution;
96
+ // Nothing is externalized when building for the client-side
97
+ (0, utils_js_1.assert)(external === false);
98
+ // We include:
99
+ // - CSS(/LESS/SCSS/...) files
100
+ // - Asset files (`.svg`, `.pdf`, ...)
101
+ // - URL imports (e.g. `import scriptUrl from './script.js?url.js'`)
102
+ if (utils_js_1.styleFileRE.test(file) || (0, isAsset_js_1.isAsset)(file) || urlRE.test(file)) {
103
+ debugOperation('INCLUDED', file, importer);
104
+ return resolution;
105
+ }
106
+ // We erase `source` if its file doesn't contain JavaScript
107
+ if (!(0, utils_js_1.isScriptFile)(file)) {
108
+ return emptyModule(file, importer);
109
+ }
110
+ // If the import path resolves to a file in `node_modules/`, we ignore that file:
111
+ // - Direct CSS dependencies are included though, such as `import 'bootstrap/theme/dark.css'`. (Because the above if-branch for CSS files will add the file.)
112
+ // - Loading CSS from a library (living in `node_modules/`) in a non-direct way is unconventional; we can safely not support this case. (I'm not aware of any library that does this.)
113
+ (0, utils_js_1.assertPosixPath)(file);
114
+ if (file.includes('/node_modules/')) {
115
+ return emptyModule(file, importer);
116
+ }
117
+ // When a library is symlinked, it lives outside `root`.
118
+ (0, utils_js_1.assertPosixPath)(config.root);
119
+ if (!file.startsWith(config.root)) {
120
+ return emptyModule(file, importer);
121
+ }
122
+ return appendExtractAssetsQuery(file, importer);
123
+ },
120
124
  },
121
125
  },
122
126
  {
123
127
  name: 'vike:pluginExtractAssets-3',
124
128
  apply: 'build',
125
- load(id) {
126
- if (!(0, utils_js_1.isVirtualFileId)(id))
127
- return undefined;
128
- id = (0, utils_js_1.removeVirtualFileIdPrefix)(id);
129
- if (id === EMPTY_MODULE_ID) {
130
- return '// Erased by vike:pluginExtractAssets';
131
- }
129
+ load: {
130
+ handler(id) {
131
+ if (!(0, utils_js_1.isVirtualFileId)(id))
132
+ return undefined;
133
+ id = (0, utils_js_1.removeVirtualFileIdPrefix)(id);
134
+ if (id === EMPTY_MODULE_ID) {
135
+ return '// Erased by vike:pluginExtractAssets';
136
+ }
137
+ },
132
138
  },
133
- config() {
134
- if (debug.isActivated) {
135
- return { logLevel: 'silent' };
136
- }
139
+ config: {
140
+ handler() {
141
+ if (debug.isActivated) {
142
+ return { logLevel: 'silent' };
143
+ }
144
+ },
137
145
  },
138
146
  },
139
147
  {
140
148
  name: 'vike:pluginExtractAssets-4',
141
- async configResolved(config_) {
142
- config = config_;
143
- vikeConfig = await (0, resolveVikeConfigInternal_js_1.getVikeConfigInternal)();
144
- isFixEnabled = (0, handleAssetsManifest_js_1.handleAssetsManifest_isFixEnabled)();
145
- if (!isFixEnabled) {
146
- // https://github.com/vikejs/vike/issues/1060
147
- (0, utils_js_1.assertUsage)(!config.plugins.find((p) => p.name === 'vite-tsconfig-paths'), 'vite-tsconfig-paths not supported, remove it and use vite.config.js#resolve.alias instead');
148
- }
149
+ configResolved: {
150
+ async handler(config_) {
151
+ config = config_;
152
+ vikeConfig = await (0, resolveVikeConfigInternal_js_1.getVikeConfigInternal)();
153
+ isFixEnabled = (0, handleAssetsManifest_js_1.handleAssetsManifest_isFixEnabled)();
154
+ if (!isFixEnabled) {
155
+ // https://github.com/vikejs/vike/issues/1060
156
+ (0, utils_js_1.assertUsage)(!config.plugins.find((p) => p.name === 'vite-tsconfig-paths'), 'vite-tsconfig-paths not supported, remove it and use vite.config.js#resolve.alias instead');
157
+ }
158
+ },
149
159
  },
150
160
  },
151
161
  ];
@@ -17,25 +17,33 @@ function pluginExtractExportNames() {
17
17
  return {
18
18
  name: 'vike:pluginExtractExportNames',
19
19
  enforce: 'post',
20
- async transform(src, id, options) {
21
- id = (0, normalizeId_js_1.normalizeId)(id);
22
- const isClientSide = !(0, isViteServerSide_js_1.isViteServerSide_extraSafe)(config, this.environment, options);
23
- if (extractExportNamesRE.test(id)) {
24
- const code = await getExtractExportNamesCode(src, isClientSide, !isDev, id);
25
- debug('id ' + id, ['result:\n' + code.code.trim(), 'src:\n' + src.trim()]);
26
- return code;
27
- }
20
+ transform: {
21
+ async handler(src, id, options) {
22
+ id = (0, normalizeId_js_1.normalizeId)(id);
23
+ const isClientSide = !(0, isViteServerSide_js_1.isViteServerSide_extraSafe)(config, this.environment, options);
24
+ if (extractExportNamesRE.test(id)) {
25
+ const code = await getExtractExportNamesCode(src, isClientSide, !isDev, id);
26
+ debug('id ' + id, ['result:\n' + code.code.trim(), 'src:\n' + src.trim()]);
27
+ return code;
28
+ }
29
+ },
28
30
  },
29
- configureServer() {
30
- isDev = true;
31
+ configureServer: {
32
+ handler() {
33
+ isDev = true;
34
+ },
31
35
  },
32
- configResolved(config_) {
33
- config = config_;
36
+ configResolved: {
37
+ handler(config_) {
38
+ config = config_;
39
+ },
34
40
  },
35
- config() {
36
- if (debug.isActivated) {
37
- return { logLevel: 'silent' };
38
- }
41
+ config: {
42
+ handler() {
43
+ if (debug.isActivated) {
44
+ return { logLevel: 'silent' };
45
+ }
46
+ },
39
47
  },
40
48
  };
41
49
  }
@@ -18,68 +18,78 @@ function pluginFileEnv() {
18
18
  let viteDevServer;
19
19
  return {
20
20
  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);
21
+ load: {
22
+ handler(id, options) {
23
+ // 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.
24
+ if (!viteDevServer)
25
+ return;
26
+ if (!(0, resolveVikeConfigInternal_js_1.isV1Design)())
27
+ return;
28
+ if (skip(id))
29
+ return;
30
+ // For `.vue` files: https://github.com/vikejs/vike/issues/1912#issuecomment-2394981475
31
+ if (id.endsWith('?direct'))
32
+ id = id.slice(0, -1 * '?direct'.length);
33
+ const moduleInfo = viteDevServer.moduleGraph.getModuleById(id);
34
+ (0, utils_js_1.assert)(moduleInfo);
35
+ const importers = Array.from(moduleInfo.importers)
36
+ .map((m) => m.id)
37
+ .filter((id) => id !== null);
38
+ assertFileEnv(id, (0, isViteServerSide_js_1.isViteServerSide_extraSafe)(config, this.environment, options), importers,
39
+ // 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).
40
+ true);
41
+ },
40
42
  },
41
43
  // 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
- */
44
+ transform: {
45
+ async handler(code, id, options) {
46
+ id = (0, normalizeId_js_1.normalizeId)(id);
47
+ // In dev, only using load() is enough as it also works for dynamic imports (see sibling comment).
48
+ if (viteDevServer)
73
49
  return;
74
- }
75
- assertFileEnv(moduleId, (0, isViteServerSide_js_1.isViteServerSide)(config, this.environment), importers, false);
76
- });
50
+ if (skip(id))
51
+ return;
52
+ const isServerSide = (0, isViteServerSide_js_1.isViteServerSide_extraSafe)(config, this.environment, options);
53
+ if (!isWrongEnv(id, isServerSide))
54
+ return;
55
+ const { importers } = this.getModuleInfo(id);
56
+ // Throwing a verbose error doesn't waste client-side KBs as dynamic imports are code split.
57
+ const errMsg = getErrorMessage(id, isServerSide, importers, false, true);
58
+ // We have to inject empty exports to avoid Rollup complaining about missing exports, see https://gist.github.com/brillout/5ea45776e65bd65100a52ecd7bfda3ff
59
+ const { exportNames } = await (0, parseEsModule_js_1.getExportNames)(code);
60
+ return (0, utils_js_1.rollupSourceMapRemove)([
61
+ `throw new Error(${JSON.stringify(errMsg)});`,
62
+ ...exportNames.map((name) => name === 'default' ? 'export default undefined;' : `export const ${name} = undefined;`),
63
+ ].join('\n'));
64
+ },
65
+ },
66
+ generateBundle: {
67
+ handler() {
68
+ Array.from(this.getModuleIds())
69
+ .filter((id) => !skip(id))
70
+ .forEach((moduleId) => {
71
+ const mod = this.getModuleInfo(moduleId);
72
+ const { importers } = mod;
73
+ if (importers.length === 0) {
74
+ // Dynamic imports can only be verified at runtime
75
+ /* This assertion can fail: https://github.com/vikejs/vike/issues/2227
76
+ assert(dynamicImporters.length > 0)
77
+ */
78
+ return;
79
+ }
80
+ assertFileEnv(moduleId, (0, isViteServerSide_js_1.isViteServerSide)(config, this.environment), importers, false);
81
+ });
82
+ },
77
83
  },
78
- configResolved(config_) {
79
- config = config_;
84
+ configResolved: {
85
+ handler(config_) {
86
+ config = config_;
87
+ },
80
88
  },
81
- configureServer(viteDevServer_) {
82
- viteDevServer = viteDevServer_;
89
+ configureServer: {
90
+ handler(viteDevServer_) {
91
+ viteDevServer = viteDevServer_;
92
+ },
83
93
  },
84
94
  };
85
95
  function assertFileEnv(moduleId, isServerSide, importers, onlyWarn) {
@@ -25,27 +25,34 @@ function pluginNonRunnableDev() {
25
25
  let config;
26
26
  return {
27
27
  name: 'vike:pluginNonRunnableDev',
28
- configureServer(viteDevServer) {
29
- (0, utils_js_1.createViteRPC)(viteDevServer, getViteRpcFunctions);
28
+ configureServer: {
29
+ handler(viteDevServer) {
30
+ (0, utils_js_1.createViteRPC)(viteDevServer, getViteRpcFunctions);
31
+ },
30
32
  },
31
- configResolved(config_) {
32
- config = config_;
33
+ configResolved: {
34
+ handler(config_) {
35
+ config = config_;
36
+ },
33
37
  },
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();
38
+ transform: {
39
+ handler(code, id) {
40
+ if (!config._isDev)
41
+ return;
42
+ const idWithoutQuery = id.split('?')[0];
43
+ if (idWithoutQuery !== distFileIsNonRunnableDev && idWithoutQuery !== distFileGlobalContext)
44
+ return;
45
+ if ((0, utils_js_1.isRunnableDevEnvironment)(this.environment))
46
+ return;
47
+ const { magicString, getMagicStringResult } = (0, getMagicString_js_1.getMagicString)(code, id);
48
+ if (idWithoutQuery === distFileIsNonRunnableDev) {
49
+ magicString.replaceAll('__VIKE__IS_NON_RUNNABLE_DEV', JSON.stringify(true));
50
+ }
51
+ if (idWithoutQuery === distFileGlobalContext) {
52
+ magicString.replaceAll('__VIKE__DYNAMIC_IMPORT', 'import');
53
+ }
54
+ return getMagicStringResult();
55
+ },
49
56
  },
50
57
  };
51
58
  }