From d5458b85adf63daa4b7854205577515db808c924 Mon Sep 17 00:00:00 2001 From: nuintun Date: Wed, 8 May 2024 15:05:56 +0800 Subject: [PATCH] chore: Update tools --- tools/rollup.base.js | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/tools/rollup.base.js b/tools/rollup.base.js index 5d2b19b..5b6db66 100644 --- a/tools/rollup.base.js +++ b/tools/rollup.base.js @@ -2,9 +2,9 @@ * @module rollup.base */ -import { createRequire } from 'module'; import replace from '@rollup/plugin-replace'; import treeShake from './plugins/tree-shake.js'; +import { createRequire, isBuiltin } from 'module'; import typescript from '@rollup/plugin-typescript'; const pkg = createRequire(import.meta.url)('../package.json'); @@ -58,6 +58,17 @@ export default function rollup(esnext) { warn(error); } }, - external: ['tslib', 'react', 'react/jsx-runtime', 'react/jsx-dev-runtime'] + external(source) { + const { dependencies = {}, peerDependencies = {} } = pkg; + + return ( + // Built-in modules + isBuiltin(source) || + // Dependencies modules + Reflect.has(dependencies, source) || + // Peer dependencies modules + Reflect.has(peerDependencies, source) + ); + } }; }