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.
- package/dist/cjs/node/prerender/resolvePrerenderConfig.js +3 -2
- package/dist/cjs/node/prerender/runPrerender.js +1 -0
- package/dist/cjs/node/runtime/globalContext.js +10 -0
- package/dist/cjs/node/runtime/index.js +3 -3
- package/dist/cjs/node/runtime/page-files/setup.js +3 -1
- package/dist/cjs/node/runtime/renderPage/createHttpResponse.js +2 -9
- package/dist/cjs/node/runtime/renderPage/createPageContextServerSide.js +2 -2
- package/dist/cjs/node/runtime/renderPage/csp.js +47 -0
- package/dist/cjs/node/runtime/renderPage/execHookOnRenderHtml.js +2 -2
- package/dist/cjs/node/runtime/renderPage/getEarlyHints.js +1 -1
- package/dist/cjs/node/runtime/renderPage/getHttpResponseBody.js +2 -2
- package/dist/cjs/node/runtime/renderPage/headersResponse.js +48 -0
- package/dist/cjs/node/runtime/{html → renderPage/html}/injectAssets/getHtmlTags.js +16 -13
- package/dist/cjs/node/runtime/{html → renderPage/html}/injectAssets/getViteDevScript.js +1 -1
- package/dist/cjs/node/runtime/{html → renderPage/html}/injectAssets/inferHtmlTags.js +8 -6
- package/dist/cjs/node/runtime/{html → renderPage/html}/injectAssets/injectAssets__public.js +1 -1
- package/dist/cjs/node/runtime/{html → renderPage/html}/injectAssets/injectHtmlTags.js +1 -1
- package/dist/cjs/node/runtime/{html → renderPage/html}/injectAssets/mergeScriptTags.js +5 -3
- package/dist/cjs/node/runtime/{html → renderPage/html}/injectAssets.js +2 -2
- package/dist/cjs/node/runtime/{html → renderPage/html}/propKeys.js +1 -1
- package/dist/cjs/node/runtime/{html → renderPage/html}/renderHtml.js +1 -1
- package/dist/cjs/node/runtime/{html → renderPage/html}/serializeContext.js +6 -6
- package/dist/cjs/node/runtime/{html → renderPage/html}/stream/react-streaming.js +1 -1
- package/dist/cjs/node/runtime/{html → renderPage/html}/stream.js +1 -1
- package/dist/cjs/node/runtime/renderPage/loadPageConfigsLazyServerSide.js +17 -38
- package/dist/cjs/node/runtime/renderPage/renderPageAfterRoute.js +2 -2
- package/dist/cjs/node/runtime/renderPage.js +1 -1
- package/dist/cjs/node/vite/onLoad.js +1 -1
- package/dist/cjs/node/vite/plugins/pluginBaseUrls.js +32 -28
- package/dist/cjs/node/vite/plugins/pluginBuild/handleAssetsManifest.js +1 -1
- package/dist/cjs/node/vite/plugins/pluginBuild/pluginBuildApp.js +24 -20
- package/dist/cjs/node/vite/plugins/pluginBuild/pluginBuildConfig.js +4 -2
- package/dist/cjs/node/vite/plugins/pluginBuild/pluginDistFileNames.js +76 -74
- package/dist/cjs/node/vite/plugins/pluginBuild/pluginDistPackageJsonFile.js +18 -14
- package/dist/cjs/node/vite/plugins/pluginBuild/pluginModuleBanner.js +17 -9
- package/dist/cjs/node/vite/plugins/pluginBuild/pluginProdBuildEntry.js +4 -2
- package/dist/cjs/node/vite/plugins/pluginBuild/pluginSuppressRollupWarning.js +20 -18
- package/dist/cjs/node/vite/plugins/pluginCommon.js +7 -21
- package/dist/cjs/node/vite/plugins/pluginDev.js +51 -47
- package/dist/cjs/node/vite/plugins/pluginEnvVars.js +62 -57
- package/dist/cjs/node/vite/plugins/pluginExtractAssets.js +107 -93
- package/dist/cjs/node/vite/plugins/pluginExtractExportNames.js +27 -13
- package/dist/cjs/node/vite/plugins/pluginFileEnv.js +107 -84
- package/dist/cjs/node/vite/plugins/pluginNonRunnableDev.js +40 -21
- package/dist/cjs/node/vite/plugins/pluginPreview.js +30 -24
- package/dist/cjs/node/vite/plugins/pluginReplaceConstants.js +59 -33
- package/dist/cjs/node/vite/plugins/pluginSetGlobalContext.js +4 -2
- package/dist/cjs/node/vite/plugins/pluginVirtualFiles/generateVirtualFileGlobalEntryWithOldDesign.js +1 -1
- package/dist/cjs/node/vite/plugins/pluginVirtualFiles.js +54 -36
- package/dist/cjs/node/vite/plugins/pluginWorkaroundCssModuleHmr.js +8 -6
- package/dist/cjs/node/vite/shared/resolveVikeConfigInternal/configDefinitionsBuiltIn.js +3 -0
- package/dist/cjs/node/vite/shared/resolveVikeConfigInternal/crawlPlusFiles.js +1 -1
- package/dist/cjs/node/vite/shared/resolveVikeConfigInternal.js +20 -22
- package/dist/cjs/shared/createGlobalContextShared.js +4 -22
- package/dist/cjs/shared/createPageContextShared.js +2 -2
- package/dist/cjs/shared/page-configs/resolveVikeConfigPublic.js +62 -43
- package/dist/cjs/utils/PROJECT_VERSION.js +1 -1
- package/dist/cjs/utils/assert.js +16 -1
- package/dist/cjs/utils/assertNodeVersion.js +3 -1
- package/dist/cjs/utils/assertVersion.js +26 -5
- package/dist/cjs/utils/joinEnglish.js +2 -1
- package/dist/cjs/utils/virtualFileId.js +15 -11
- package/dist/esm/client/runtime-client-routing/createPageContextClientSide.d.ts +40 -17
- package/dist/esm/client/runtime-client-routing/createPageContextClientSide.js +1 -1
- package/dist/esm/client/runtime-client-routing/getPageContextCurrent.d.ts +2 -2
- package/dist/esm/client/runtime-client-routing/getPageContextFromHooks.d.ts +99 -85
- package/dist/esm/client/runtime-client-routing/globalContext.d.ts +39 -11
- package/dist/esm/client/runtime-client-routing/prefetch/getPrefetchSettings.d.ts +2 -2
- package/dist/esm/client/runtime-client-routing/prefetch.d.ts +2 -2
- package/dist/esm/client/runtime-client-routing/prefetch.js +2 -2
- package/dist/esm/client/runtime-client-routing/preparePageContextForPublicUsageClient.d.ts +2 -2
- package/dist/esm/client/runtime-client-routing/renderPageClientSide.d.ts +44 -29
- package/dist/esm/client/runtime-server-routing/createPageContextClientSide.d.ts +40 -17
- package/dist/esm/client/runtime-server-routing/createPageContextClientSide.js +1 -1
- package/dist/esm/client/runtime-server-routing/globalContext.d.ts +39 -11
- package/dist/esm/client/runtime-server-routing/preparePageContextForPublicUsageClient.d.ts +2 -2
- package/dist/esm/client/shared/createGetGlobalContextClient.d.ts +39 -11
- package/dist/esm/client/shared/execHookOnRenderClient.d.ts +2 -2
- package/dist/esm/client/shared/loadPageConfigsLazyClientSide.d.ts +1 -1
- package/dist/esm/client/shared/loadPageConfigsLazyClientSide.js +2 -3
- package/dist/esm/client/shared/preparePageContextForPublicUsageClientShared.d.ts +2 -2
- package/dist/esm/node/prerender/resolvePrerenderConfig.js +4 -3
- package/dist/esm/node/prerender/runPrerender.d.ts +61 -16
- package/dist/esm/node/prerender/runPrerender.js +2 -1
- package/dist/esm/node/runtime/globalContext.d.ts +167 -42
- package/dist/esm/node/runtime/globalContext.js +11 -1
- package/dist/esm/node/runtime/index.d.ts +3 -3
- package/dist/esm/node/runtime/index.js +3 -3
- package/dist/esm/node/runtime/page-files/setup.js +3 -1
- package/dist/esm/node/runtime/renderPage/createHttpResponse.d.ts +1 -1
- package/dist/esm/node/runtime/renderPage/createHttpResponse.js +2 -9
- package/dist/esm/node/runtime/renderPage/createPageContextServerSide.d.ts +56 -12
- package/dist/esm/node/runtime/renderPage/createPageContextServerSide.js +2 -2
- package/dist/esm/node/runtime/renderPage/csp.d.ts +12 -0
- package/dist/esm/node/runtime/renderPage/csp.js +45 -0
- package/dist/esm/node/runtime/renderPage/execHookOnRenderHtml.d.ts +2 -2
- package/dist/esm/node/runtime/renderPage/execHookOnRenderHtml.js +2 -2
- package/dist/esm/node/runtime/renderPage/execHookServer.d.ts +2 -2
- package/dist/esm/node/runtime/renderPage/getEarlyHints.js +1 -1
- package/dist/esm/node/runtime/renderPage/getHttpResponseBody.d.ts +2 -2
- package/dist/esm/node/runtime/renderPage/getHttpResponseBody.js +2 -2
- package/dist/esm/node/runtime/renderPage/headersResponse.d.ts +10 -0
- package/dist/esm/node/runtime/renderPage/headersResponse.js +46 -0
- package/dist/esm/node/runtime/{html → renderPage/html}/injectAssets/getHtmlTags.d.ts +1 -1
- package/dist/esm/node/runtime/{html → renderPage/html}/injectAssets/getHtmlTags.js +16 -13
- package/dist/esm/node/runtime/{html → renderPage/html}/injectAssets/getViteDevScript.d.ts +1 -1
- package/dist/esm/node/runtime/{html → renderPage/html}/injectAssets/getViteDevScript.js +1 -1
- package/dist/esm/node/runtime/renderPage/html/injectAssets/inferHtmlTags.d.ts +10 -0
- package/dist/esm/node/runtime/{html → renderPage/html}/injectAssets/inferHtmlTags.js +7 -5
- package/dist/esm/node/runtime/{html → renderPage/html}/injectAssets/injectAssets__public.js +1 -1
- package/dist/esm/node/runtime/{html → renderPage/html}/injectAssets/injectHtmlTags.js +1 -1
- package/dist/esm/node/runtime/renderPage/html/injectAssets/mergeScriptTags.d.ts +3 -0
- package/dist/esm/node/runtime/{html → renderPage/html}/injectAssets/mergeScriptTags.js +6 -4
- package/dist/esm/node/runtime/{html → renderPage/html}/injectAssets.d.ts +2 -2
- package/dist/esm/node/runtime/{html → renderPage/html}/injectAssets.js +2 -2
- package/dist/esm/node/runtime/{html → renderPage/html}/propKeys.js +1 -1
- package/dist/esm/node/runtime/{html → renderPage/html}/renderHtml.d.ts +1 -1
- package/dist/esm/node/runtime/{html → renderPage/html}/renderHtml.js +1 -1
- package/dist/esm/node/runtime/{html → renderPage/html}/serializeContext.d.ts +6 -5
- package/dist/esm/node/runtime/{html → renderPage/html}/serializeContext.js +6 -6
- package/dist/esm/node/runtime/{html → renderPage/html}/stream/react-streaming.js +1 -1
- package/dist/esm/node/runtime/{html → renderPage/html}/stream.js +1 -1
- package/dist/esm/node/runtime/renderPage/loadPageConfigsLazyServerSide.d.ts +66 -17
- package/dist/esm/node/runtime/renderPage/loadPageConfigsLazyServerSide.js +18 -39
- package/dist/esm/node/runtime/renderPage/preparePageContextForPublicUsageServer.d.ts +2 -2
- package/dist/esm/node/runtime/renderPage/renderPageAfterRoute.d.ts +122 -32
- package/dist/esm/node/runtime/renderPage/renderPageAfterRoute.js +2 -2
- package/dist/esm/node/runtime/renderPage.d.ts +56 -12
- package/dist/esm/node/runtime/renderPage.js +1 -1
- package/dist/esm/node/vite/onLoad.js +1 -1
- package/dist/esm/node/vite/plugins/pluginBaseUrls.js +32 -28
- package/dist/esm/node/vite/plugins/pluginBuild/handleAssetsManifest.js +1 -1
- package/dist/esm/node/vite/plugins/pluginBuild/pluginBuildApp.js +24 -20
- package/dist/esm/node/vite/plugins/pluginBuild/pluginBuildConfig.js +4 -2
- package/dist/esm/node/vite/plugins/pluginBuild/pluginDistFileNames.js +76 -74
- package/dist/esm/node/vite/plugins/pluginBuild/pluginDistPackageJsonFile.js +18 -14
- package/dist/esm/node/vite/plugins/pluginBuild/pluginModuleBanner.js +18 -10
- package/dist/esm/node/vite/plugins/pluginBuild/pluginProdBuildEntry.js +4 -2
- package/dist/esm/node/vite/plugins/pluginBuild/pluginSuppressRollupWarning.js +20 -18
- package/dist/esm/node/vite/plugins/pluginCommon.js +8 -22
- package/dist/esm/node/vite/plugins/pluginDev.js +51 -47
- package/dist/esm/node/vite/plugins/pluginEnvVars.js +62 -57
- package/dist/esm/node/vite/plugins/pluginExtractAssets.js +107 -91
- package/dist/esm/node/vite/plugins/pluginExtractExportNames.js +27 -13
- package/dist/esm/node/vite/plugins/pluginFileEnv.js +107 -84
- package/dist/esm/node/vite/plugins/pluginNonRunnableDev.js +41 -22
- package/dist/esm/node/vite/plugins/pluginPreview.js +30 -24
- package/dist/esm/node/vite/plugins/pluginReplaceConstants.d.ts +11 -0
- package/dist/esm/node/vite/plugins/pluginReplaceConstants.js +58 -33
- package/dist/esm/node/vite/plugins/pluginSetGlobalContext.js +4 -2
- package/dist/esm/node/vite/plugins/pluginVirtualFiles/generateVirtualFileGlobalEntryWithOldDesign.js +2 -2
- package/dist/esm/node/vite/plugins/pluginVirtualFiles.js +56 -38
- package/dist/esm/node/vite/plugins/pluginWorkaroundCssModuleHmr.js +8 -6
- package/dist/esm/node/vite/shared/resolveVikeConfigInternal/configDefinitionsBuiltIn.js +3 -0
- package/dist/esm/node/vite/shared/resolveVikeConfigInternal/crawlPlusFiles.js +2 -2
- package/dist/esm/node/vite/shared/resolveVikeConfigInternal.d.ts +4 -8
- package/dist/esm/node/vite/shared/resolveVikeConfigInternal.js +22 -24
- package/dist/esm/shared/createGlobalContextShared.d.ts +75 -19
- package/dist/esm/shared/createGlobalContextShared.js +5 -23
- package/dist/esm/shared/createPageContextShared.d.ts +2 -7
- package/dist/esm/shared/createPageContextShared.js +2 -2
- package/dist/esm/shared/getPageFiles.d.ts +1 -1
- package/dist/esm/shared/hooks/execHook.d.ts +2 -2
- package/dist/esm/shared/hooks/getHook.d.ts +3 -3
- package/dist/esm/shared/page-configs/resolveVikeConfigPublic.d.ts +91 -31
- package/dist/esm/shared/page-configs/resolveVikeConfigPublic.js +62 -43
- package/dist/esm/types/Config/ConfigResolved.d.ts +8 -0
- package/dist/esm/types/Config.d.ts +14 -6
- package/dist/esm/types/PageContext.d.ts +8 -25
- package/dist/esm/types/VikeNamespace.d.ts +0 -27
- package/dist/esm/types/index.d.ts +2 -2
- package/dist/esm/utils/PROJECT_VERSION.d.ts +1 -1
- package/dist/esm/utils/PROJECT_VERSION.js +1 -1
- package/dist/esm/utils/assert.js +16 -1
- package/dist/esm/utils/assertNodeVersion.js +3 -1
- package/dist/esm/utils/assertVersion.d.ts +4 -3
- package/dist/esm/utils/assertVersion.js +23 -5
- package/dist/esm/utils/joinEnglish.js +2 -1
- package/dist/esm/utils/virtualFileId.d.ts +4 -0
- package/dist/esm/utils/virtualFileId.js +14 -11
- package/package.json +5 -5
- package/dist/cjs/types/Config/helpers.js +0 -2
- package/dist/esm/node/runtime/html/injectAssets/inferHtmlTags.d.ts +0 -9
- package/dist/esm/node/runtime/html/injectAssets/mergeScriptTags.d.ts +0 -2
- package/dist/esm/types/Config/PageContextConfig.d.ts +0 -15
- package/dist/esm/types/Config/helpers.d.ts +0 -10
- package/dist/esm/types/Config/helpers.js +0 -1
- /package/dist/cjs/node/runtime/{html → renderPage/html}/injectAssets/sanitizeJson.js +0 -0
- /package/dist/cjs/types/Config/{PageContextConfig.js → ConfigResolved.js} +0 -0
- /package/dist/esm/node/runtime/{html → renderPage/html}/injectAssets/injectAssets__public.d.ts +0 -0
- /package/dist/esm/node/runtime/{html → renderPage/html}/injectAssets/injectHtmlTags.d.ts +0 -0
- /package/dist/esm/node/runtime/{html → renderPage/html}/injectAssets/sanitizeJson.d.ts +0 -0
- /package/dist/esm/node/runtime/{html → renderPage/html}/injectAssets/sanitizeJson.js +0 -0
- /package/dist/esm/node/runtime/{html → renderPage/html}/propKeys.d.ts +0 -0
- /package/dist/esm/node/runtime/{html → renderPage/html}/stream/react-streaming.d.ts +0 -0
- /package/dist/esm/node/runtime/{html → renderPage/html}/stream.d.ts +0 -0
- /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
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
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
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
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
|
-
|
|
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
|
|
79
|
-
|
|
101
|
+
configResolved: {
|
|
102
|
+
handler(config_) {
|
|
103
|
+
config = config_;
|
|
104
|
+
},
|
|
80
105
|
},
|
|
81
|
-
configureServer
|
|
82
|
-
|
|
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
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
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
|
-
|
|
29
|
-
|
|
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
|
|
32
|
-
|
|
43
|
+
configResolved: {
|
|
44
|
+
handler(config_) {
|
|
45
|
+
config = config_;
|
|
46
|
+
},
|
|
33
47
|
},
|
|
34
|
-
transform
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
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
|
-
|
|
24
|
-
|
|
25
|
-
|
|
22
|
+
config: {
|
|
23
|
+
handler() {
|
|
24
|
+
return {
|
|
25
|
+
appType: 'custom',
|
|
26
|
+
};
|
|
27
|
+
},
|
|
26
28
|
},
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
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
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
(
|
|
45
|
-
|
|
46
|
-
|
|
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
|
|
15
|
-
|
|
34
|
+
configResolved: {
|
|
35
|
+
handler(config_) {
|
|
36
|
+
config = config_;
|
|
37
|
+
},
|
|
16
38
|
},
|
|
17
|
-
transform
|
|
18
|
-
|
|
19
|
-
(
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
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
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
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
|
-
(
|
|
25
|
+
configurePreviewServer: {
|
|
26
|
+
handler() {
|
|
27
|
+
(0, utils_js_1.markSetup_vitePreviewServer)();
|
|
28
|
+
},
|
|
27
29
|
},
|
|
28
30
|
config: {
|
|
29
31
|
order: 'pre',
|
package/dist/cjs/node/vite/plugins/pluginVirtualFiles/generateVirtualFileGlobalEntryWithOldDesign.js
CHANGED
|
@@ -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.
|
|
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
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
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
|
|
31
|
-
|
|
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
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
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
|
-
|
|
58
|
-
|
|
59
|
-
|
|
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
|
|
64
|
-
|
|
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.
|
|
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
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
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
|
}
|