@marko/vite 5.3.9 → 5.4.1
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 +49 -4
- package/package.json +1 -1
package/dist/index.mjs
CHANGED
|
@@ -887,6 +887,20 @@ function markoPlugin(opts = {}) {
|
|
|
887
887
|
name: "marko-vite:pre",
|
|
888
888
|
enforce: "pre",
|
|
889
889
|
// Must be pre to allow us to resolve assets before vite.
|
|
890
|
+
sharedDuringBuild: true,
|
|
891
|
+
async buildApp(builder) {
|
|
892
|
+
const { ssr, client } = builder.environments;
|
|
893
|
+
if (!ssr || !client) {
|
|
894
|
+
return;
|
|
895
|
+
}
|
|
896
|
+
if (builder.config?.builder?.buildApp) {
|
|
897
|
+
return;
|
|
898
|
+
}
|
|
899
|
+
if (linked) {
|
|
900
|
+
await builder.build(ssr);
|
|
901
|
+
}
|
|
902
|
+
await builder.build(client);
|
|
903
|
+
},
|
|
890
904
|
async config(config, env) {
|
|
891
905
|
let optimize = env.mode === "production";
|
|
892
906
|
isTest = env.mode === "test";
|
|
@@ -1093,6 +1107,36 @@ function markoPlugin(opts = {}) {
|
|
|
1093
1107
|
}
|
|
1094
1108
|
};
|
|
1095
1109
|
},
|
|
1110
|
+
configEnvironment(name, options) {
|
|
1111
|
+
if (name === "ssr") {
|
|
1112
|
+
options.resolve ??= {};
|
|
1113
|
+
const { noExternal } = options.resolve;
|
|
1114
|
+
if (noExternal !== true) {
|
|
1115
|
+
const noExternalReg = /\.marko$/;
|
|
1116
|
+
if (noExternal) {
|
|
1117
|
+
if (Array.isArray(noExternal)) {
|
|
1118
|
+
options.resolve.noExternal = [...noExternal, noExternalReg];
|
|
1119
|
+
} else {
|
|
1120
|
+
options.resolve.noExternal = [noExternal, noExternalReg];
|
|
1121
|
+
}
|
|
1122
|
+
} else {
|
|
1123
|
+
options.resolve.noExternal = noExternalReg;
|
|
1124
|
+
}
|
|
1125
|
+
}
|
|
1126
|
+
options.build ??= {};
|
|
1127
|
+
if (!options.build?.rollupOptions?.output) {
|
|
1128
|
+
options.build.rollupOptions ??= {};
|
|
1129
|
+
options.build.rollupOptions.output = {
|
|
1130
|
+
chunkFileNames: `[name]-[hash].js`
|
|
1131
|
+
};
|
|
1132
|
+
}
|
|
1133
|
+
if (!options.build?.commonjsOptions?.esmExternals) {
|
|
1134
|
+
options.build.commonjsOptions ??= {};
|
|
1135
|
+
options.build.commonjsOptions.esmExternals = (id) => !isCJSModule(id, rootResolveFile);
|
|
1136
|
+
}
|
|
1137
|
+
}
|
|
1138
|
+
return options;
|
|
1139
|
+
},
|
|
1096
1140
|
configResolved(config) {
|
|
1097
1141
|
basePath = config.base;
|
|
1098
1142
|
cacheDir = config.cacheDir && normalizePath(config.cacheDir);
|
|
@@ -1150,7 +1194,7 @@ function markoPlugin(opts = {}) {
|
|
|
1150
1194
|
},
|
|
1151
1195
|
async options(inputOptions) {
|
|
1152
1196
|
if (linked && isBuild) {
|
|
1153
|
-
if (isSSRBuild) {
|
|
1197
|
+
if (isSSRBuild || this.environment?.name === "ssr") {
|
|
1154
1198
|
serverManifest = {
|
|
1155
1199
|
entries: {},
|
|
1156
1200
|
entrySources: {},
|
|
@@ -1182,7 +1226,7 @@ function markoPlugin(opts = {}) {
|
|
|
1182
1226
|
}
|
|
1183
1227
|
},
|
|
1184
1228
|
async buildStart() {
|
|
1185
|
-
if (isBuild && linked && !isSSRBuild) {
|
|
1229
|
+
if (isBuild && linked && !isSSRBuild && this.environment?.name !== "ssr") {
|
|
1186
1230
|
for (const assetId of serverManifest.ssrAssetIds) {
|
|
1187
1231
|
this.load({
|
|
1188
1232
|
id: normalizePath(path6.resolve(root, assetId)),
|
|
@@ -1426,7 +1470,8 @@ if (import.meta.hot) import.meta.hot.accept(() => {});`;
|
|
|
1426
1470
|
name: "marko-vite:post",
|
|
1427
1471
|
apply: "build",
|
|
1428
1472
|
enforce: "post",
|
|
1429
|
-
// We use a "post" plugin to allow us to read the final generated `.html` from vite
|
|
1473
|
+
// We use a "post" plugin to allow us to read the final generated `.html` from vite.,
|
|
1474
|
+
sharedDuringBuild: true,
|
|
1430
1475
|
transform(_source, id, opts2) {
|
|
1431
1476
|
if (!opts2?.ssr && /\.module\.[^.]+(?:\?|$)/.test(id)) {
|
|
1432
1477
|
return {
|
|
@@ -1443,7 +1488,7 @@ if (import.meta.hot) import.meta.hot.accept(() => {});`;
|
|
|
1443
1488
|
`Linked builds are currently only supported when in "write" mode.`
|
|
1444
1489
|
);
|
|
1445
1490
|
}
|
|
1446
|
-
if (isSSRBuild) {
|
|
1491
|
+
if (isSSRBuild || this.environment?.name === "ssr") {
|
|
1447
1492
|
const dir = outputOptions.dir ? path6.resolve(outputOptions.dir) : path6.resolve(outputOptions.file, "..");
|
|
1448
1493
|
for (const fileName in bundle) {
|
|
1449
1494
|
const chunk = bundle[fileName];
|