Skip to content

Commit 514bcb5

Browse files
committed
refactor: upgrade @vue-macros/common package
1 parent 48e2057 commit 514bcb5

File tree

4 files changed

+26
-31
lines changed

4 files changed

+26
-31
lines changed

package.json

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -75,10 +75,8 @@
7575
"prepublishOnly": "pnpm run build"
7676
},
7777
"dependencies": {
78-
"@rollup/pluginutils": "^5.0.2",
79-
"@vue-macros/common": "^1.1.1",
78+
"@vue-macros/common": "^1.1.4",
8079
"change-case": "^4.1.2",
81-
"magic-string": "^0.30.0",
8280
"unplugin": "^1.3.1"
8381
},
8482
"devDependencies": {

pnpm-lock.yaml

Lines changed: 15 additions & 9 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/core/options.ts

Lines changed: 6 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,15 @@
1-
import type { FilterPattern } from '@rollup/pluginutils'
2-
3-
export interface Options {
4-
include?: FilterPattern
5-
exclude?: FilterPattern
1+
import { type BaseOptions } from '@vue-macros/common'
62

3+
export interface Options extends Pick<BaseOptions, 'include' | 'exclude'> {
74
resolveName?(id: string): string | Promise<string>
85
}
96

10-
export type OptionsResolved = Omit<
11-
Required<Options>,
12-
'exclude' | 'resolveName'
13-
> & {
14-
exclude?: Options['exclude']
15-
resolveName?: Options['resolveName']
16-
}
7+
export type OptionsResolved = Pick<Required<Options>, 'include'> &
8+
Pick<Options, 'exclude' | 'resolveName'>
179

1810
export function resolveOption(options: Options): OptionsResolved {
1911
return {
20-
include: options.include || [/\.vue$/],
21-
exclude: options.exclude,
22-
resolveName: options.resolveName
12+
include: [/\.vue$/],
13+
...options,
2314
}
2415
}

src/index.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
import path from 'node:path'
22
import { createUnplugin } from 'unplugin'
3-
import { createFilter } from '@rollup/pluginutils'
43
import { camelCase } from 'change-case'
54
import {
6-
MagicString,
5+
MagicStringBase,
76
babelParse,
7+
createFilter,
88
getLang,
99
getTransformResult,
1010
} from '@vue-macros/common'
@@ -25,7 +25,7 @@ function getNodeStart(node: Node) {
2525

2626
export default createUnplugin<Options | undefined>((rawOptions = {}) => {
2727
const options = resolveOption(rawOptions)
28-
const filter = createFilter(options.include, options.exclude)
28+
const filter = createFilter(options)
2929

3030
const name = 'unplugin-vue-named-export'
3131
return {
@@ -48,7 +48,7 @@ export default createUnplugin<Options | undefined>((rawOptions = {}) => {
4848
)
4949
if (!defaultExport) return
5050

51-
const s = new MagicString(code)
51+
const s = new MagicStringBase(code)
5252
const resolvedName = (options.resolveName || resolveName)(id)
5353

5454
s.overwrite(

0 commit comments

Comments
 (0)