Skip to content

Commit 88f4131

Browse files
committedDec 27, 2023
feat: support unimport parser
1 parent def8007 commit 88f4131

File tree

9 files changed

+1438
-1696
lines changed

9 files changed

+1438
-1696
lines changed
 

‎examples/solid-js/package.json

+4-4
Original file line numberDiff line numberDiff line change
@@ -11,12 +11,12 @@
1111
"serve": "vite preview"
1212
},
1313
"dependencies": {
14-
"@solidjs/router": "^0.9.1",
14+
"@solidjs/router": "^0.10.5",
1515
"solid-js": "^1.8.7"
1616
},
1717
"devDependencies": {
18-
"typescript": "^5.3.2",
19-
"vite": "^5.0.4",
20-
"vite-plugin-solid": "^2.7.2"
18+
"typescript": "^5.3.3",
19+
"vite": "^5.0.10",
20+
"vite-plugin-solid": "^2.8.0"
2121
}
2222
}

‎examples/vite-astro/package.json

+5-5
Original file line numberDiff line numberDiff line change
@@ -11,14 +11,14 @@
1111
"astro": "astro"
1212
},
1313
"devDependencies": {
14-
"@astrojs/react": "^3.0.6",
15-
"@astrojs/svelte": "^4.0.4",
16-
"@astrojs/vue": "^3.0.4",
17-
"astro": "^3.6.4",
14+
"@astrojs/react": "^3.0.8",
15+
"@astrojs/svelte": "^5.0.2",
16+
"@astrojs/vue": "^4.0.5",
17+
"astro": "^4.0.7",
1818
"react": "^18.2.0",
1919
"react-dom": "^18.2.0",
2020
"svelte": "^4.2.8",
2121
"unplugin-auto-import": "workspace:*",
22-
"vue": "^3.3.9"
22+
"vue": "^3.3.13"
2323
}
2424
}

‎examples/vite-react/package.json

+8-8
Original file line numberDiff line numberDiff line change
@@ -9,22 +9,22 @@
99
},
1010
"dependencies": {
1111
"ahooks": "^3.7.8",
12-
"i18next": "^23.7.7",
12+
"i18next": "^23.7.11",
1313
"react": "^18.2.0",
1414
"react-dom": "^18.2.0",
15-
"react-i18next": "^13.5.0",
16-
"react-router": "^6.20.1",
17-
"react-router-dom": "^6.20.1"
15+
"react-i18next": "^14.0.0",
16+
"react-router": "^6.21.1",
17+
"react-router-dom": "^6.21.1"
1818
},
1919
"devDependencies": {
2020
"@iconify-json/logos": "*",
2121
"@svgr/core": "^8.1.0",
22-
"@types/react": "^18.2.41",
23-
"@types/react-dom": "^18.2.17",
22+
"@types/react": "^18.2.45",
23+
"@types/react-dom": "^18.2.18",
2424
"@vitejs/plugin-react-refresh": "^1.3.6",
25-
"typescript": "^5.3.2",
25+
"typescript": "^5.3.3",
2626
"unplugin-auto-import": "workspace:*",
2727
"unplugin-icons": "^0.18.1",
28-
"vite": "^5.0.4"
28+
"vite": "^5.0.10"
2929
}
3030
}

‎examples/vite-svelte/package.json

+3-3
Original file line numberDiff line numberDiff line change
@@ -14,11 +14,11 @@
1414
"detect-browser-es": "^0.1.0",
1515
"svelte": "^4.2.8",
1616
"svelte-check": "^3.6.2",
17-
"svelte-preprocess": "^5.1.1",
17+
"svelte-preprocess": "^5.1.3",
1818
"tslib": "^2.6.2",
19-
"typescript": "^5.3.2",
19+
"typescript": "^5.3.3",
2020
"unplugin-auto-import": "workspace:*",
21-
"vite": "^5.0.4",
21+
"vite": "^5.0.10",
2222
"vite-plugin-inspect": "^0.8.1"
2323
}
2424
}

‎package.json

+15-15
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"name": "unplugin-auto-import",
33
"type": "module",
44
"version": "0.17.2",
5-
"packageManager": "pnpm@8.11.0",
5+
"packageManager": "pnpm@8.13.1",
66
"description": "Register global imports on demand for Vite and Webpack",
77
"author": "Anthony Fu <anthonyfu117@hotmail.com>",
88
"license": "MIT",
@@ -162,32 +162,32 @@
162162
}
163163
},
164164
"dependencies": {
165-
"@antfu/utils": "^0.7.6",
165+
"@antfu/utils": "^0.7.7",
166166
"@rollup/pluginutils": "^5.1.0",
167167
"fast-glob": "^3.3.2",
168168
"local-pkg": "^0.5.0",
169169
"magic-string": "^0.30.5",
170170
"minimatch": "^9.0.3",
171-
"unimport": "^3.6.0",
172-
"unplugin": "^1.5.1"
171+
"unimport": "^3.7.0",
172+
"unplugin": "^1.6.0"
173173
},
174174
"devDependencies": {
175-
"@antfu/eslint-config": "^2.2.2",
175+
"@antfu/eslint-config": "^2.6.1",
176176
"@antfu/ni": "^0.21.12",
177-
"@nuxt/kit": "^3.8.2",
177+
"@nuxt/kit": "^3.9.0",
178178
"@svgr/plugin-jsx": "^8.1.0",
179-
"@types/node": "^20.10.2",
179+
"@types/node": "^20.10.5",
180180
"@types/resolve": "^1.20.6",
181-
"@vueuse/metadata": "^10.6.1",
182-
"bumpp": "^9.2.0",
183-
"eslint": "^8.55.0",
181+
"@vueuse/metadata": "^10.7.0",
182+
"bumpp": "^9.2.1",
183+
"eslint": "^8.56.0",
184184
"esno": "^4.0.0",
185-
"publint": "^0.2.6",
186-
"rollup": "^4.6.1",
185+
"publint": "^0.2.7",
186+
"rollup": "^4.9.1",
187187
"tsup": "^8.0.1",
188-
"typescript": "^5.3.2",
189-
"vite": "^5.0.4",
190-
"vitest": "^0.34.6",
188+
"typescript": "^5.3.3",
189+
"vite": "^5.0.10",
190+
"vitest": "^1.1.0",
191191
"webpack": "^5.89.0"
192192
}
193193
}

‎playground/package.json

+5-5
Original file line numberDiff line numberDiff line change
@@ -5,15 +5,15 @@
55
"build": "vite build"
66
},
77
"dependencies": {
8-
"@vueuse/core": "^10.6.1",
8+
"@vueuse/core": "^10.7.0",
99
"vue": "3.3.4"
1010
},
1111
"devDependencies": {
12-
"@vitejs/plugin-vue": "^4.5.1",
13-
"@vue/compiler-sfc": "^3.3.9",
14-
"element-plus": "^2.4.3",
12+
"@vitejs/plugin-vue": "^5.0.0",
13+
"@vue/compiler-sfc": "^3.3.13",
14+
"element-plus": "^2.4.4",
1515
"unplugin-vue-components": "^0.26.0",
16-
"vite": "^5.0.4",
16+
"vite": "^5.0.10",
1717
"vite-plugin-inspect": "^0.8.1"
1818
}
1919
}

‎pnpm-lock.yaml

+1,388-1,655
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎src/core/ctx.ts

+1
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,7 @@ export function createContext(options: Options = {}, root = process.cwd()) {
5757
imports: [],
5858
presets: options.packagePresets?.map(p => typeof p === 'string' ? { package: p } : p) ?? [],
5959
injectAtEnd,
60+
parser: options.parser,
6061
addons: [
6162
...(options.vueTemplate ? [vueTemplateAddon()] : []),
6263
resolversAddon(resolvers),

‎src/types.ts

+9-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import type { Arrayable, Awaitable } from '@antfu/utils'
22
import type { FilterPattern } from '@rollup/pluginutils'
3-
import type { Import, InlinePreset, PackagePreset } from 'unimport'
3+
import type { Import, InlinePreset, PackagePreset, UnimportOptions } from 'unimport'
44
import { PresetName } from './presets'
55

66
export interface ImportLegacy {
@@ -112,6 +112,14 @@ export interface Options {
112112
*/
113113
resolvers?: Arrayable<Arrayable<Resolver>>
114114

115+
/**
116+
* Parser to be used for parsing the source code.
117+
*
118+
* @see https://github.com/unjs/unimport#acorn-parser
119+
* @default 'regex'
120+
*/
121+
parser?: UnimportOptions['parser']
122+
115123
/**
116124
* Filepath to generate corresponding .d.ts file.
117125
* Default enabled when `typescript` is installed locally.

0 commit comments

Comments
 (0)
Please sign in to comment.