@vue-macros/common
Advanced tools
+1
-1
@@ -23,3 +23,3 @@ import { CodeTransform, MagicString, MagicStringAST } from "magic-string-ast"; | ||
| declare const HELPER_PREFIX = "__MACROS_"; | ||
| declare function importHelperFn(s: MagicString, offset: number, imported: string, local?: string, from?: string): string; | ||
| declare function importHelperFn(s: MagicString, offset: number, imported: string, local?: string, from?: string, prefix?: string): string; | ||
| //#endregion | ||
@@ -26,0 +26,0 @@ //#region src/constants.d.ts |
+4
-4
@@ -67,10 +67,10 @@ import { babelParse, getLang, isFunctionType, isLiteralType, resolveObjectKey, resolveString } from "ast-kit"; | ||
| const HELPER_PREFIX = "__MACROS_"; | ||
| function importHelperFn(s, offset, imported, local = imported, from = "vue") { | ||
| const cacheKey = `${from}@${imported}`; | ||
| function importHelperFn(s, offset, imported, local = imported, from = "vue", prefix = HELPER_PREFIX) { | ||
| const cacheKey = `${from}@${imported}@${prefix}@${local}`; | ||
| if (!importedMap.get(s)?.has(cacheKey)) { | ||
| s.appendLeft(offset, `\nimport ${imported === "default" ? HELPER_PREFIX + local : `{ ${imported} as ${HELPER_PREFIX + local} }`} from ${JSON.stringify(from)};`); | ||
| s.appendLeft(offset, `\nimport ${imported === "default" ? prefix + local : `{ ${imported} as ${prefix + local} }`} from ${JSON.stringify(from)};`); | ||
| if (importedMap.has(s)) importedMap.get(s).add(cacheKey); | ||
| else importedMap.set(s, new Set([cacheKey])); | ||
| } | ||
| return `${HELPER_PREFIX}${local}`; | ||
| return `${prefix}${local}`; | ||
| } | ||
@@ -77,0 +77,0 @@ |
+1
-1
| { | ||
| "name": "@vue-macros/common", | ||
| "version": "3.1.2", | ||
| "version": "3.1.3", | ||
| "description": "common feature from Vue Macros.", | ||
@@ -5,0 +5,0 @@ "type": "module", |
19366
0.2%