developit / developit/microbundle

Babel targets configuration for browser and node builds

Abierto
#982 4 comentarios 0 reacciones 0 asignados Ver en GitHub
Lenguaje dominante
JavaScript
Estrellas
8.1k
Forks
358
Métricas de merge de PR
Sin PR fusionados en 30 d

Descripción

For a while I have been using the following `babel` preset for production bundles:
```
...
"presets": [
[
"@babel/preset-env",
{
"targets": [
"defaults",
"maintained node versions"
]
}
]
],
...
```

This configuration seems to be incompatible with `microbundle` as it generates errors such as `unknown Statement of type "ForOfStatement"` when the source contains `for (... of ...)` statements. Using `"presets": ["@babel/preset-env"]` without specifying targets works. However, I am concerned about the compatibility achieved by such "default" builds.

What is the proper way to use `microbundle` to build for both the browser and for node? What's the correct babel configuration to use? I am fine with having one build for the browser and another for Node, but how should one define `package.json` exports in that case?

I do realize `microbundle` probably does the correct thing by default, but I am a bit skeptical given the existence of the `--target` CLI flag, for which little documentation exists.

Guía de contribución

No hay ninguna guía de contribución indexada para este repositorio

Evaluación

Este issue todavía no se ha evaluado.

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.