Skip to content

Commit 2b890d1

Browse files
committed
refactor: 子包里使用 createRequire 动态获取 PACKAGE_NAME
1 parent 749c55e commit 2b890d1

4 files changed

Lines changed: 6 additions & 4 deletions

File tree

packages/components/resolver.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
11
import type { ImportsMap } from 'unplugin-auto-import/types'
22
import type { ComponentResolver, TypeImport } from 'unplugin-vue-components'
3+
import { createRequire } from 'node:module'
34

45
const COMPONENT_PREFIX = 'Fa'
5-
const PACKAGE_NAME = '@fantastic-admin/components'
6+
const PACKAGE_NAME = createRequire(import.meta.url)('./package.json').name
67

78
const BASIC_COMPONENT_NAMES = [
89
'FaAlert',

packages/components/tsconfig.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"extends": "../../tsconfig.json",
33
"compilerOptions": {
44
"lib": ["ESNext", "DOM", "DOM.Iterable"],
5-
"types": ["vite/client"]
5+
"types": ["vite/client", "node"]
66
},
77
"include": [
88
"resolver.ts",

packages/composables/resolver.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import type { ImportsMap } from 'unplugin-auto-import/types'
2+
import { createRequire } from 'node:module'
23

3-
const PACKAGE_NAME = '@fantastic-admin/composables'
4+
const PACKAGE_NAME = createRequire(import.meta.url)('./package.json').name
45

56
const AUTO_IMPORT_NAMES = [
67
'usePagination',

packages/composables/tsconfig.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"extends": "../../tsconfig.json",
33
"compilerOptions": {
44
"lib": ["ESNext", "DOM", "DOM.Iterable"],
5-
"types": ["vite/client"]
5+
"types": ["vite/client", "node"]
66
},
77
"include": [
88
"resolver.ts",

0 commit comments

Comments
 (0)