chore(build): 优化 vsix 打包#534
Closed
inaku-Gyan wants to merge 3 commits intogithub0null:devfrom
Closed
Conversation
Author
|
另外,不知道 |
Owner
|
这是一个危险改动。我不知道你是否完全测试过插件的所有功能(不是在插件调试模式,而是通过vsix安装的全新安装状态) 我知道这个项目使用的包和工具很多都过时了,因为这个项目始于19年。我的原则是 如果它现在能正常工作,那么我不会动它,除非已经到了不改不能用的地步。 为什么有些包是分离的没有打成一个 bundle.js,这是刻意为之,有些包含有浏览器的兼容部分,使用 webpack 打包会引入一些 nodejs 中没有的东西,这会导致错误,而另一些则是其他原因。 当然我没有深究这些问题到底是我的做法有问题,还是包本身的问题,因为问题已经得到解决。 另外,我不知道你是否使用了 AI,该提交完全移除了 dependencies,然而有些包是开发工具有些则是项目依赖,这显然是不对的。 我倾向于拒绝该提交,这个插件有多个平台的支持,这个修改会导致大量的测试,这个项目没有测试用例因此所有的测试需要手动完成。为5MB的尺寸优化和一些Warnings消除不值得。 |
Author
|
感谢你的解释。确实应当以兼容性为重,而本项目实在难以测试。我支持你的决定,我会关闭这个 PR。 补充说明一下: |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
执行
vsce package时报警告:两条 webpack 弃用警告:
问题
dist/extension.js,但因为package.json的dependencies字段非空,vsce 会再把所有生产依赖的node_modules树原样复制进 vsix。externals有两处 bug:iconv_lite/jsonc_parser用了下划线 key,与实际 import 字符串iconv-lite/jsonc-parser不匹配,规则永远不命中。这两个包仍然被 bundle,但同时又随dependencies被多复制了一份。unzipper出现在externals中,但项目根本没有这个依赖(src/ResInstaller.ts中只是恰巧有同名局部变量),是死规则。ts-loader@6.2.2:--trace-deprecation显示堆栈指向ts-loader/dist/after-compile.js。该版本针对 webpack 4 设计,在 webpack 5 下使用了已废弃的Compilation.modules数组与Module.errorsAPI。改动
1.
webpack.config.jsexternals只保留vscode,其余依赖由 webpack 内联打包。devtool按模式切换:production 关闭 source map,development 仍生成。iconv_lite/jsonc_parser与死规则unzipper。2.
package.jsondependencies移入devDependencies(这些纯 JS 包均已被 webpack bundle,运行时无需在node_modules中独立存在)。dependencies留空,使 vsce 默认行为也不会再复制node_modules。ts-loader: ^6.2.1→^9.5.1。ts-loader 9.x 原生支持 webpack 5。3.
.vscodeignore.git改为**/.git:原规则只匹配根目录。lib/node-utility/.git被包进 vsix。node_modulesDEP_WEBPACK警告兼容性
dependencies都是纯 JS(无 native module),bundle 后行为一致。tsconfig.json配置兼容。