@bamboocss/plugin-vue 1.45.5 → 1.46.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.cjs +13 -2
- package/dist/index.mjs +12 -1
- package/package.json +2 -2
package/dist/index.cjs
CHANGED
|
@@ -21,11 +21,22 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
|
|
|
21
21
|
enumerable: true
|
|
22
22
|
}) : target, mod));
|
|
23
23
|
//#endregion
|
|
24
|
-
let _vue_compiler_sfc = require("@vue/compiler-sfc");
|
|
25
24
|
let magic_string = require("magic-string");
|
|
26
25
|
magic_string = __toESM(magic_string);
|
|
26
|
+
let node_module = require("node:module");
|
|
27
27
|
//#region src/vue-to-tsx.ts
|
|
28
28
|
/**
|
|
29
|
+
* Vue's SFC compiler, loaded the first time a `.vue` file is actually parsed.
|
|
30
|
+
*
|
|
31
|
+
* This plugin is auto-injected into every project, so a static import made every build of every
|
|
32
|
+
* project — Vue or not — pay 55ms to load a compiler most of them never call. The `parser:before`
|
|
33
|
+
* hook is synchronous, so this is a lazy `require` rather than a dynamic import.
|
|
34
|
+
*/
|
|
35
|
+
let parseSfc;
|
|
36
|
+
const parse = (...args) => {
|
|
37
|
+
return (parseSfc ??= (0, node_module.createRequire)(require("url").pathToFileURL(__filename).href)("@vue/compiler-sfc").parse)(...args);
|
|
38
|
+
};
|
|
39
|
+
/**
|
|
29
40
|
* @see https://github.com/vuejs/core/blob/d2c3d8b70b2df6e16f053a7ac58e6b04e7b2078f/packages/compiler-core/src/ast.ts#L28-L60
|
|
30
41
|
* import { NodeTypes } from '@vue/compiler-core' isn't working for some reason (?)
|
|
31
42
|
* Cannot read properties of undefined (reading 'ELEMENT')
|
|
@@ -61,7 +72,7 @@ const NodeTypes = {
|
|
|
61
72
|
};
|
|
62
73
|
const vueToTsx = (code) => {
|
|
63
74
|
try {
|
|
64
|
-
const parsed =
|
|
75
|
+
const parsed = parse(code);
|
|
65
76
|
const fileStr = new magic_string.default(`<template>${parsed.descriptor.template?.content}</template>`);
|
|
66
77
|
const rewriteProp = (prop) => {
|
|
67
78
|
if (prop.type === NodeTypes.DIRECTIVE && prop.exp?.type === NodeTypes.SIMPLE_EXPRESSION && prop.arg?.type === NodeTypes.SIMPLE_EXPRESSION) fileStr.replace(prop.loc.source, `${prop.arg.content}={${prop.exp.content}}`);
|
package/dist/index.mjs
CHANGED
|
@@ -1,7 +1,18 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { createRequire } from "node:module";
|
|
2
2
|
import MagicString from "magic-string";
|
|
3
3
|
//#region src/vue-to-tsx.ts
|
|
4
4
|
/**
|
|
5
|
+
* Vue's SFC compiler, loaded the first time a `.vue` file is actually parsed.
|
|
6
|
+
*
|
|
7
|
+
* This plugin is auto-injected into every project, so a static import made every build of every
|
|
8
|
+
* project — Vue or not — pay 55ms to load a compiler most of them never call. The `parser:before`
|
|
9
|
+
* hook is synchronous, so this is a lazy `require` rather than a dynamic import.
|
|
10
|
+
*/
|
|
11
|
+
let parseSfc;
|
|
12
|
+
const parse = (...args) => {
|
|
13
|
+
return (parseSfc ??= createRequire(import.meta.url)("@vue/compiler-sfc").parse)(...args);
|
|
14
|
+
};
|
|
15
|
+
/**
|
|
5
16
|
* @see https://github.com/vuejs/core/blob/d2c3d8b70b2df6e16f053a7ac58e6b04e7b2078f/packages/compiler-core/src/ast.ts#L28-L60
|
|
6
17
|
* import { NodeTypes } from '@vue/compiler-core' isn't working for some reason (?)
|
|
7
18
|
* Cannot read properties of undefined (reading 'ELEMENT')
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@bamboocss/plugin-vue",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.46.1",
|
|
4
4
|
"description": "Bamboo CSS plugin for Vue single file component support",
|
|
5
5
|
"homepage": "https://bamboocss.com",
|
|
6
6
|
"license": "MIT",
|
|
@@ -35,7 +35,7 @@
|
|
|
35
35
|
"dependencies": {
|
|
36
36
|
"@vue/compiler-sfc": "3.5.41",
|
|
37
37
|
"magic-string": "0.30.21",
|
|
38
|
-
"@bamboocss/types": "1.
|
|
38
|
+
"@bamboocss/types": "1.46.1"
|
|
39
39
|
},
|
|
40
40
|
"devDependencies": {
|
|
41
41
|
"@vue/compiler-core": "3.5.41"
|