Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Taro 4.0.7 生产模式无法渲染 dangerouslySetInnerHTML 中的内容 #16892

Open
alexlees opened this issue Nov 20, 2024 · 5 comments
Open

Comments

@alexlees
Copy link
Contributor

相关平台

字节跳动小程序

复现仓库

https://github.com/alexlees/demo-bug-taro4.git
小程序基础库: 3.44.0.2
使用框架: React

复现步骤

<View dangerouslySetInnerHTML={{__html: '123'}} />
npm run build:tt

期望结果

image

正常渲染 dangerouslySetInnerHTML 中的内容
img_v3_02gq_bdf3f6c3-eebd-4fdf-95e0-337926fc917g

实际结果

未渲染 dangerouslySetInnerHTML 内容
img_v3_02gq_1687ff94-35a9-43a1-bd60-8ca251cbc33g

环境信息

👽 Taro v4.0.7


  Taro CLI 4.0.7 environment info:
    System:
      OS: macOS 12.3
      Shell: 5.8 - /bin/zsh
    Binaries:
      Node: 18.20.5 - ~/.nvm/versions/node/v18.20.5/bin/node
      Yarn: 1.22.18 - ~/.yarn/bin/yarn
      npm: 10.8.2 - ~/.nvm/versions/node/v18.20.5/bin/npm
    npmPackages:
      @tarojs/cli: 4.0.7 => 4.0.7 
      @tarojs/components: 4.0.7 => 4.0.7 
      @tarojs/helper: 4.0.7 => 4.0.7 
      @tarojs/plugin-framework-react: 4.0.7 => 4.0.7 
      @tarojs/plugin-platform-alipay: 4.0.7 => 4.0.7 
      @tarojs/plugin-platform-h5: 4.0.7 => 4.0.7 
      @tarojs/plugin-platform-harmony-hybrid: 4.0.7 => 4.0.7 
      @tarojs/plugin-platform-jd: 4.0.7 => 4.0.7 
      @tarojs/plugin-platform-qq: 4.0.7 => 4.0.7 
      @tarojs/plugin-platform-swan: 4.0.7 => 4.0.7 
      @tarojs/plugin-platform-tt: 4.0.7 => 4.0.7 
      @tarojs/plugin-platform-weapp: 4.0.7 => 4.0.7 
      @tarojs/react: 4.0.7 => 4.0.7 
      @tarojs/runtime: 4.0.7 => 4.0.7 
      @tarojs/shared: 4.0.7 => 4.0.7 
      @tarojs/taro: 4.0.7 => 4.0.7 
      @tarojs/taro-loader: 4.0.7 => 4.0.7 
      @tarojs/webpack5-runner: 4.0.7 => 4.0.7 
      babel-preset-taro: 4.0.7 => 4.0.7 
      eslint-config-taro: 4.0.7 => 4.0.7 
      react: ^18.0.0 => 18.3.1 

补充信息

与 Prebundle 有关,生产环境开启 Prebundle 后能正常。

@TheKonka
Copy link
Member

可以在编译配置里面 临时加下这个 alias
@tarojs/runtime': require.resolve('@tarojs/runtime')

@alexlees
Copy link
Contributor Author

可以在编译配置里面 临时加下这个 alias @tarojs/runtime': require.resolve('@tarojs/runtime')

没毛病,是已知问题吗?准备啥时候发新版本修复

@alexlees
Copy link
Contributor Author

可以在编译配置里面 临时加下这个 alias @tarojs/runtime': require.resolve('@tarojs/runtime')

@TheKonka 发现加完这个之后,所有的npm包都会依赖上 @tarojs/runtime 有其他修复方式吗。

img_v3_02gq_d84e4d7c-3113-4858-9dab-526e0b449e3g

@alexlees
Copy link
Contributor Author

image
查找了相关上下文,使用 webpackChain 去注入 alias 可以临时解决这个问题

This was referenced Nov 23, 2024
@Yang03
Copy link
Contributor

Yang03 commented Dec 25, 2024

image 查找了相关上下文,使用 webpackChain 去注入 alias 可以临时解决这个问题

@tarojs/shared 这个必要吗

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants