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

mini.compile.include 条件判断不合理 #15115

Closed
banyudu opened this issue Jan 15, 2024 · 1 comment · Fixed by #15120 or #15361
Closed

mini.compile.include 条件判断不合理 #15115

banyudu opened this issue Jan 15, 2024 · 1 comment · Fixed by #15120 or #15361
Labels
F-react Framework - React T-weapp Target - 编译到微信小程序 V-3 Version - 3.x

Comments

@banyudu
Copy link

banyudu commented Jan 15, 2024

相关平台

微信小程序

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

复现步骤

config/index.js 中同时配置 mini.compile.excludemini.compile.include,只有 mini.compile.exclude 生效。

相关代码:https://github.com/NervJS/taro/blob/523bf1b8b31b6f0aebc714db6da9e6ae2dc0db56/packages/taro-mini-runner/src/webpack/chain.ts#L395C2-L406C4

  if (compile.exclude && compile.exclude.length) {
    scriptRule.exclude = [
      ...compile.exclude,
      filename => /css-loader/.test(filename) || (/node_modules/.test(filename) && !(/taro/.test(filename)))
    ]
  } else if (compile.include && compile.include.length) {
    scriptRule.include = [
      ...compile.include,
      sourceDir,
      filename => /taro/.test(filename)
    ]
  } else {
    scriptRule.exclude = [filename => /css-loader/.test(filename) || (/node_modules/.test(filename) && !(/taro/.test(filename)))]
  }

此处的 else if 判断感觉不太合理

期望结果

期望 mini.compile.excludemini.compile.include 能够同时生效

实际结果

当同时配置时,仅 mini.compile.exclude 生效

环境信息

👽 Taro v3.6.17

REQUEST_ENV:  production
envFlag:  
isBuild:  true
basename:  /mp
publicPath:  xxx

  Taro CLI 3.6.17 environment info:
    System:
      OS: macOS 13.6.1
      Shell: 5.9 - /bin/zsh
    Binaries:
      Node: 16.20.0 - ~/.nvm/versions/node/v16.20.0/bin/node
      Yarn: 1.22.19 - ~/.nvm/versions/node/v16.20.0/bin/yarn
      npm: 8.19.4 - ~/.nvm/versions/node/v16.20.0/bin/npm
    npmPackages:
      @tarojs/components: ~3.6.17 => 3.6.17 
      @tarojs/mini-runner: ~3.6.17 => 3.6.17 
      @tarojs/plugin-framework-react: ~3.6.17 => 3.6.17 
      @tarojs/react: ~3.6.17 => 3.6.17 
      @tarojs/runtime: ~3.6.17 => 3.6.17 
      @tarojs/service: ~3.6.17 => 3.6.17 
      @tarojs/taro: ~3.6.17 => 3.6.17 
      @tarojs/webpack-runner: ~3.6.17 => 3.6.17 
      babel-preset-taro: ~3.6.17 => 3.6.17 
      react: ^17.0.0 => 17.0.2 
@taro-bot2 taro-bot2 bot added F-react Framework - React T-weapp Target - 编译到微信小程序 V-3 Version - 3.x labels Jan 15, 2024
@Chen-jj Chen-jj linked a pull request Mar 14, 2024 that will close this issue
18 tasks
@banyudu
Copy link
Author

banyudu commented Mar 20, 2024

Awesome, thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
F-react Framework - React T-weapp Target - 编译到微信小程序 V-3 Version - 3.x
Projects
Archived in project
1 participant