From f6fc40bc518d175d18d556b8c22e3c924ed25bbd Mon Sep 17 00:00:00 2001 From: Ryan Lamb <4955475+kinyoklion@users.noreply.github.com> Date: Fri, 11 Oct 2024 09:08:25 -0700 Subject: [PATCH] fix: Do not mangle _meta. (#622) --- packages/sdk/browser/rollup.config.js | 28 +++++++++++++-------------- 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/packages/sdk/browser/rollup.config.js b/packages/sdk/browser/rollup.config.js index 4ac931184..550533ccf 100644 --- a/packages/sdk/browser/rollup.config.js +++ b/packages/sdk/browser/rollup.config.js @@ -21,6 +21,18 @@ const getSharedConfig = (format, file) => ({ }, }); +const terserOpts = { + mangle: { + properties: { + // Mangle class properties which start with an underscore. + regex: /^_/, + // Do not mangle '_meta', because this is part of our JSON + // data model. + reserved: ['_meta'] + }, + } +}; + export default [ { ...getSharedConfig('es', 'dist/index.es.js'), @@ -33,13 +45,7 @@ export default [ esmExternals: true, }), resolve(), - terser({ - mangle: { - properties: { - regex: /^_/, - }, - }, - }), + terser(terserOpts), json(), // The 'sourcemap' option allows using the minified size, not the size before minification. visualizer({ sourcemap: true }), @@ -51,13 +57,7 @@ export default [ typescript(), common(), resolve(), - terser({ - mangle: { - properties: { - regex: /^_/, - }, - }, - }), + terser(terserOpts), json(), ], },