Skip to content

Commit

Permalink
Reduce bundle size
Browse files Browse the repository at this point in the history
By marking all code as side-effects free, we can reduce the bundle size
by ~20%.
  • Loading branch information
remcohaszing committed Jun 7, 2024
1 parent 6f86e70 commit 1997880
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion build.js
Original file line number Diff line number Diff line change
Expand Up @@ -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')",
Expand Down

0 comments on commit 1997880

Please sign in to comment.