@marko/vite 5.2.0 → 5.3.0
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/glob-import-transform.d.ts +1 -1
- package/dist/index.mjs +82 -63
- package/package.json +15 -14
package/dist/index.mjs
CHANGED
|
@@ -244,6 +244,7 @@ function esbuildPlugin(config) {
|
|
|
244
244
|
import { types as t2 } from "@marko/compiler";
|
|
245
245
|
import glob from "fast-glob";
|
|
246
246
|
import path3 from "path";
|
|
247
|
+
import { relativeImportPath } from "relative-import-path";
|
|
247
248
|
var programGlobImports = /* @__PURE__ */ new WeakMap();
|
|
248
249
|
var glob_import_transform_default = {
|
|
249
250
|
MetaProperty(tag) {
|
|
@@ -265,18 +266,17 @@ var glob_import_transform_default = {
|
|
|
265
266
|
}
|
|
266
267
|
},
|
|
267
268
|
Program: {
|
|
268
|
-
exit(
|
|
269
|
-
const globImports = programGlobImports.get(
|
|
269
|
+
exit(program) {
|
|
270
|
+
const globImports = programGlobImports.get(program);
|
|
270
271
|
if (!globImports) {
|
|
271
272
|
return;
|
|
272
273
|
}
|
|
273
|
-
const { cwd, filename } =
|
|
274
|
+
const { cwd, filename } = program.hub.file.opts;
|
|
274
275
|
const dir = path3.dirname(filename);
|
|
275
276
|
const seen = /* @__PURE__ */ new Set();
|
|
276
277
|
for (const [patterns, options] of globImports) {
|
|
277
|
-
const
|
|
278
|
-
|
|
279
|
-
cwd,
|
|
278
|
+
const results = glob.globSync(patterns, {
|
|
279
|
+
cwd: dir,
|
|
280
280
|
absolute: true,
|
|
281
281
|
dot: !!options.exhaustive,
|
|
282
282
|
ignore: options.exhaustive ? [] : [path3.join(cwd, "**/node_modules/**")]
|
|
@@ -284,7 +284,12 @@ var glob_import_transform_default = {
|
|
|
284
284
|
for (const file of results) {
|
|
285
285
|
if (file.endsWith(".marko") && file !== filename && !seen.has(file)) {
|
|
286
286
|
seen.add(file);
|
|
287
|
-
|
|
287
|
+
program.node.body.push(
|
|
288
|
+
t2.importDeclaration(
|
|
289
|
+
[],
|
|
290
|
+
t2.stringLiteral(relativeImportPath(filename, file))
|
|
291
|
+
)
|
|
292
|
+
);
|
|
288
293
|
}
|
|
289
294
|
}
|
|
290
295
|
}
|
|
@@ -737,8 +742,7 @@ static function flush($global, html) {
|
|
|
737
742
|
static function setFlush($global) {
|
|
738
743
|
$global.__flush__ = flush;
|
|
739
744
|
}
|
|
740
|
-
|
|
741
|
-
<const/writeSync=addAssets($global, assets) || setFlush($global)/>
|
|
745
|
+
<const/writeSync=addAssets($global, [${opts.entryData.join(",")}]) || setFlush($global)/>
|
|
742
746
|
-- $!{writeSync && getPrepend($global)}
|
|
743
747
|
<Template ...input/>
|
|
744
748
|
-- $!{writeSync && getAppend($global)}
|
|
@@ -747,8 +751,7 @@ static const assets = [${opts.entryData.join(",")}];
|
|
|
747
751
|
return `import template from ${fileNameStr};
|
|
748
752
|
export * from ${fileNameStr};
|
|
749
753
|
import { addAssets, getPrepend, getAppend } from "${renderAssetsRuntimeId}";
|
|
750
|
-
|
|
751
|
-
<if(addAssets($global, assets))>
|
|
754
|
+
<if(addAssets($global, [${opts.entryData.join(",")}]))>
|
|
752
755
|
$!{getPrepend($global)}
|
|
753
756
|
<\${template} ...input/>
|
|
754
757
|
$!{getAppend($global)}
|
|
@@ -772,6 +775,7 @@ var virtualFiles = /* @__PURE__ */ new Map();
|
|
|
772
775
|
var extReg = /\.[^.]+$/;
|
|
773
776
|
var queryReg = /\?marko-[^?]+$/;
|
|
774
777
|
var importTagReg2 = /^<([^>]+)>$/;
|
|
778
|
+
var noClientAssetsRuntimeId = "\0no_client_bundles.mjs";
|
|
775
779
|
var browserEntryQuery = "?marko-browser-entry";
|
|
776
780
|
var serverEntryQuery = "?marko-server-entry";
|
|
777
781
|
var virtualFileQuery = "?marko-virtual";
|
|
@@ -1103,22 +1107,35 @@ function markoPlugin(opts = {}) {
|
|
|
1103
1107
|
}
|
|
1104
1108
|
},
|
|
1105
1109
|
async options(inputOptions) {
|
|
1106
|
-
if (
|
|
1107
|
-
|
|
1108
|
-
serverManifest =
|
|
1109
|
-
|
|
1110
|
-
|
|
1111
|
-
|
|
1112
|
-
|
|
1113
|
-
|
|
1110
|
+
if (linked && isBuild) {
|
|
1111
|
+
if (isSSRBuild) {
|
|
1112
|
+
serverManifest = {
|
|
1113
|
+
entries: {},
|
|
1114
|
+
entrySources: {},
|
|
1115
|
+
chunksNeedingAssets: [],
|
|
1116
|
+
ssrAssetIds: []
|
|
1117
|
+
};
|
|
1118
|
+
} else {
|
|
1119
|
+
try {
|
|
1120
|
+
serverManifest = await store.read();
|
|
1121
|
+
if (isEmpty(serverManifest.entries)) {
|
|
1122
|
+
inputOptions.input = noClientAssetsRuntimeId;
|
|
1123
|
+
} else {
|
|
1124
|
+
inputOptions.input = toHTMLEntries(
|
|
1125
|
+
root,
|
|
1126
|
+
serverManifest.entries
|
|
1127
|
+
);
|
|
1128
|
+
for (const entry in serverManifest.entrySources) {
|
|
1129
|
+
const id = normalizePath(path6.resolve(root, entry));
|
|
1130
|
+
entryIds.add(id);
|
|
1131
|
+
cachedSources.set(id, serverManifest.entrySources[entry]);
|
|
1132
|
+
}
|
|
1133
|
+
}
|
|
1134
|
+
} catch (err) {
|
|
1135
|
+
this.error(
|
|
1136
|
+
`You must run the "ssr" build before the "browser" build.`
|
|
1137
|
+
);
|
|
1114
1138
|
}
|
|
1115
|
-
} catch (err) {
|
|
1116
|
-
this.error(
|
|
1117
|
-
`You must run the "ssr" build before the "browser" build.`
|
|
1118
|
-
);
|
|
1119
|
-
}
|
|
1120
|
-
if (isEmpty(inputOptions.input)) {
|
|
1121
|
-
this.error("No Marko files were found when compiling the server.");
|
|
1122
1139
|
}
|
|
1123
1140
|
}
|
|
1124
1141
|
},
|
|
@@ -1136,8 +1153,8 @@ function markoPlugin(opts = {}) {
|
|
|
1136
1153
|
if (virtualFiles.has(importee)) {
|
|
1137
1154
|
return importee;
|
|
1138
1155
|
}
|
|
1139
|
-
if (importee === renderAssetsRuntimeId) {
|
|
1140
|
-
return { id:
|
|
1156
|
+
if (importee === renderAssetsRuntimeId || importee === noClientAssetsRuntimeId) {
|
|
1157
|
+
return { id: importee };
|
|
1141
1158
|
}
|
|
1142
1159
|
if (importer) {
|
|
1143
1160
|
const tagName = importTagReg2.exec(importee)?.[1];
|
|
@@ -1190,6 +1207,9 @@ function markoPlugin(opts = {}) {
|
|
|
1190
1207
|
if (id === renderAssetsRuntimeId) {
|
|
1191
1208
|
return renderAssetsRuntimeCode;
|
|
1192
1209
|
}
|
|
1210
|
+
if (id === noClientAssetsRuntimeId) {
|
|
1211
|
+
return "NO_CLIENT_ASSETS";
|
|
1212
|
+
}
|
|
1193
1213
|
const query = getMarkoQuery(id);
|
|
1194
1214
|
switch (query) {
|
|
1195
1215
|
case serverEntryQuery: {
|
|
@@ -1225,12 +1245,6 @@ function markoPlugin(opts = {}) {
|
|
|
1225
1245
|
path6.relative(root, fileName)
|
|
1226
1246
|
);
|
|
1227
1247
|
const entryId = toEntryId(relativeFileName);
|
|
1228
|
-
serverManifest ??= {
|
|
1229
|
-
entries: {},
|
|
1230
|
-
entrySources: {},
|
|
1231
|
-
chunksNeedingAssets: [],
|
|
1232
|
-
ssrAssetIds: []
|
|
1233
|
-
};
|
|
1234
1248
|
serverManifest.entries[entryId] = relativeFileName;
|
|
1235
1249
|
serverManifest.entrySources[relativeFileName] = source;
|
|
1236
1250
|
mainEntryData = JSON.stringify(entryId);
|
|
@@ -1363,11 +1377,6 @@ if (import.meta.hot) import.meta.hot.accept(() => {});`;
|
|
|
1363
1377
|
`Linked builds are currently only supported when in "write" mode.`
|
|
1364
1378
|
);
|
|
1365
1379
|
}
|
|
1366
|
-
if (!serverManifest) {
|
|
1367
|
-
this.error(
|
|
1368
|
-
"No Marko files were found when bundling the server in linked mode."
|
|
1369
|
-
);
|
|
1370
|
-
}
|
|
1371
1380
|
if (isSSRBuild) {
|
|
1372
1381
|
const dir = outputOptions.dir ? path6.resolve(outputOptions.dir) : path6.resolve(outputOptions.file, "..");
|
|
1373
1382
|
for (const fileName in bundle) {
|
|
@@ -1394,32 +1403,42 @@ if (import.meta.hot) import.meta.hot.accept(() => {});`;
|
|
|
1394
1403
|
store.write(serverManifest);
|
|
1395
1404
|
} else {
|
|
1396
1405
|
const browserManifest = {};
|
|
1397
|
-
|
|
1398
|
-
const
|
|
1399
|
-
|
|
1400
|
-
|
|
1401
|
-
|
|
1402
|
-
|
|
1403
|
-
|
|
1404
|
-
basePath,
|
|
1405
|
-
chunk.source.toString()
|
|
1406
|
-
),
|
|
1407
|
-
preload: void 0
|
|
1408
|
-
// clear out preload for prod builds.
|
|
1409
|
-
};
|
|
1410
|
-
delete bundle[chunkId];
|
|
1411
|
-
} else {
|
|
1412
|
-
this.error(
|
|
1413
|
-
`Marko template had unexpected output from vite, ${fileName}`
|
|
1414
|
-
);
|
|
1406
|
+
if (isEmpty(serverManifest.entries)) {
|
|
1407
|
+
for (const chunkId in bundle) {
|
|
1408
|
+
const chunk = bundle[chunkId];
|
|
1409
|
+
if (chunk.type === "chunk" && chunk.facadeModuleId === noClientAssetsRuntimeId) {
|
|
1410
|
+
delete bundle[chunkId];
|
|
1411
|
+
delete bundle[chunkId + ".map"];
|
|
1412
|
+
}
|
|
1415
1413
|
}
|
|
1416
|
-
}
|
|
1417
|
-
|
|
1418
|
-
|
|
1419
|
-
|
|
1414
|
+
} else {
|
|
1415
|
+
for (const entryId in serverManifest.entries) {
|
|
1416
|
+
const fileName = serverManifest.entries[entryId];
|
|
1417
|
+
const chunkId = fileName + htmlExt;
|
|
1418
|
+
const chunk = bundle[chunkId];
|
|
1419
|
+
if (chunk?.type === "asset") {
|
|
1420
|
+
browserManifest[entryId] = {
|
|
1421
|
+
...await generateDocManifest(
|
|
1422
|
+
basePath,
|
|
1423
|
+
chunk.source.toString()
|
|
1424
|
+
),
|
|
1425
|
+
preload: void 0
|
|
1426
|
+
// clear out preload for prod builds.
|
|
1427
|
+
};
|
|
1428
|
+
delete bundle[chunkId];
|
|
1429
|
+
} else {
|
|
1430
|
+
this.error(
|
|
1431
|
+
`Marko template had unexpected output from vite, ${fileName}`
|
|
1432
|
+
);
|
|
1433
|
+
}
|
|
1434
|
+
}
|
|
1435
|
+
const manifestStr = `;var __MARKO_MANIFEST__=${JSON.stringify(
|
|
1436
|
+
browserManifest
|
|
1437
|
+
)};
|
|
1420
1438
|
`;
|
|
1421
|
-
|
|
1422
|
-
|
|
1439
|
+
for (const fileName of serverManifest.chunksNeedingAssets) {
|
|
1440
|
+
await fs4.promises.appendFile(fileName, manifestStr);
|
|
1441
|
+
}
|
|
1423
1442
|
}
|
|
1424
1443
|
}
|
|
1425
1444
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@marko/vite",
|
|
3
|
-
"version": "5.
|
|
3
|
+
"version": "5.3.0",
|
|
4
4
|
"description": "A Marko plugin for Vite",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"loader",
|
|
@@ -47,46 +47,47 @@
|
|
|
47
47
|
"domhandler": "^5.0.3",
|
|
48
48
|
"fast-glob": "^3.3.3",
|
|
49
49
|
"htmlparser2": "^10.0.0",
|
|
50
|
+
"relative-import-path": "^1.0.0",
|
|
50
51
|
"resolve": "^1.22.10",
|
|
51
52
|
"resolve.exports": "^2.0.3"
|
|
52
53
|
},
|
|
53
54
|
"devDependencies": {
|
|
54
55
|
"@changesets/changelog-github": "^0.5.1",
|
|
55
56
|
"@changesets/cli": "^2.29.5",
|
|
56
|
-
"@eslint/js": "^9.
|
|
57
|
-
"@marko/compiler": "^5.39.
|
|
57
|
+
"@eslint/js": "^9.31.0",
|
|
58
|
+
"@marko/compiler": "^5.39.29",
|
|
58
59
|
"@marko/fixture-snapshots": "^2.2.1",
|
|
59
|
-
"@marko/testing-library": "^6.
|
|
60
|
+
"@marko/testing-library": "^6.3.1",
|
|
60
61
|
"@types/babel__core": "^7.20.5",
|
|
61
62
|
"@types/diff": "^8.0.0",
|
|
62
63
|
"@types/jsdom": "^21.1.7",
|
|
63
64
|
"@types/mocha": "^10.0.10",
|
|
64
|
-
"@types/node": "^24.0.
|
|
65
|
+
"@types/node": "^24.0.14",
|
|
65
66
|
"@types/resolve": "^1.20.6",
|
|
66
67
|
"@types/serve-handler": "^6.1.4",
|
|
67
68
|
"cross-env": "^7.0.3",
|
|
68
69
|
"diff": "^8.0.2",
|
|
69
|
-
"esbuild": "^0.25.
|
|
70
|
-
"eslint": "^9.
|
|
70
|
+
"esbuild": "^0.25.6",
|
|
71
|
+
"eslint": "^9.31.0",
|
|
71
72
|
"eslint-formatter-unix": "^8.40.0",
|
|
72
73
|
"eslint-plugin-simple-import-sort": "^12.1.1",
|
|
73
|
-
"globals": "^16.
|
|
74
|
+
"globals": "^16.3.0",
|
|
74
75
|
"husky": "^9.1.7",
|
|
75
76
|
"jsdom": "^26.1.0",
|
|
76
77
|
"less": "^4.3.0",
|
|
77
78
|
"lint-staged": "^16.1.2",
|
|
78
|
-
"marko": "^5.37.
|
|
79
|
+
"marko": "^5.37.41",
|
|
79
80
|
"mocha": "^11.7.1",
|
|
80
81
|
"mocha-snap": "^5.0.0",
|
|
81
82
|
"nyc": "^17.1.0",
|
|
82
|
-
"playwright": "^1.
|
|
83
|
-
"prettier": "^3.6.
|
|
84
|
-
"prettier-plugin-packagejson": "^2.5.
|
|
83
|
+
"playwright": "^1.54.1",
|
|
84
|
+
"prettier": "^3.6.2",
|
|
85
|
+
"prettier-plugin-packagejson": "^2.5.18",
|
|
85
86
|
"serve-handler": "^6.1.6",
|
|
86
87
|
"tsx": "^4.20.3",
|
|
87
88
|
"typescript": "^5.8.3",
|
|
88
|
-
"typescript-eslint": "^8.
|
|
89
|
-
"vite": "^7.0.
|
|
89
|
+
"typescript-eslint": "^8.37.0",
|
|
90
|
+
"vite": "^7.0.4"
|
|
90
91
|
},
|
|
91
92
|
"peerDependencies": {
|
|
92
93
|
"@marko/compiler": "^5",
|