Improve tree-shaking
Nadie ha tomado este issue todavía.
Evaluación
- Dificultad
- 4/5
- Tiempo estimado
- 3-5 días
- Aptitud para principiantes
- 55/100
- Tipo de issue
- Error
- Claridad
- Bien especificado
- Estado de actividad
- Activo
- Stack tecnológico
- javascript, node.js, rollup
- Área
- build-system, performance
Línea de trabajo
Read the package build configuration and inspect how it produces dist/d3-shape.mjs; the issue identifies Rollup's output.preserveModules as a possible direction. Run the provided esbuild reproduction to record bundle sizes, then check whether publishing per-module files restores the 3.2.0 behavior while keeping the dist/ layout and bundled CDN builds.
Escrito por el modelo de indexación a partir del texto del issue.
Descripción
Since 3.2.1, the package's default entry points to one bundled file, dist/d3-shape.mjs, instead of separate source files. sideEffects: false used to let bundlers drop unused files. With one file, importing anything keeps that module, and bundlers then have to prove each top-level statement is safe to remove.
Most of them can't be removed, so importing one curve now pulls in nearly all the others.
Reproduction
npm i [email protected]
echo "export { curveLinear } from 'd3-shape'" \
| npx [email protected] --bundle --minify --format=esm | gzip -c | wc -c
| Import | 3.2.0 (gzip) | 3.2.1 (gzip) |
|---|---|---|
curveLinear |
265 B | 2,509 B |
arc |
2,478 B | 4,871 B |
Other toolchains are affected too, though less.
Cause
The file has top-level statements that bundlers treat as side effects:
- 17 prototype assignments, such as
Linear.prototype = { … } - calls such as
var catmullRom = (function custom(alpha) { … })(0.5)andconst sqrt3 = sqrt(3)
The prototype assignments matter most. Adding /*#__PURE__*/ to all 18 top-level calls only reduced the curveLinear case to about 2.3 KB, and those annotations can't be applied to assignments.
Suggested fix
Publish one file per module again, for example with Rollup's output.preserveModules, while keeping the dist/ layout and the bundled CDN builds. This restores the behavior of 3.2.0 without changing the source.
The same build change shipped in d3-array 3.2.5 and d3-time 3.1.1, which grew in the same way under esbuild: ticks + tickIncrement from 420 B to about 1.3 KB, and timeDay + utcDay from 597 B to about 2.7 KB. I haven't looked at the cause in those packages.
- Lenguaje dominante
- JavaScript
- Estrellas
- 2.5k
- Forks
- 307
- Merge medio
- 4 h 16 min
- PR fusionados (30 d)
- 1
Preparar el entorno
Este proyecto no incluye contenedor de desarrollo, Dockerfile ni guía de contribución, así que la configuración corre por tu cuenta: empieza por su README y consulta nuestra guía para la primera contribución para los pasos generales.
Primeros pasos
- Lee el issue completo y luego la guía de contribución del proyecto.
- Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
- Haz un fork del repositorio y trabaja en una rama.
- Abre un pull request que haga referencia al número del issue.
Más de d3/d3-shape
-
option for arc's curve precisionAbierto
Dificultad 3/5 1-2 días Aptitud para principiantes 38/100
-
Dificultad 5/5 Más de una semana Aptitud para principiantes 35/100
-
startPadAngle and endPadAngleAbierto
Dificultad 5/5 Más de una semana Aptitud para principiantes 25/100
-
Dynamic smoothing interpolationAbierto
Dificultad 5/5 Más de una semana Aptitud para principiantes 25/100
-
Dificultad 5/5 Más de una semana Aptitud para principiantes 25/100
Todos los issues de d3/d3-shape
Issues similares
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 78/100
Los mantenedores suelen responder en 1 día
-
0. Needs triage bug feature: api
Dificultad 2/5 1-3 horas Aptitud para principiantes 78/100
Los mantenedores suelen responder en 1 día
-
agent-os ai bug good first issue help wanted
Dificultad 1/5 1-3 horas Aptitud para principiantes 68/100
Los mantenedores suelen responder en 1 día
-
area: documentation good first issue package: rule-data status: accepting prs
Dificultad 2/5 1-3 horas Aptitud para principiantes 72/100
Los mantenedores suelen responder en 1 día
-
status: needs triage
Dificultad 2/5 1-3 horas Aptitud para principiantes 85/100
mastra-ai/mastra#30109 · 2 comentarios ·
Los mantenedores suelen responder en 1 día