developit / developit/microbundle

Granular compress option

未關閉
#1,031 3 則留言 1 個 reaction 已指派 0 人 在 GitHub 檢視
Feature Request
主要語言
JavaScript
星號
8.1k
分支
358
PR 合併指標
30 天內沒有已合併 PR

描述

I think it'd be great to be able to do this:

package.json
```json5
{
"name": "foo", // your package name
"type": "module",
"source": "src/foo.js", // your source code
"exports": {
"require": "./dist/foo.cjs", // used for require() in Node 12+
"default": "./dist/foo.modern.js" // where to generate the modern bundle (see below)
},
"main": "./dist/foo.cjs", // where to generate the CommonJS bundle
"module": "./dist/foo.module.min.js", // where to generate the ESM bundle
// note the 'min' here 👇👇👇
"unpkg": "./dist/foo.umd.min.js", // where to generate the UMD bundle (also aliased as "umd:main")
"scripts": {
"build": "microbundle", // compiles "source" to "main"/"module"/"unpkg"
"dev": "microbundle watch" // re-build when source files change
}
}
```

Then expand the `--compress` option to allow a regex. So, if you run `--compress min` it's saying "Compress the outputs that contain the string `min`". In the above case, it'd only minify the `module` and `unpkg` outputs.

This'd be useful to allow node users to use unminified code but browser users to use minified etc. It could be made to be non-breaking by making `--compress true` and `--compress false` special cases to enable/disable all.

貢獻指南

這個儲存庫沒有索引到貢獻指南

研究方向

Start by locating the `--compress` option and the code that maps package.json outputs such as `main`, `module`, and `unpkg` to generated bundles. Check how the current true/false compression behavior is handled, then verify that a regex-like value such as `min` only compresses matching output paths while the existing boolean cases still work.

由索引模型根據 Issue 內容生成。

評估

技術堆疊
javascript
領域
build-system
Issue 類型
功能
難度
3/5
預估耗時
1-2 天
活躍度
停滯
描述清晰度
基本清楚
新手友好度
35/100

把新 issue 寄到你的電子郵件信箱

精選適合新手參與的 GitHub issue 摘要。