From 60a683a9eabd28d8895c9482430ee64e4bbe38e6 Mon Sep 17 00:00:00 2001 From: ZHAO Jinxiang Date: Fri, 11 Feb 2022 22:41:41 +0800 Subject: [PATCH] fix: esm support (#110) --- README.md | 12 ++++++++---- src/rollup.ts | 3 --- src/vite.ts | 3 --- src/webpack.ts | 3 --- 4 files changed, 8 insertions(+), 13 deletions(-) diff --git a/README.md b/README.md index 807549e..d389f8b 100644 --- a/README.md +++ b/README.md @@ -120,12 +120,13 @@ And then use [`vue-tsc`](https://github.com/johnsoncodehk/volar) to do the type ```ts // vue.config.js +const ScriptSetup = require('unplugin-vue2-script-setup/webpack').default module.exports = { parallel: false, // disable thread-loader, which is not compactible with this plugin configureWebpack: { plugins: [ - require('unplugin-vue2-script-setup/webpack')({ /* options */ }), + ScriptSetup({ /* options */ }), ], }, } @@ -142,11 +143,12 @@ npm i -D @vue/cli-plugin-typescript vue-tsc ``` ```ts +const ScriptSetup = require('unplugin-vue2-script-setup/webpack').default module.exports = { parallel: false, configureWebpack: { plugins: [ - require('unplugin-vue2-script-setup/webpack')({ /* options */ }), + ScriptSetup({ /* options */ }), ], }, chainWebpack(config) { @@ -175,10 +177,11 @@ And then use [`vue-tsc`](https://github.com/johnsoncodehk/volar) to do the type ```ts // webpack.config.js +const ScriptSetup = require('unplugin-vue2-script-setup/webpack').default module.exports = { /* ... */ plugins: [ - require('unplugin-vue2-script-setup/webpack')({ /* options */ }), + ScriptSetup({ /* options */ }), ] } ``` @@ -209,10 +212,11 @@ export default { ```ts // esbuild.config.js import { build } from 'esbuild' +import ScriptSetup from 'unplugin-vue2-script-setup/esbuild' build({ /* ... */ plugins: [ - require('unplugin-vue2-script-setup/esbuild')({ + ScriptSetup({ /* options */ }), ], diff --git a/src/rollup.ts b/src/rollup.ts index 62d3a71..ed6909c 100644 --- a/src/rollup.ts +++ b/src/rollup.ts @@ -1,6 +1,3 @@ import unplugin from '.' export default unplugin.rollup -module.exports = unplugin.rollup -module.exports.default = unplugin.rollup -Object.defineProperty(module.exports, '__esModule', { value: true }) diff --git a/src/vite.ts b/src/vite.ts index 996ecf0..589f4b9 100644 --- a/src/vite.ts +++ b/src/vite.ts @@ -1,6 +1,3 @@ import unplugin from '.' export default unplugin.vite -module.exports = unplugin.vite -module.exports.default = unplugin.vite -Object.defineProperty(module.exports, '__esModule', { value: true }) diff --git a/src/webpack.ts b/src/webpack.ts index a5bec64..83091ee 100644 --- a/src/webpack.ts +++ b/src/webpack.ts @@ -1,6 +1,3 @@ import unplugin from '.' export default unplugin.webpack -module.exports = unplugin.webpack -module.exports.default = unplugin.webpack -Object.defineProperty(module.exports, '__esModule', { value: true })