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

升级3.5.7后Uncaught ReferenceError: $RefreshSig$ is not defined #12685

Closed
jianjiachenghub opened this issue Oct 19, 2022 · 10 comments · Fixed by #12692 or #12895
Closed

升级3.5.7后Uncaught ReferenceError: $RefreshSig$ is not defined #12685

jianjiachenghub opened this issue Oct 19, 2022 · 10 comments · Fixed by #12692 or #12895
Labels
F-react Framework - React T-h5 Target - 编译到 H5 V-3 Version - 3.x
Milestone

Comments

@jianjiachenghub
Copy link
Contributor

相关平台

H5

浏览器版本: 版本 105.0.5195.125(正式版本) (x86_64)
使用框架: React

复现步骤

项目由3.5.5 执行update指令后,重新运行即报错,目前能根据https://docs.taro.zone/docs/h5#fast-refresh中的提示关闭热跟新解决

期望结果

期望能够都启用hot时,不报错

实际结果

Uncaught (in promise) ReferenceError: $RefreshSig$ is not defined

环境信息

 Taro v3.5.7


  Taro CLI 3.5.7 environment info:
    System:
      OS: macOS 10.15.5
      Shell: 5.7.1 - /bin/zsh
    Binaries:
      Node: 14.19.2 - ~/.nvm/versions/node/v14.19.2/bin/node
      Yarn: 1.22.18 - ~/.nvm/versions/node/v14.19.2/bin/yarn
      npm: 6.14.17 - ~/.nvm/versions/node/v14.19.2/bin/npm
    npmPackages:
      @tarojs/cli: 3.5.7 => 3.5.7 
      @tarojs/components: 3.5.7 => 3.5.7 
      @tarojs/helper: 3.5.7 => 3.5.7 
      @tarojs/plugin-framework-react: 3.5.7 => 3.5.7 
      @tarojs/plugin-platform-alipay: 3.5.7 => 3.5.7 
      @tarojs/plugin-platform-jd: 3.5.7 => 3.5.7 
      @tarojs/plugin-platform-qq: 3.5.7 => 3.5.7 
      @tarojs/plugin-platform-swan: 3.5.7 => 3.5.7 
      @tarojs/plugin-platform-tt: 3.5.7 => 3.5.7 
      @tarojs/plugin-platform-weapp: 3.5.7 => 3.5.7 
      @tarojs/react: 3.5.7 => 3.5.7 
      @tarojs/router: 3.5.7 => 3.5.7 
      @tarojs/runtime: 3.5.7 => 3.5.7 
      @tarojs/shared: 3.5.7 => 3.5.7 
      @tarojs/taro: 3.5.7 => 3.5.7 
      @tarojs/taro-h5: 3.5.7 => 3.5.7 
      @tarojs/webpack5-runner: 3.5.7 => 3.5.7 
      babel-preset-taro: 3.5.7 => 3.5.7 
      eslint-config-taro: 3.5.7 => 3.5.7 
      react: ^18.0.0 => 18.2.0 
@taro-bot2 taro-bot2 bot added F-react Framework - React T-h5 Target - 编译到 H5 V-3 Version - 3.x labels Oct 19, 2022
@ZakaryCode
Copy link
Contributor

没有具体的项目可供复现,正常是无该问题的。

当前出现问题猜测是由于处于生产模式,但却开启热更新导致插件抛出该问题。请检查编译项目时是否启用 watch 模式,同时检查是否存在 webpackChain 传入 mode: production,或 process.env.NODE_ENV === 'production' 等类似情况导致该问题出现。

@jianhao2010303
Copy link

同样的问题 +1.

1 similar comment
@schier
Copy link

schier commented Oct 19, 2022

同样的问题 +1.

@hqwlkj
Copy link
Contributor

hqwlkj commented Oct 19, 2022

+1

image

@jianjiachenghub
Copy link
Contributor Author

没有具体的项目可供复现,正常是无该问题的。

当前出现问题猜测是由于处于生产模式,但却开启热更新导致插件抛出该问题。请检查编译项目时是否启用 watch 模式,同时检查是否存在 webpackChain 传入 mode: production,或 process.env.NODE_ENV === 'production' 等类似情况导致该问题出现。

执行的是"dev:h5": "npm run build:h5 -- --watch",且不存在 传入 mode: production。
但是在config/index 中使用了process.env.NODE_ENV === "production" 来判断publicPath,这个会导致上面提到的问题?

@hqwlkj
Copy link
Contributor

hqwlkj commented Oct 19, 2022

我是做了自定义环境变量

module.exports = function (merge) {
  if (process.env.NODE_ENV === 'development') {
    return merge({}, config, require('./dev'));
  }
  if (process.env.NODE_ENV === 'staging') {
    return merge({}, config, require('./staging'));
  }
  return merge({}, config, require('./prod'));
};

@liugezhou
Copy link

同样的问题+1

@hqwlkj
Copy link
Contributor

hqwlkj commented Oct 20, 2022

可以采用这样的方式开暂时处理一下。

https://taro-docs.jd.com/docs/h5#fast-refresh

@ZakaryCode
Copy link
Contributor

ZakaryCode commented Oct 20, 2022

执行的是"dev:h5": "npm run build:h5 -- --watch",且不存在 传入 mode: production。 但是在config/index 中使用了process.env.NODE_ENV === "production" 来判断publicPath,这个会导致上面提到的问题?

确实存在,在使用 webpack5-runner 编译时,禁用 prebundle 条件下复现了该问题,后续修复。

当前版本可以通过在 config/dev.js 中添加 isWatch: true 跳过该问题:

module. Exports = {
  env: {
    NODE_ENV: '"development"'
  },
  defineConstants: {
  },
+  isWatch: true,
  mini: {},
  h5: {}
}

@xyw1229
Copy link

xyw1229 commented Mar 9, 2023

晕 刚从3.0更新到3.5.7 然后又得更到3.5.8

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
F-react Framework - React T-h5 Target - 编译到 H5 V-3 Version - 3.x
Projects
Archived in project
8 participants