developit / developit/microbundle

Support Node conditional exports

オープン
#594 コメント 9 件 リアクション 0 件 担当者 1 名 @developit が担当を希望しています GitHub で見る
enhancement :rocket: important
主要言語
JavaScript
スター
8.1k
フォーク
358
PR マージ指標
30日以内にマージされた PR はありません

説明

In node 13, there is a new option available: [`exports`](https://nodejs.org/api/esm.html#esm_conditional_exports).

As this will be the new standard for defining packages available for node/browsers/etc, it could be nice to use it instead/addition of the `module`, `unpkg` etc. fields in the current package.json. Webpack also plans to support it in the v5: https://github.com/webpack/webpack/issues/9509

Current API:

```jsonc
{
"source": "src/foo.js", // Your source file (same as 1st arg to microbundle)
"main": "dist/foo.js", // output path for CommonJS/Node
"module": "dist/foo.module.js", // output path for JS Modules
"unpkg": "dist/foo.umd.js", // optional, for unpkg.com
"scripts": {
"build": "microbundle", // uses "source" and "main" as input and output paths by default
"dev": "microbundle watch"
}
}
```

New API:
```jsonc
{
"source": "src/foo.js", // Your source file (same as 1st arg to microbundle)
"main": "dist/foo.js", // output path for CommonJS/Node
"exports": {
"import": "dist/foo.module.js", // output path for JS Modules
"browser": "dist/foo.umd.js", // optional, for unpkg.com
},
"scripts": {
"build": "microbundle", // uses "source" and "main" as input and output paths by default
"dev": "microbundle watch"
}
}
```

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

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

評価

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

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

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