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 摘要。