From 91d052811764fbe8b2822e2c56dace08ca33a64c Mon Sep 17 00:00:00 2001 From: userquin Date: Sat, 2 Dec 2023 15:46:55 +0100 Subject: [PATCH 1/4] docs: update cjs usage in readme file --- README.md | 94 ++++++++++++++++++++++++++++++++++++++++++++++++++++--- 1 file changed, 90 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index 951a463..4909e6d 100644 --- a/README.md +++ b/README.md @@ -89,6 +89,18 @@ export default {
Webpack
+From version `v0.17.0+` you need to use `default` export: +```ts +// webpack.config.js +module.exports = { + /* ... */ + plugins: [ + require('unplugin-auto-import/webpack').default({ /* options */ }), + ], +} +``` + +If you are using a version earlier than `v0.17.0`: ```ts // webpack.config.js module.exports = { @@ -104,6 +116,18 @@ module.exports = {
Rspack
+From version `v0.17.0+` you need to use `default` export: +```ts +// rspack.config.js +module.exports = { + /* ... */ + plugins: [ + require('unplugin-auto-import/webpack').default({ /* options */ }), + ], +} +``` + +If you are using a version earlier than `v0.17.0`: ```ts // rspack.config.js module.exports = { @@ -126,6 +150,32 @@ module.exports = {
Vue CLI
+From version `v0.17.0+` you need to use `default` export: +```ts +// vue.config.js +module.exports = { + /* ... */ + plugins: [ + require('unplugin-auto-import/webpack').default({ /* options */ }), + ], +} +``` + +or you can rename the Vue configuration file to `vue.config.mjs` and use static import syntax (you should use latest `@vue/cli-service ^5.0.8`): +```ts +// vue.config.mjs +import AutoImport from 'unplugin-auto-import/webpack' + +export default { + configureWebpack: { + plugins: [ + AutoImport({ /* options */ }), + ], + }, +} +``` + +If you are using a version earlier than `v0.17.0`: ```ts // vue.config.js module.exports = { @@ -143,14 +193,34 @@ module.exports = { Quasar
```ts -// quasar.conf.js [Vite] +// vite.config.js [Vite] +import { defineConfig } from 'vite' +import AutoImport from 'unplugin-auto-import/vite' + +export default defineConfig({ + plugins: [ + AutoImport({ /* options */ }) + ] +}) +``` + +From version `v0.17.0+` you need to use `default` export: +```ts +// quasar.conf.js [Webpack] +const AutoImportPlugin = require('unplugin-auto-import/webpack').default + module.exports = { - vitePlugins: [ - ['unplugin-auto-import/vite', { /* options */ }], - ], + build: { + chainWebpack(chain) { + chain.plugin('unplugin-auto-import').use( + AutoImportPlugin({ /* options */ }), + ) + }, + }, } ``` +If you are using a version earlier than `v0.17.0`: ```ts // quasar.conf.js [Webpack] const AutoImportPlugin = require('unplugin-auto-import/webpack') @@ -172,6 +242,22 @@ module.exports = {
esbuild
+From version `v0.17.0+` you need to use `default` export: +```ts +// esbuild.config.js +import { build } from 'esbuild' + +build({ + /* ... */ + plugins: [ + require('unplugin-auto-import/esbuild').default({ + /* options */ + }), + ], +}) +``` + +If you are using a version earlier than `v0.17.0`: ```ts // esbuild.config.js import { build } from 'esbuild' From e849a8f37d24c06a7a26aad8d8548a2ec9cde916 Mon Sep 17 00:00:00 2001 From: userquin Date: Sat, 2 Dec 2023 16:15:03 +0100 Subject: [PATCH 2/4] chore: update esbuild entry --- README.md | 19 ++----------------- 1 file changed, 2 insertions(+), 17 deletions(-) diff --git a/README.md b/README.md index 4909e6d..1f2b45c 100644 --- a/README.md +++ b/README.md @@ -242,30 +242,15 @@ module.exports = {
esbuild
-From version `v0.17.0+` you need to use `default` export: -```ts -// esbuild.config.js -import { build } from 'esbuild' - -build({ - /* ... */ - plugins: [ - require('unplugin-auto-import/esbuild').default({ - /* options */ - }), - ], -}) -``` - -If you are using a version earlier than `v0.17.0`: ```ts // esbuild.config.js import { build } from 'esbuild' +import AutoImport from 'unplugin-auto-import/esbuild' build({ /* ... */ plugins: [ - require('unplugin-auto-import/esbuild')({ + AutoImport({ /* options */ }), ], From 479d42e0fc91c7e7c6d0b5265f825aa7e0cbe0c2 Mon Sep 17 00:00:00 2001 From: userquin Date: Sat, 2 Dec 2023 16:33:57 +0100 Subject: [PATCH 3/4] chore: update rspack entry --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 1f2b45c..d9c340e 100644 --- a/README.md +++ b/README.md @@ -122,7 +122,7 @@ From version `v0.17.0+` you need to use `default` export: module.exports = { /* ... */ plugins: [ - require('unplugin-auto-import/webpack').default({ /* options */ }), + require('unplugin-auto-import/rspack').default({ /* options */ }), ], } ``` From 69219ce761180b72dc22a4e2de20adc84c610d09 Mon Sep 17 00:00:00 2001 From: userquin Date: Sun, 3 Dec 2023 15:04:06 +0100 Subject: [PATCH 4/4] chore: include only code snippets for the latest version --- README.md | 56 +------------------------------------------------------ 1 file changed, 1 insertion(+), 55 deletions(-) diff --git a/README.md b/README.md index d9c340e..bf9a050 100644 --- a/README.md +++ b/README.md @@ -89,7 +89,6 @@ export default {
Webpack
-From version `v0.17.0+` you need to use `default` export: ```ts // webpack.config.js module.exports = { @@ -100,23 +99,11 @@ module.exports = { } ``` -If you are using a version earlier than `v0.17.0`: -```ts -// webpack.config.js -module.exports = { - /* ... */ - plugins: [ - require('unplugin-auto-import/webpack')({ /* options */ }), - ], -} -``` -
Rspack
-From version `v0.17.0+` you need to use `default` export: ```ts // rspack.config.js module.exports = { @@ -127,17 +114,6 @@ module.exports = { } ``` -If you are using a version earlier than `v0.17.0`: -```ts -// rspack.config.js -module.exports = { - /* ... */ - plugins: [ - require('unplugin-auto-import/rspack')({ /* options */ }), - ], -} -``` -
@@ -150,7 +126,6 @@ module.exports = {
Vue CLI
-From version `v0.17.0+` you need to use `default` export: ```ts // vue.config.js module.exports = { @@ -161,7 +136,7 @@ module.exports = { } ``` -or you can rename the Vue configuration file to `vue.config.mjs` and use static import syntax (you should use latest `@vue/cli-service ^5.0.8`): +You can also rename the Vue configuration file to `vue.config.mjs` and use static import syntax (you should use latest `@vue/cli-service ^5.0.8`): ```ts // vue.config.mjs import AutoImport from 'unplugin-auto-import/webpack' @@ -175,18 +150,6 @@ export default { } ``` -If you are using a version earlier than `v0.17.0`: -```ts -// vue.config.js -module.exports = { - configureWebpack: { - plugins: [ - require('unplugin-auto-import/webpack')({ /* options */ }), - ], - }, -} -``` -
@@ -204,7 +167,6 @@ export default defineConfig({ }) ``` -From version `v0.17.0+` you need to use `default` export: ```ts // quasar.conf.js [Webpack] const AutoImportPlugin = require('unplugin-auto-import/webpack').default @@ -220,22 +182,6 @@ module.exports = { } ``` -If you are using a version earlier than `v0.17.0`: -```ts -// quasar.conf.js [Webpack] -const AutoImportPlugin = require('unplugin-auto-import/webpack') - -module.exports = { - build: { - chainWebpack(chain) { - chain.plugin('unplugin-auto-import').use( - AutoImportPlugin({ /* options */ }), - ) - }, - }, -} -``` -