@vuebro/loader-sfc 2.0.1 → 2.0.2

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.
@@ -22,9 +22,12 @@ const fetchText = async (url) => {
22
22
  URL.revokeObjectURL(objectURL);
23
23
  return value;
24
24
  }, loadModule = async (filename) => {
25
+ const alerts = new Set(), id = `data-v-${hash(filename)}`, { descriptor, errors } = parse((await (await fetchText(filename)).text()) || "<template></template>"), { script, scriptSetup, slotted, styles, template } = descriptor;
25
26
  const compilerOptions = {
26
27
  expressionPlugins: ["jsx", "typescript"],
27
- }, id = hash(filename), module = {}, { descriptor, errors } = parse((await (await fetchText(filename)).text()) || "<template></template>"), { script, scriptSetup, slotted, styles, template } = descriptor;
28
+ scopeId: id,
29
+ slotted,
30
+ }, scoped = styles.some(({ scoped }) => scoped), module = scoped ? { __scopeId: id } : {};
28
31
  log(errors);
29
32
  let el = document.getElementById(id);
30
33
  if (!(el instanceof HTMLStyleElement)) {
@@ -33,16 +36,18 @@ const fetchText = async (url) => {
33
36
  document.head.appendChild(el);
34
37
  }
35
38
  el.textContent = (await Promise.all(styles.map(async ({ content, module, scoped = false, src }) => {
39
+ if (module)
40
+ alerts.add("<style module> is not supported in the playground.");
36
41
  const { code, errors } = await compileStyleAsync({
37
42
  filename,
38
43
  id,
39
- modules: !!module,
40
44
  scoped,
41
45
  source: src ? await (await fetchText(src)).text() : content,
42
46
  });
43
47
  log(errors);
44
48
  return code;
45
49
  }))).join("\n");
50
+ log([...alerts]);
46
51
  if (script || scriptSetup) {
47
52
  const { bindings, content, warnings = [], } = compileScript(descriptor, { id });
48
53
  log(warnings);
@@ -51,12 +56,13 @@ const fetchText = async (url) => {
51
56
  Object.assign(module, (await inject(transform(content, options).code)).default);
52
57
  }
53
58
  if (template) {
54
- const { content: source } = template;
59
+ const { ast, content: source } = template;
55
60
  const { code, errors, tips } = compileTemplate({
61
+ ...(ast && { ast }),
56
62
  compilerOptions,
57
63
  filename,
58
64
  id,
59
- scoped: styles.some(({ scoped }) => scoped),
65
+ scoped,
60
66
  slotted,
61
67
  source,
62
68
  });
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": "2.0.1",
24
+ "version": "2.0.2",
25
25
  "type": "module",
26
26
  "main": "./dist/loader-sfc.js",
27
27
  "types": "./dist/loader-sfc.d.ts",
@@ -44,7 +44,7 @@
44
44
  "jiti": "^2.6.1",
45
45
  "typescript": "^5.9.3",
46
46
  "typescript-eslint": "^8.45.0",
47
- "vite": "^7.1.8"
47
+ "vite": "^7.1.9"
48
48
  },
49
49
  "dependencies": {
50
50
  "@vue/compiler-sfc": "^3.5.22",