developit / developit/microbundle

Babel targets configuration for browser and node builds

オープン
#982 コメント 4 件 リアクション 0 件 担当者 0 名 GitHub で見る
主要言語
JavaScript
スター
8.1k
フォーク
358
PR マージ指標
30日以内にマージされた PR はありません

説明

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.

コントリビューションガイド

このリポジトリのコントリビューションガイドは索引されていません

評価

この issue はまだ評価されていません。

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。