@marko/vite 5.1.2 → 5.1.4
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/index.mjs +24 -18
- package/package.json +1 -1
package/dist/index.mjs
CHANGED
|
@@ -651,16 +651,18 @@ function renderAssets(slot) {
|
|
|
651
651
|
// To avoid FOUC we will hide the page until all of these modules are loaded.
|
|
652
652
|
const { preload } = entry;
|
|
653
653
|
if (preload) {
|
|
654
|
-
html += \`<script
|
|
654
|
+
html += \`<script marko-vite-preload async blocking=render type=module\${this.___viteInjectAttrs}>\`;
|
|
655
|
+
html+= "await Promise.allSettled([";
|
|
656
|
+
|
|
655
657
|
for (const id of preload) {
|
|
656
|
-
html += \`import
|
|
658
|
+
html += \`import(\${JSON.stringify(base + id)}),\`;
|
|
657
659
|
}
|
|
658
660
|
|
|
659
|
-
html += "
|
|
661
|
+
html += "]);";
|
|
660
662
|
html += "document.documentElement.style.visibility='';";
|
|
661
|
-
html +=
|
|
662
|
-
|
|
663
|
-
html += \`</script><script
|
|
663
|
+
html += "if(document.documentElement.getAttribute('style')==='')document.documentElement.removeAttribute('style');";
|
|
664
|
+
html += "document.querySelectorAll('[marko-vite-preload]').forEach((el) => el.remove());";
|
|
665
|
+
html += \`</script><script marko-vite-preload\${this.___viteInjectAttrs}>document.documentElement.style.visibility='hidden'</script>\`;
|
|
664
666
|
}
|
|
665
667
|
}`}
|
|
666
668
|
|
|
@@ -904,16 +906,31 @@ function markoPlugin(opts = {}) {
|
|
|
904
906
|
if (linked) {
|
|
905
907
|
baseConfig.markoViteLinked = linked;
|
|
906
908
|
}
|
|
909
|
+
const getCJSInteropBabelConfig = () => ({
|
|
910
|
+
...baseConfig.babelConfig,
|
|
911
|
+
plugins: (baseConfig.babelConfig.plugins || []).concat(
|
|
912
|
+
plugin({
|
|
913
|
+
filter: isBuild || isTest ? void 0 : (path7) => !/^\./.test(path7)
|
|
914
|
+
})
|
|
915
|
+
)
|
|
916
|
+
});
|
|
907
917
|
ssrConfig = {
|
|
908
918
|
...baseConfig,
|
|
909
919
|
resolveVirtualDependency,
|
|
910
920
|
output: "html"
|
|
911
921
|
};
|
|
922
|
+
ssrCjsConfig = {
|
|
923
|
+
...ssrConfig,
|
|
924
|
+
babelConfig: getCJSInteropBabelConfig()
|
|
925
|
+
};
|
|
912
926
|
domConfig = {
|
|
913
927
|
...baseConfig,
|
|
914
928
|
resolveVirtualDependency,
|
|
915
929
|
output: "dom"
|
|
916
930
|
};
|
|
931
|
+
if (isTest) {
|
|
932
|
+
domConfig.babelConfig = getCJSInteropBabelConfig();
|
|
933
|
+
}
|
|
917
934
|
hydrateConfig = {
|
|
918
935
|
...baseConfig,
|
|
919
936
|
resolveVirtualDependency,
|
|
@@ -1037,17 +1054,6 @@ function markoPlugin(opts = {}) {
|
|
|
1037
1054
|
},
|
|
1038
1055
|
configResolved(config) {
|
|
1039
1056
|
basePath = config.base;
|
|
1040
|
-
ssrCjsConfig = {
|
|
1041
|
-
...ssrConfig,
|
|
1042
|
-
babelConfig: {
|
|
1043
|
-
...ssrConfig.babelConfig,
|
|
1044
|
-
plugins: (ssrConfig.babelConfig.plugins || []).concat(
|
|
1045
|
-
plugin({
|
|
1046
|
-
filter: isBuild ? void 0 : (path7) => !/^\./.test(path7)
|
|
1047
|
-
})
|
|
1048
|
-
)
|
|
1049
|
-
}
|
|
1050
|
-
};
|
|
1051
1057
|
getMarkoAssetFns = void 0;
|
|
1052
1058
|
for (const plugin2 of config.plugins) {
|
|
1053
1059
|
const fn = plugin2.api?.getMarkoAssetCodeForEntry;
|
|
@@ -1061,7 +1067,7 @@ function markoPlugin(opts = {}) {
|
|
|
1061
1067
|
}
|
|
1062
1068
|
},
|
|
1063
1069
|
configureServer(_server) {
|
|
1064
|
-
ssrConfig.hot = domConfig.hot = true;
|
|
1070
|
+
ssrConfig.hot = ssrCjsConfig.hot = domConfig.hot = true;
|
|
1065
1071
|
devServer = _server;
|
|
1066
1072
|
devServer.watcher.on("all", (type, originalFileName) => {
|
|
1067
1073
|
const fileName = normalizePath(originalFileName);
|