@marko/vite 5.1.7 → 5.2.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/glob-import-transform.d.ts +1 -1
- package/dist/index.mjs +33 -11
- package/package.json +15 -14
package/dist/index.mjs
CHANGED
|
@@ -160,6 +160,7 @@ function plugin(options) {
|
|
|
160
160
|
import * as compiler from "@marko/compiler";
|
|
161
161
|
import fs2 from "fs";
|
|
162
162
|
import path2 from "path";
|
|
163
|
+
var importTagReg = /<([^>]+)>/;
|
|
163
164
|
var markoErrorRegExp = /^(.+?)(?:\((\d+)(?:\s*,\s*(\d+))?\))?: (.*)$/gm;
|
|
164
165
|
function esbuildPlugin(config) {
|
|
165
166
|
return {
|
|
@@ -183,6 +184,16 @@ function esbuildPlugin(config) {
|
|
|
183
184
|
external: true
|
|
184
185
|
};
|
|
185
186
|
});
|
|
187
|
+
build.onResolve({ filter: importTagReg }, (args) => {
|
|
188
|
+
const tagName = importTagReg.exec(args.path)?.[1];
|
|
189
|
+
if (tagName) {
|
|
190
|
+
const tagDef = compiler.taglib.buildLookup(args.resolveDir).getTag(tagName);
|
|
191
|
+
const tagFile = tagDef && (tagDef.template || tagDef.renderer);
|
|
192
|
+
if (tagFile) {
|
|
193
|
+
return { path: tagFile };
|
|
194
|
+
}
|
|
195
|
+
}
|
|
196
|
+
});
|
|
186
197
|
build.onLoad({ filter: /\.marko$/ }, async (args) => {
|
|
187
198
|
try {
|
|
188
199
|
const { code, meta } = await compiler.compileFile(
|
|
@@ -233,6 +244,7 @@ function esbuildPlugin(config) {
|
|
|
233
244
|
import { types as t2 } from "@marko/compiler";
|
|
234
245
|
import glob from "fast-glob";
|
|
235
246
|
import path3 from "path";
|
|
247
|
+
import { relativeImportPath } from "relative-import-path";
|
|
236
248
|
var programGlobImports = /* @__PURE__ */ new WeakMap();
|
|
237
249
|
var glob_import_transform_default = {
|
|
238
250
|
MetaProperty(tag) {
|
|
@@ -254,18 +266,17 @@ var glob_import_transform_default = {
|
|
|
254
266
|
}
|
|
255
267
|
},
|
|
256
268
|
Program: {
|
|
257
|
-
exit(
|
|
258
|
-
const globImports = programGlobImports.get(
|
|
269
|
+
exit(program) {
|
|
270
|
+
const globImports = programGlobImports.get(program);
|
|
259
271
|
if (!globImports) {
|
|
260
272
|
return;
|
|
261
273
|
}
|
|
262
|
-
const { cwd, filename } =
|
|
274
|
+
const { cwd, filename } = program.hub.file.opts;
|
|
263
275
|
const dir = path3.dirname(filename);
|
|
264
276
|
const seen = /* @__PURE__ */ new Set();
|
|
265
277
|
for (const [patterns, options] of globImports) {
|
|
266
|
-
const
|
|
267
|
-
|
|
268
|
-
cwd,
|
|
278
|
+
const results = glob.globSync(patterns, {
|
|
279
|
+
cwd: dir,
|
|
269
280
|
absolute: true,
|
|
270
281
|
dot: !!options.exhaustive,
|
|
271
282
|
ignore: options.exhaustive ? [] : [path3.join(cwd, "**/node_modules/**")]
|
|
@@ -273,7 +284,12 @@ var glob_import_transform_default = {
|
|
|
273
284
|
for (const file of results) {
|
|
274
285
|
if (file.endsWith(".marko") && file !== filename && !seen.has(file)) {
|
|
275
286
|
seen.add(file);
|
|
276
|
-
|
|
287
|
+
program.node.body.push(
|
|
288
|
+
t2.importDeclaration(
|
|
289
|
+
[],
|
|
290
|
+
t2.stringLiteral(relativeImportPath(filename, file))
|
|
291
|
+
)
|
|
292
|
+
);
|
|
277
293
|
}
|
|
278
294
|
}
|
|
279
295
|
}
|
|
@@ -726,8 +742,7 @@ static function flush($global, html) {
|
|
|
726
742
|
static function setFlush($global) {
|
|
727
743
|
$global.__flush__ = flush;
|
|
728
744
|
}
|
|
729
|
-
|
|
730
|
-
<const/writeSync=addAssets($global, assets) || setFlush($global)/>
|
|
745
|
+
<const/writeSync=addAssets($global, [${opts.entryData.join(",")}]) || setFlush($global)/>
|
|
731
746
|
-- $!{writeSync && getPrepend($global)}
|
|
732
747
|
<Template ...input/>
|
|
733
748
|
-- $!{writeSync && getAppend($global)}
|
|
@@ -736,8 +751,7 @@ static const assets = [${opts.entryData.join(",")}];
|
|
|
736
751
|
return `import template from ${fileNameStr};
|
|
737
752
|
export * from ${fileNameStr};
|
|
738
753
|
import { addAssets, getPrepend, getAppend } from "${renderAssetsRuntimeId}";
|
|
739
|
-
|
|
740
|
-
<if(addAssets($global, assets))>
|
|
754
|
+
<if(addAssets($global, [${opts.entryData.join(",")}]))>
|
|
741
755
|
$!{getPrepend($global)}
|
|
742
756
|
<\${template} ...input/>
|
|
743
757
|
$!{getAppend($global)}
|
|
@@ -760,6 +774,7 @@ var normalizePath = path6.sep === WINDOWS_SEP ? (id) => id.replace(/\\/g, POSIX_
|
|
|
760
774
|
var virtualFiles = /* @__PURE__ */ new Map();
|
|
761
775
|
var extReg = /\.[^.]+$/;
|
|
762
776
|
var queryReg = /\?marko-[^?]+$/;
|
|
777
|
+
var importTagReg2 = /^<([^>]+)>$/;
|
|
763
778
|
var browserEntryQuery = "?marko-browser-entry";
|
|
764
779
|
var serverEntryQuery = "?marko-server-entry";
|
|
765
780
|
var virtualFileQuery = "?marko-virtual";
|
|
@@ -1127,6 +1142,13 @@ function markoPlugin(opts = {}) {
|
|
|
1127
1142
|
if (importee === renderAssetsRuntimeId) {
|
|
1128
1143
|
return { id: renderAssetsRuntimeId };
|
|
1129
1144
|
}
|
|
1145
|
+
if (importer) {
|
|
1146
|
+
const tagName = importTagReg2.exec(importee)?.[1];
|
|
1147
|
+
if (tagName) {
|
|
1148
|
+
const tagDef = compiler2.taglib.buildLookup(path6.dirname(importer)).getTag(tagName);
|
|
1149
|
+
return tagDef && (tagDef.template || tagDef.renderer);
|
|
1150
|
+
}
|
|
1151
|
+
}
|
|
1130
1152
|
let importeeQuery = getMarkoQuery(importee);
|
|
1131
1153
|
if (importeeQuery) {
|
|
1132
1154
|
importee = importee.slice(0, -importeeQuery.length);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@marko/vite",
|
|
3
|
-
"version": "5.1
|
|
3
|
+
"version": "5.2.1",
|
|
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",
|