@vuebro/loader-sfc 1.5.22 → 1.6.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.
@@ -23320,29 +23320,30 @@ const jp = "<template></template>", io = async (e) => {
23320
23320
  e.forEach((t) => {
23321
23321
  console.log(t);
23322
23322
  });
23323
- }, Mg = (e) => import(`data:text/javascript;base64,${btoa(Array.from(new TextEncoder().encode(e), (t) => String.fromCodePoint(t)).join(""))}`), uP = async (e) => {
23324
- const { descriptor: t, errors: s } = Hy(await (await io(e)).text() || jp, { filename: e }), n = { expressionPlugins: [] }, i = ["script", "scriptSetup"], o = await Promise.all(i.map(async (f) => {
23325
- const { lang: x = "js", src: m } = t[f] ?? {};
23326
- return /[jt]sx$/.test(x) && n.expressionPlugins?.push("jsx"), /tsx?$/.test(x) && n.expressionPlugins?.push("typescript"), m && await (await io(m)).text();
23327
- })), c = `data-v-${qw(e)}`, l = "preserve", p = {}, d = t.styles.some(({ scoped: f }) => f), { expressionPlugins: g } = n;
23328
- if (Mn(s), d && (p.__scopeId = c), t.script || t.scriptSetup) {
23329
- i.forEach((y, v) => {
23330
- const b = t[y];
23331
- b && o[v] !== void 0 && (b.content = o[v]);
23323
+ }, Mg = async (e) => {
23324
+ const t = URL.createObjectURL(new Blob([e], { type: "application/javascript" })), s = await import(t);
23325
+ return URL.revokeObjectURL(t), s;
23326
+ }, uP = async (e) => {
23327
+ const t = `data-v-${qw(e)}`, { descriptor: s, errors: n } = Hy(await (await io(e)).text() || jp, { filename: e }), i = { cacheHandlers: !0, comments: !1, expressionPlugins: [], hoistStatic: !0, optimizeImports: !0, scopeId: t, sourceMap: !1, ssr: !1 }, o = ["script", "scriptSetup"], c = await Promise.all(o.map(async (f) => {
23328
+ const { lang: x = "js", src: m } = s[f] ?? {};
23329
+ return /[jt]sx$/.test(x) && i.expressionPlugins?.push("jsx"), /tsx?$/.test(x) && i.expressionPlugins?.push("typescript"), m && await (await io(m)).text();
23330
+ })), l = "preserve", p = {}, d = s.styles.some(({ scoped: f }) => f), { expressionPlugins: g } = i;
23331
+ if (Mn(n), d && (p.__scopeId = t), s.script || s.scriptSetup) {
23332
+ o.forEach((y, v) => {
23333
+ const b = s[y];
23334
+ b && c[v] !== void 0 && (b.content = c[v]);
23332
23335
  });
23333
- const { bindings: f, content: x, warnings: m = [] } = Nw(t, { id: c });
23334
- Mn(m), f && (n.bindingMetadata = f), Object.assign(p, (await Mg(g.length ? Rg(x, { jsxRuntime: l, transforms: g }).code : x)).default);
23336
+ const { bindings: f, content: x, warnings: m = [] } = Nw(s, { id: t });
23337
+ Mn(m), f && (i.bindingMetadata = f), Object.assign(p, (await Mg(g.length ? Rg(x, { jsxRuntime: l, transforms: g }).code : x)).default);
23335
23338
  }
23336
- if (t.template) {
23337
- const { code: f, errors: x, tips: m } = Xx({ ast: t.template.ast, compilerOptions: n, filename: t.filename, id: c, scoped: d, slotted: t.slotted, source: t.template.src ? await (await io(t.template.src)).text() : t.template.content, vapor: t.vapor });
23339
+ if (s.template) {
23340
+ const { code: f, errors: x, tips: m } = Xx({ ast: s.template.ast, compilerOptions: i, filename: s.filename, id: t, scoped: d, slotted: s.slotted, source: s.template.src ? await (await io(s.template.src)).text() : s.template.content, vapor: s.vapor });
23338
23341
  Mn(x), Mn(m), Object.assign(p, await Mg(g.length ? Rg(f, { jsxRuntime: l, transforms: g }).code : f));
23339
23342
  }
23340
- return t.styles.forEach((f) => {
23341
- (async (x, { filename: m }, { content: y, module: v, scoped: b = !1, src: E }) => {
23342
- const { code: w, errors: C } = await qE({ filename: m, id: x, modules: !!v, scoped: b, source: E ? await (await io(E)).text() : y });
23343
- Mn(C), Bw(w, b ? { id: x } : void 0);
23344
- })(c, t, f);
23345
- }), p;
23343
+ return await Promise.all(s.styles.map((f) => (async (x, { filename: m }, { content: y, module: v, scoped: b = !1, src: E }) => {
23344
+ const { code: w, errors: C } = await qE({ filename: m, id: x, modules: !!v, scoped: b, source: E ? await (await io(E)).text() : y });
23345
+ Mn(C), Bw(w, b ? { id: x } : void 0);
23346
+ })(t, s, f))), p;
23346
23347
  };
23347
23348
  export {
23348
23349
  uP as default
@@ -25,18 +25,31 @@ const addStyle = async (id, { filename }, { content, module, scoped = false, src
25
25
  });
26
26
  log(errors);
27
27
  useStyleTag(code, scoped ? { id } : undefined);
28
- }, inject = (code) => import(
29
- /* @vite-ignore */
30
- `data:text/javascript;base64,${btoa(Array.from(new TextEncoder().encode(code), (byte) => String.fromCodePoint(byte)).join(""))}`), loadModule = async (filename) => {
31
- const { descriptor, errors } = parse((await (await fetchText(filename)).text()) || body, { filename });
32
- const compilerOptions = { expressionPlugins: [] }, scriptBlocks = ["script", "scriptSetup"], contents = await Promise.all(scriptBlocks.map(async (key) => {
28
+ }, inject = async (code) => {
29
+ const objectURL = URL.createObjectURL(new Blob([code], { type: "application/javascript" })),
30
+ /* @vite-ignore */
31
+ value = (await import(objectURL));
32
+ URL.revokeObjectURL(objectURL);
33
+ return value;
34
+ }, loadModule = async (filename) => {
35
+ const id = `data-v-${hash(filename)}`, { descriptor, errors } = parse((await (await fetchText(filename)).text()) || body, { filename });
36
+ const compilerOptions = {
37
+ cacheHandlers: true,
38
+ comments: false,
39
+ expressionPlugins: [],
40
+ hoistStatic: true,
41
+ optimizeImports: true,
42
+ scopeId: id,
43
+ sourceMap: false,
44
+ ssr: false,
45
+ }, scriptBlocks = ["script", "scriptSetup"], contents = await Promise.all(scriptBlocks.map(async (key) => {
33
46
  const { lang = "js", src } = (descriptor[key] ?? {});
34
47
  if (/[jt]sx$/.test(lang))
35
48
  compilerOptions.expressionPlugins?.push("jsx");
36
49
  if (/tsx?$/.test(lang))
37
50
  compilerOptions.expressionPlugins?.push("typescript");
38
51
  return src && (await (await fetchText(src)).text());
39
- })), id = `data-v-${hash(filename)}`, jsxRuntime = "preserve", module = {}, scoped = descriptor.styles.some(({ scoped }) => scoped), { expressionPlugins: transforms } = compilerOptions;
52
+ })), jsxRuntime = "preserve", module = {}, scoped = descriptor.styles.some(({ scoped }) => scoped), { expressionPlugins: transforms } = compilerOptions;
40
53
  log(errors);
41
54
  if (scoped)
42
55
  module.__scopeId = id;
@@ -75,9 +88,7 @@ const addStyle = async (id, { filename }, { content, module, scoped = false, src
75
88
  ? transform(code, { jsxRuntime, transforms }).code
76
89
  : code));
77
90
  }
78
- descriptor.styles.forEach((style) => {
79
- void addStyle(id, descriptor, style);
80
- });
91
+ await Promise.all(descriptor.styles.map((style) => addStyle(id, descriptor, style)));
81
92
  return module;
82
93
  };
83
94
  export default loadModule;
package/package.json CHANGED
@@ -21,7 +21,7 @@
21
21
  "url": "git+https://github.com/vuebro/loader-sfc.git"
22
22
  },
23
23
  "license": "AGPL-3.0-only",
24
- "version": "1.5.22",
24
+ "version": "1.6.0",
25
25
  "type": "module",
26
26
  "main": "./dist/loader-sfc.js",
27
27
  "types": "./dist/loader-sfc.d.ts",
@@ -34,15 +34,15 @@
34
34
  "@eslint/js": "^9.36.0",
35
35
  "@rollup/plugin-terser": "^0.4.4",
36
36
  "@types/hash-sum": "^1.0.2",
37
- "@types/node": "^24.6.0",
37
+ "@types/node": "^24.6.1",
38
38
  "eslint": "^9.36.0",
39
39
  "eslint-config-prettier": "^10.1.8",
40
40
  "eslint-import-resolver-typescript": "^4.4.4",
41
41
  "eslint-plugin-import-x": "^4.16.1",
42
42
  "eslint-plugin-perfectionist": "^4.15.0",
43
43
  "eslint-plugin-prettier": "^5.5.4",
44
- "jiti": "^2.6.0",
45
- "typescript": "^5.9.2",
44
+ "jiti": "^2.6.1",
45
+ "typescript": "^5.9.3",
46
46
  "typescript-eslint": "^8.45.0",
47
47
  "vite": "^7.1.7"
48
48
  },