Having nameCache controls
还没有人认领这个 Issue。
评估
- 难度
- 4/5
- 预计耗时
- 3-5 天
- 新手友好度
- 35/100
- Issue 类型
- 功能
- 描述清晰度
- 基本清楚
- 活跃度
- 停滞
- 技术栈
- javascript, webpack
- 领域
- build-system, tooling
调研方向
首先跟踪插件现有的选项处理方式及其对 Terser 的调用;issue 没有指定具体的文件或测试。使用所描述的多 bundle Angular 场景,验证是否可以提供并更新持久化的 nameCache,以及单独的构建是否保留兼容的压缩名称。
由索引模型根据 Issue 内容生成。
描述
- Operating System: Windows
- Node Version: 13.5.0
- NPM Version: 6.13.4
- webpack Version: 4.41.2
- terser-webpack-plugin Version: 3.0.2
Feature Proposal
What about adding nameCache option? I haven't used it before, but as documentation suggests we should be able to tell terser to use js object (or it would be more correct to call it dictionary) to map names (as I guess variables, classes, functions) to predefined, new, minified names instead of just renaming them to alphabetically smallest, nonempty, available string.
To say it simply, I'm asking to bring this somehow possible in webpack plugin too:
var cacheFileName = "/tmp/cache.json";
var options = {
mangle: {
properties: true,
},
nameCache: JSON.parse(fs.readFileSync(cacheFileName, "utf8"))
};
fs.writeFileSync("part1.js", Terser.minify({
"file1.js": fs.readFileSync("file1.js", "utf8"),
"file2.js": fs.readFileSync("file2.js", "utf8")
}, options).code, "utf8");
fs.writeFileSync("part2.js", Terser.minify({
"file3.js": fs.readFileSync("file3.js", "utf8"),
"file4.js": fs.readFileSync("file4.js", "utf8")
}, options).code, "utf8");
fs.writeFileSync(cacheFileName, JSON.stringify(options.nameCache), "utf8");
And this code in my opinion also saves new names cache to same file too. I think this is impossible now in terser webpack plugin.
Feature Request: Add ability/option to bind json file as name cache.
Feature Use Case
<! -- problem -->
Easiest use case would be, I need to build application (currently in angular) which has more than two files bundled (let's assume 3). First and second files both have dependency on third.
Now if I build only first file, after minification first minified file will have for example console.log(thirdModule.thirdModuleVariable) transformed into console.log(thirdModule.a).
But if I only build second file or if I build whole project thirdModule's thirdModuleVariable may become b.
</!-- problem -->
What I want in the end is that in angular application I have appModule => [firstLazyModule, secondLazyModule, thirdLazyModule]. Now I will build whole app, then I will comment out other two modules and build only appModule => [firstLazyModule] (because building all three of them takes too long and I have only changed code in firstLazyModule, after building app with only one module, I will take generated module bundle and I will replace corresponding module file in the firstly generated directory with this new module bundle file.
This whole thing works if I don't use terser plugin, but doesn't work with terser because of the problem I have provided. If I'll have nameCache file in the project, each time I build app it will generate and use in next builds same minified variable names and replacing modules will still work.
I hope we can work this out. Thank you in advance.
- 主要语言
- JavaScript
- 星标
- 2k
- 派生
- 165
- 平均合并
- 2 天 2 小时
- 30 天内合并 PR
- 5
环境准备
- 没有 Dockerfile 或 Docker Compose 文件
- 没有 Pull Request 模板
- 阅读贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
webpack/minimizer-webpack-plugin 的其他 Issue
-
难度 4/5 3-5 天 新手友好度 42/100
webpack/minimizer-webpack-plugin#684 · 1 条评论 ·
-
难度 4/5 3-5 天 新手友好度 25/100
webpack/minimizer-webpack-plugin#389 · 15 条评论 · 3 个 reaction ·
-
enhancement
难度 4/5 3-5 天 新手友好度 25/100
webpack/minimizer-webpack-plugin#175 · 6 条评论 ·
查看 webpack/minimizer-webpack-plugin 的全部 Issue
相似的 Issue
-
Mend: dependency security vulnerability
难度 2/5 1-3 小时 新手友好度 65/100
ManageIQ/manageiq-ui-service#2259 ·
维护者通常 1 天内回复
-
难度 2/5 1-3 小时 新手友好度 73/100
electerious/Ackee#411 ·
-
难度 2/5 1-3 小时 新手友好度 72/100
维护者通常 1 天内回复
-
难度 2/5 1-3 小时 新手友好度 64/100
babalae/bettergi-scripts-list#3905 · 1 条评论 ·
维护者通常 1 天内回复
-
[Bug] "Configure Colota" opens Colota with "Invalid configuration: No configuration data in URL"未关闭
难度 1/5 1-3 小时 新手友好度 87/100
dedicatedcode/reitti#1445 ·
维护者通常 1 天内回复