From d7246ba168155866c0669721976c2aa65c5a9036 Mon Sep 17 00:00:00 2001 From: liaoxuezhi <2698393+2betop@users.noreply.github.com> Date: Wed, 15 Jan 2025 19:41:15 +0800 Subject: [PATCH] chore: Disable tree shake for modules under --- packages/amis-core/rollup.config.js | 17 ++++++++++++++++- packages/amis/rollup.config.js | 18 +++++++++++++++++- 2 files changed, 33 insertions(+), 2 deletions(-) diff --git a/packages/amis-core/rollup.config.js b/packages/amis-core/rollup.config.js index f21c71f8bc2..216fb973588 100644 --- a/packages/amis-core/rollup.config.js +++ b/packages/amis-core/rollup.config.js @@ -206,6 +206,21 @@ function getPlugins(format = 'esm') { ${name} v${version} Copyright 2018<%= moment().format('YYYY') > 2018 ? '-' + moment().format('YYYY') : null %> ${author} ` - }) + }), + { + name: 'disable-treeshake', + transform(code, id) { + if (/\/src\/renderers\//.test(id)) { + // Disable tree shake for modules under `src/renderers` + return { + code, + map: null, + moduleSideEffects: 'no-treeshake' + }; + } + + return null; + } + } ].filter(item => item); } diff --git a/packages/amis/rollup.config.js b/packages/amis/rollup.config.js index 197c5b2f43b..adeafa6f9c1 100644 --- a/packages/amis/rollup.config.js +++ b/packages/amis/rollup.config.js @@ -241,6 +241,22 @@ function getPlugins(format = 'esm') { build time: <%=moment().format('YYYY-MM-DD')%> Copyright 2018<%= moment().format('YYYY') > 2018 ? '-' + moment().format('YYYY') : null %> ${author} ` - }) + }), + + { + name: 'disable-treeshake', + transform(code, id) { + if (/\/src\/renderers\//.test(id)) { + // Disable tree shake for modules under `src/renderers` + return { + code, + map: null, + moduleSideEffects: 'no-treeshake' + }; + } + + return null; + } + } ].filter(item => item); }