feat(compiler): build() 支持自定义小程序文件扩展名(fileTypes 选项)#248
Merged
Conversation
Contributor
Author
|
补一个 |
dos1in
reviewed
Jun 15, 2026
9beaee3 to
8236cc1
Compare
通过 build() 的 options.fileTypes 在内置 wx/dd 系之上追加自定义模板/样式/视图脚本扩展名(如 .qdml/.qdss/.qds 及内联 <qds> 标签),编译时与对应内置类型等价处理。 - env.js:compilerOptions 单例 + 归一化(补点/小写/去重,拒绝路径分隔符与选择器元字符)+ 4 个 getter;storeInfo 按本次重建防跨构建串用,resetStoreInfo 还原 worker 上下文 - 消费点改读 getter:模板/样式查找、视图脚本文件扫描与路径剥除、内联标签取并集(修「无 wxs 才回退 dds」漏编译)、npm 白名单对齐补 .ddml/.ddss/.sass、compatibility 动态豁免视图脚本标签 - loadWxsModule 改用 wxsFilePathMap 判定,不再依赖 _wxs_ 路径片段(自定义扩展名/非 wxs 目录的 .wxs 不再漏编译) 测试:custom-file-types.spec(单元+集成+元字符/泄漏反证)、npm-view-script-custom-loading.spec;vitest 258 passed。 Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
button-style-specificity.spec 在单引号串里断言字面 template-literal 子串,
触发 oxlint no-template-curly-in-string。改用转义的模板字符串
`\`dd-button--\${type}\``(值不变、不插值,规则不再误报),无需 disable 注释。
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
8236cc1 to
18ee953
Compare
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.
做了什么
给
build()增加options.fileTypes,允许在内置wx*(.wxml/.wxss/.wxs)、dd*(.ddml/.ddss) 之上追加自定义文件扩展名,使其等价编译。通用能力,无品牌耦合。[a-z0-9_-],不得占用内置或.js/.ts/.json)。fileTypes行为不变;内置wx/dd永远保留、仅追加。:if/:for/:key等)按后缀匹配,自定义前缀(如xx:if)也能正常编译。顺带修复(与本改动共用 getter,故一并提交)
transTagWxs原「无<wxs>才回退<dds>」会漏编同时含两种标签的文件。.ddml/.ddss/.sass、且含编译器不支持的.styl。loadWxsModule旧的_wxs_路径片段判定只对 scoped 包放在wxs/目录的.wxs生效,改用wxsFilePathMap定位。测试
新增
custom-file-types.spec+npm-view-script-custom-loading.spec;全量vitest260 passed,oxlint 干净。