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); }