Skip to content

4.0.3版本关闭prebundle,const document = xxx 会报错 #16196

@Ryan-CW-Code

Description

@Ryan-CW-Code

相关平台

微信小程序

小程序基础库: 3.4.10
使用框架: React

复现步骤

将prebundle置为false

期望结果

正常运行

实际结果

// Note: 小程序端 vite 打包成 commonjs,const document = xxx 会报错,所以把 document 改为 taroDocumentProvider
export const taroDocumentProvider: TaroDocument = process.env.TARO_PLATFORM === PLATFORM_TYPE.WEB ? env.document : (env.document = createDocument())

这行代码报错

环境信息

  Taro CLI 4.0.3 environment info:
    System:
      OS: Windows 11 10.0.22631
    Binaries:
      Node: 20.14.0 - C:\Program Files\nodejs\node.EXE
      npm: 10.7.0 - C:\Program Files\nodejs\npm.CMD
    npmPackages:
      @tarojs/cli: 4.0.3 => 4.0.3 
      @tarojs/components: 4.0.3 => 4.0.3 
      @tarojs/helper: 4.0.3 => 4.0.3 
      @tarojs/plugin-framework-react: 4.0.3 => 4.0.3 
      @tarojs/plugin-html: 4.0.3 => 4.0.3 
      @tarojs/plugin-platform-alipay: 4.0.3 => 4.0.3 
      @tarojs/plugin-platform-h5: 4.0.3 => 4.0.3 
      @tarojs/plugin-platform-jd: 4.0.3 => 4.0.3 
      @tarojs/plugin-platform-qq: 4.0.3 => 4.0.3 
      @tarojs/plugin-platform-swan: 4.0.3 => 4.0.3 
      @tarojs/plugin-platform-tt: 4.0.3 => 4.0.3 
      @tarojs/plugin-platform-weapp: 4.0.3 => 4.0.3 
      @tarojs/react: 4.0.3 => 4.0.3 
      @tarojs/runtime: 4.0.3 => 4.0.3 
      @tarojs/shared: 4.0.3 => 4.0.3 
      @tarojs/taro: 4.0.3 => 4.0.3 
      @tarojs/taro-loader: 4.0.3 => 4.0.3 
      @tarojs/webpack5-runner: 4.0.3 => 4.0.3 
      babel-preset-taro: 4.0.3 => 4.0.3 
      eslint-config-taro: 4.0.3 => 4.0.3 
      react: ^18.3.1 => 18.3.1 

Metadata

Metadata

Assignees

No one assigned

    Labels

    F-reactFramework - ReactT-weappTarget - 编译到微信小程序V-3Version - 3.x

    Type

    No type

    Projects

    Status

    Done

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions