diff --git a/.vscode/extensions.json b/.vscode/extensions.json new file mode 100644 index 00000000..7b5ef185 --- /dev/null +++ b/.vscode/extensions.json @@ -0,0 +1,6 @@ +{ + "recommendations": [ + "dbaeumer.vscode-eslint", + "antfu.pnpm-catalog-lens" + ] +} diff --git a/.vscode/settings.json b/.vscode/settings.json index 0967ef42..78994605 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -1 +1,37 @@ -{} +{ + "prettier.enable": false, + "editor.formatOnSave": false, + + // Auto fix + "editor.codeActionsOnSave": { + "source.fixAll.eslint": "explicit", + "source.organizeImports": "never" + }, + + // Silent the stylistic rules in you IDE, but still auto fix them + "eslint.rules.customizations": [ + { "rule": "style/*", "severity": "off" }, + { "rule": "*-indent", "severity": "off" }, + { "rule": "*-spacing", "severity": "off" }, + { "rule": "*-spaces", "severity": "off" }, + { "rule": "*-order", "severity": "off" }, + { "rule": "*-dangle", "severity": "off" }, + { "rule": "*-newline", "severity": "off" }, + { "rule": "*quotes", "severity": "off" }, + { "rule": "*semi", "severity": "off" } + ], + + // Enable eslint for all supported languages + "eslint.validate": [ + "javascript", + "javascriptreact", + "typescript", + "typescriptreact", + "vue", + "html", + "markdown", + "json", + "jsonc", + "yaml" + ] +} diff --git a/README.md b/README.md index 4dae3169..2f7157fa 100644 --- a/README.md +++ b/README.md @@ -8,12 +8,12 @@ Unified plugin system for build tools. Currently supports: -- [Vite](https://vitejs.dev/) +- [Vite](https://vite.dev/) - [Rollup](https://rollupjs.org/) - [Webpack](https://webpack.js.org/) - [esbuild](https://esbuild.github.io/) - [Rspack](https://www.rspack.dev/) -- [Rolldown](https://rolldown.rs/) (⚠️ experimental) +- [Rolldown](https://rolldown.rs/) - [Farm](https://www.farmfe.org/) - And every framework built on top of them. diff --git a/docs/guide/index.md b/docs/guide/index.md index 0a5031b1..6e0fd129 100644 --- a/docs/guide/index.md +++ b/docs/guide/index.md @@ -11,12 +11,12 @@ lastUpdated: false **Unplugin** current supports: -- [Vite](https://vitejs.dev/) +- [Vite](https://vite.dev/) - [Rollup](https://rollupjs.org/) - [webpack](https://webpack.js.org/) - [esbuild](https://esbuild.github.io/) - [Rspack](https://www.rspack.dev/) -- [Rolldown](https://rolldown.rs/) (⚠️ experimental) +- [Rolldown](https://rolldown.rs/) - [Farm](https://www.farmfe.org/) ## Trying It Online @@ -195,12 +195,12 @@ export default defineConfig({ | Hook | Rollup | Vite | webpack | esbuild | Rspack | Farm | Rolldown | | --------------------------------------------------------------------------------- | :-------------: | :--: | :-----: | :-------------: | :-------------: | :--: | :------: | -| [`enforce`](https://vitejs.dev/guide/api-plugin.html#plugin-ordering) | ❌ 1 | ✅ | ✅ | ❌ 1 | ✅ | ✅ | ✅ | +| [`enforce`](https://vite.dev/guide/api-plugin.html#plugin-ordering) | ❌ 1 | ✅ | ✅ | ❌ 1 | ✅ | ✅ | ✅ | | [`buildStart`](https://rollupjs.org/plugin-development/#buildstart) | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | | [`resolveId`](https://rollupjs.org/plugin-development/#resolveid) | ✅ | ✅ | ✅ | ✅ | ✅ 5 | ✅ | ✅ | -| `loadInclude`2 | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | +| ~~`loadInclude`~~2 | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | | [`load`](https://rollupjs.org/plugin-development/#load) | ✅ | ✅ | ✅ | ✅ 3 | ✅ | ✅ | ✅ | -| `transformInclude`2 | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | +| ~~`transformInclude`~~2 | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | | [`transform`](https://rollupjs.org/plugin-development/#transform) | ✅ | ✅ | ✅ | ✅ 3 | ✅ | ✅ | ✅ | | [`watchChange`](https://rollupjs.org/plugin-development/#watchchange) | ✅ | ✅ | ✅ | ❌ | ✅ | ✅ | ✅ | | [`buildEnd`](https://rollupjs.org/plugin-development/#buildend) | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | @@ -209,11 +209,14 @@ export default defineConfig({ ::: details Notice 1. Rollup and esbuild do not support using `enforce` to control the order of plugins. Users need to maintain the order manually. -2. webpack's id filter is outside of loader logic; an additional hook is needed for better perf on webpack. In Rollup and Vite, this hook has been polyfilled to match the behaviors. See for the following usage examples. +2. Webpack's id filter is outside of loader logic; an additional hook is needed for better performance on Webpack and Rolldown. + However, it is now deprecated. Please use `transform/load/resolveId.filter` instead. + In Rollup, this hook has been polyfilled to match the behaviors. See the following usage examples for reference. 3. Although esbuild can handle both JavaScript and CSS and many other file formats, you can only return JavaScript in `load` and `transform` results. 4. Currently, `writeBundle` is only serves as a hook for the timing. It doesn't pass any arguments. 5. Rspack supports `resolveId` with a minimum required version of v1.0.0-alpha.1. - ::: + +::: ### Usage @@ -227,14 +230,14 @@ export interface Options { export const unpluginFactory: UnpluginFactory = options => ({ name: 'unplugin-starter', - // webpack's id filter is outside of loader logic, - // an additional hook is needed for better perf on webpack - transformInclude(id) { - return id.endsWith('main.ts') - }, - // just like rollup transform - transform(code) { - return code.replace(/