Skip to content

fix: keep sideEffects in esm/package.json - #113

Merged
korvin89 merged 1 commit into
mainfrom
fix/esm-side-effects
Nov 2, 2026
Merged

korvin89 merged 1 commit into
mainfrom
fix/esm-side-effects

Conversation

@korvin89

@korvin89 korvin89 commented Nov 2, 2026

Copy link
Copy Markdown
Contributor

Since 2.22.1 (#108) the build generates esm/package.json with only version and type. esbuild reads sideEffects from the nearest package.json, so it no longer sees the root "sideEffects": false and keeps every icon module in esm/. Each one leaves its import * as React from 'react' in the bundle.

Only esbuild is affected. Vite 7 (Rollup) and webpack 5 already keep a single module.

Fix: repeat the root field in the generated file, as uikit does in its gulpfile:

JSON.stringify({version: pkg.version, type: 'module', sideEffects: pkg.sideEffects})

Numbers

esbuild 0.25.12, import {ArrowRotateLeft} from '@gravity-ui/icons', bundle, minify, format: 'esm', external: ['react']. Icon modules counted with bytesInOutput > 0 in metafile.outputs:

Icon modules in output Minified Brotli
2.23.0 (npm) 809 20.6 kB 1.04 kB
This branch 1 0.45 kB 0.26 kB

Verification

  • npm run build: esm/package.json is {"version":"2.23.0","type":"module","sideEffects":false}. Root package.json and the CJS output are byte-identical to a build of main. esm/package.json is the only file in esm/ that changes.
  • npm run lint, npm run typecheck: pass.
  • npm pack --dry-run: esm/package.json is included.
  • esbuild before/after as above. Before used the published 2.23.0 tarball, after used this branch's build.

@korvin89
korvin89 requested a review from amje as a code owner November 2, 2026 11:09
@gravity-ui

gravity-ui Bot commented Nov 2, 2026

Copy link
Copy Markdown
Contributor

Preview is ready.

@korvin89
korvin89 marked this pull request as draft November 2, 2026 11:12
@korvin89
korvin89 marked this pull request as ready for review November 2, 2026 11:13
@korvin89
korvin89 merged commit 6a79e56 into main Nov 2, 2026
3 checks passed
@korvin89
korvin89 deleted the fix/esm-side-effects branch November 2, 2026 12:01
@gravity-ui gravity-ui Bot mentioned this pull request Nov 2, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants