Conversation
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.
问题
renderjs 块的编译走独立的 esbuild 调用(
bundle: true),没有继承 vite 的resolve.alias。因此当 renderjs 块引用的第三方依赖内部含
import('node:module')(典型场景:wasm 包的 Emscripten glue),而项目通过
resolve.alias把它指向浏览器 shim 时,编译直接失败:改动
transformRenderjs增加resolvedConfig形参,调用处传入;resolvedConfig.resolve.alias提取 string 型find组成 esbuildalias并透传,按resolvedConfig用 WeakMap 缓存(configResolved之后不再变化);<key>/前缀替换,故仅透传 string 型find。验证
@dcloudio/*@3.0.0-5000720260410001):改动前 App 平台构建报Could not resolve "node:module",改动后build:app通过,产物app-renderjs.js中node:module零残留;DEBUG=uni:app-renderjs可看到实际透传给 esbuild 的 alias 为vue-i18n,plugin-vue:export-helper,node:module;APP-PLUS条件编译),不能用于验证该改动。影响面
仅影响 renderjs 块的 esbuild 编译;alias 语义与 vite 侧对齐(RegExp 型
find保持不生效)。transformWxs结构相同、有同样隐患,本次未包含。