Skip to content

Commit 0df8218

Browse files
authored
feat: support esbuild (#269)
1 parent 557b150 commit 0df8218

File tree

5 files changed

+48
-17
lines changed

5 files changed

+48
-17
lines changed

README.md

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ On-demand components auto importing for Vue.
88

99
- 💚 Supports both Vue 2 and Vue 3 out-of-the-box.
1010
- ✨ Supports both components and directives.
11-
- ⚡️ Supports Vite, Webpack, Vue CLI, Rollup and more, powered by <a href="https://github.com/unjs/unplugin">unplugin</a>.
11+
- ⚡️ Supports Vite, Webpack, Vue CLI, Rollup, esbuild and more, powered by <a href="https://github.com/unjs/unplugin">unplugin</a>.
1212
- 🏝 Tree-shakable, only registers the components you use.
1313
- 🪐 Folder names as namespaces.
1414
- 🦾 Full TypeScript support.
@@ -104,6 +104,25 @@ module.exports = {
104104

105105
<br></details>
106106

107+
<details>
108+
<summary>esbuild</summary><br>
109+
110+
```ts
111+
// esbuild.config.js
112+
import { build } from 'esbuild'
113+
114+
build({
115+
/* ... */
116+
plugins: [
117+
require('unplugin-vue-components/esbuild')({
118+
/* options */
119+
}),
120+
],
121+
})
122+
```
123+
124+
<br></details>
125+
107126
## Usage
108127

109128
Use components in templates as you would usually do, it will import components on demand, and there is no `import` and `component registration` required anymore! If you register the parent component asynchronously (or lazy route), the auto-imported components will be code-split along with their parent.

esbuild.d.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
export * from './dist/esbuild'
2+
export { default } from './dist/esbuild'

package.json

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,10 @@
4444
"./webpack": {
4545
"require": "./dist/webpack.js",
4646
"import": "./dist/webpack.mjs"
47+
},
48+
"./esbuild": {
49+
"require": "./dist/esbuild.js",
50+
"import": "./dist/esbuild.mjs"
4751
}
4852
},
4953
"main": "dist/index.js",
@@ -82,7 +86,7 @@
8286
"magic-string": "^0.25.7",
8387
"minimatch": "^3.0.4",
8488
"resolve": "^1.20.0",
85-
"unplugin": "^0.2.21"
89+
"unplugin": "^0.3.0"
8690
},
8791
"devDependencies": {
8892
"@antfu/eslint-config": "^0.10.0",

pnpm-lock.yaml

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

src/esbuild.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
import unplugin from '.'
2+
3+
export default unplugin.esbuild

0 commit comments

Comments
 (0)