We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
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
H5
浏览器版本: chrome 版本 110.0.5481.77(正式版本) (arm64) 使用框架: React
直接初始化项目: 在config中添加 { ... defineConstants: { TEST: '"TEST"', }, }
在项目中使用该变量如下
const Index = () => { const [text] = useState(TEST);
return {text}; };
运行项目 npm run build:h5 -- --watch
和小程序编译的结果显示一样, 能够正常显示
ReferenceError TEST is not defined
Taro CLI 3.6.1 environment info: System: OS: macOS 13.0.1 Shell: 5.8.1 - /bin/zsh Binaries: Node: 14.20.0 - ~/.nvm/versions/node/v14.20.0/bin/node Yarn: 1.22.17 - /opt/homebrew/bin/yarn npm: 6.14.17 - ~/.nvm/versions/node/v14.20.0/bin/npm npmPackages: @tarojs/cli: 3.6.1 => 3.6.1 @tarojs/components: 3.6.1 => 3.6.1 @tarojs/helper: 3.6.1 => 3.6.1 @tarojs/plugin-framework-react: 3.6.1 => 3.6.1 @tarojs/plugin-platform-alipay: 3.6.1 => 3.6.1 @tarojs/plugin-platform-h5: 3.6.1 => 3.6.1 @tarojs/plugin-platform-jd: 3.6.1 => 3.6.1 @tarojs/plugin-platform-qq: 3.6.1 => 3.6.1 @tarojs/plugin-platform-swan: 3.6.1 => 3.6.1 @tarojs/plugin-platform-tt: 3.6.1 => 3.6.1 @tarojs/plugin-platform-weapp: 3.6.1 => 3.6.1 @tarojs/react: 3.6.1 => 3.6.1 @tarojs/runtime: 3.6.1 => 3.6.1 @tarojs/shared: 3.6.1 => 3.6.1 @tarojs/taro: 3.6.1 => 3.6.1 @tarojs/webpack5-runner: 3.6.1 => 3.6.1 babel-preset-taro: 3.6.1 => 3.6.1 eslint-config-taro: 3.6.1 => 3.6.1 react: ^18.0.0 => 18.2.0 npmGlobalPackages: typescript: 4.9.4
The text was updated successfully, but these errors were encountered:
原因是 @tarojs/plugin-platform-h5@3.6.1 中, 本来应该是merge操作, 变成了覆盖操作, 导致自定义的defineConstants都失效了
// node_modules/@tarojs/plugin-platform-h5/dist/index.js // line 124 ctx.modifyRunnerOpts(({ opts }) => { opts.defineConstants = { USE_HTML_COMPONENTS: JSON.stringify(!!opts.useHtmlComponents), }; // TODO 为 postcss-html-transform 更新组件转换列表 });
Sorry, something went wrong.
fix(h5): custom define-constants fix #13286
753e7fd
fix(h5): custom define-constants fix #13286 (#13292)
c50f63f
* fix(h5): custom define-constants fix #13286 --------- Co-authored-by: AzuFF <47267778+heiazu@users.noreply.github.com> Co-authored-by: zhuminghui2 <zhuminghui2@jd.com>
Successfully merging a pull request may close this issue.
相关平台
H5
浏览器版本: chrome 版本 110.0.5481.77(正式版本) (arm64)
使用框架: React
复现步骤
直接初始化项目:
在config中添加
{
...
defineConstants: {
TEST: '"TEST"',
},
}
在项目中使用该变量如下
const Index = () => {
const [text] = useState(TEST);
return {text};
};
运行项目
npm run build:h5 -- --watch
期望结果
和小程序编译的结果显示一样, 能够正常显示
实际结果
ReferenceError
TEST is not defined
环境信息
The text was updated successfully, but these errors were encountered: