From fd9b5c1c018feb87e374cdf6671b7b8be14e775b Mon Sep 17 00:00:00 2001 From: rk_zhang <40221744+qmhc@users.noreply.github.com> Date: Wed, 30 Jun 2021 15:39:56 +0800 Subject: [PATCH] fix: cannot require @vue/compiler-sfc in monorepo fix #14 --- example/node_modules/@vue/compiler-sfc/package.json | 3 --- package.json | 2 +- src/index.ts | 2 +- 3 files changed, 2 insertions(+), 5 deletions(-) delete mode 100644 example/node_modules/@vue/compiler-sfc/package.json diff --git a/example/node_modules/@vue/compiler-sfc/package.json b/example/node_modules/@vue/compiler-sfc/package.json deleted file mode 100644 index 9b08d88..0000000 --- a/example/node_modules/@vue/compiler-sfc/package.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "main": "../../../../node_modules/@vue/compiler-sfc/dist/compiler-sfc.cjs" -} diff --git a/package.json b/package.json index 15a3a39..996b169 100644 --- a/package.json +++ b/package.json @@ -63,7 +63,7 @@ "url": "git+https://github.com/qmhc/vite-plugin-dts.git" }, "scripts": { - "build": "tsup src/index.ts --dts --format cjs,esm", + "build": "tsup src/index.ts --dts --format cjs,esm --external @vue/compiler-sfc", "changelog": "conventional-changelog -p angular -i CHANGELOG.md -s --commit-path .", "dev": "yarn run build -- --watch", "lint": "eslint --fix --ext .js,.ts src/**", diff --git a/src/index.ts b/src/index.ts index b5a17f6..53fd595 100644 --- a/src/index.ts +++ b/src/index.ts @@ -159,7 +159,7 @@ export default (options: PluginOptions = {}): Plugin => { const requireCompiler = () => { if (!compiler) { try { - compiler = require(resolve('node_modules/@vue/compiler-sfc')) + compiler = require('@vue/compiler-sfc') } catch (e) { throw new Error('@vue/compiler-sfc is not present in the dependency tree.\n') }