From 199788091d954793b8e84f2dac8ea37aa2e4b9f2 Mon Sep 17 00:00:00 2001 From: Remco Haszing Date: Fri, 7 Jun 2024 21:01:29 +0200 Subject: [PATCH] Reduce bundle size By marking all code as side-effects free, we can reduce the bundle size by ~20%. --- build.js | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/build.js b/build.js index edcb865..6762d57 100755 --- a/build.js +++ b/build.js @@ -61,7 +61,10 @@ await build({ onResolve({ filter: /\/umd\// }, ({ path, ...options }) => resolve(path.replace(/\/umd\//, '/esm/'), options) ) - onResolve({ filter: /.*/ }, () => ({ sideEffects: false })) + onResolve({ filter: /.*/, namespace: 'file' }, async ({ path, ...options }) => ({ + ...(await resolve(path, { ...options, namespace: 'side-effect-free' })), + sideEffects: false + })) onLoad({ filter: /yamlSchemaService\.js$/ }, async ({ path }) => ({ contents: (await readFile(path, 'utf8')).replaceAll( "require('ajv/dist/refs/json-schema-draft-07.json')",