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 3.0.8后,webpack-bundle-analyzer插件不能正常运行 #7443

Closed
ztfstar opened this issue Aug 26, 2020 · 9 comments
Closed
Labels
F-react Framework - React T-weapp Target - 编译到微信小程序 V-3 Version - 3.x

Comments

@ztfstar
Copy link

ztfstar commented Aug 26, 2020

相关平台

微信小程序

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

复现步骤

升级到3.0.8后,启动yarn dev:weapp命令运行后,webpack-bundle-analyzer插件不能正常运行。

期望结果

webpack-bundle-analyzer插件正常运行

实际结果

webpack-bundle-analyzer插件不能正常运行

环境信息


  Taro CLI 3.0.8 environment info:
    System:
      OS: macOS 10.14.5
      Shell: 3.2.57 - /bin/bash
    Binaries:
      Node: 14.4.0 - /usr/local/bin/node
      Yarn: 1.22.4 - /usr/local/bin/yarn
      npm: 6.14.5 - /usr/local/bin/npm
    npmPackages:
      @tarojs/cli: 1.3.35 => 1.3.35 
      @tarojs/components: ^3.0.8 => 3.0.8 
      @tarojs/mini-runner: ^3.0.8 => 3.0.8 
      @tarojs/react: ^3.0.8 => 3.0.8 
      @tarojs/router: 1.3.35 => 1.3.35 
      @tarojs/runtime: ^3.0.8 => 3.0.8 
      @tarojs/taro: ^3.0.8 => 3.0.8 
      @tarojs/taro-h5: 1.3.35 => 1.3.35 
      @tarojs/webpack-runner: 1.3.35 => 1.3.35 
      eslint-config-taro: 1.3.35 => 1.3.35 
      eslint-plugin-taro: 1.3.35 => 1.3.35 
      nerv-devtools: ^1.5.6 => 1.5.6 
      nervjs: ^1.5.7 => 1.5.7 
      react: ^16.13.1 => 16.13.1 
      taro-ui: ^2.2.4 => 2.2.4 
    npmGlobalPackages:
      typescript: 3.9.5
@taro-bot2 taro-bot2 bot added F-react Framework - React T-weapp Target - 编译到微信小程序 V-3 Version - 3.x labels Aug 26, 2020
@luckyadam
Copy link
Member

没有复现,你项目依赖里有些 taro 包的版本是旧的

@ztfstar
Copy link
Author

ztfstar commented Aug 26, 2020

@luckyadam taro的依赖更新是按照咱们文档上更新的,taro的依赖会影响插件的运行吗?
@luckyadam
`const config = {
projectName: 'library-miniprogram',
date: '2019-10-30',
designWidth: 750,
deviceRatio: {
'640': 2.34 / 2,
'750': 1,
'828': 1.81 / 2
},
sourceRoot: 'src',
outputRoot: 'dist',
alias: {
'@/components': path.resolve(__dirname, '..', 'src/components'),
'@/utils': path.resolve(__dirname, '..', 'src/utils'),
'@/pages': path.resolve(__dirname, '..', 'src/pages'),
'@/store': path.resolve(__dirname, '..', 'src/store'),
'@/api': path.resolve(__dirname, '..', 'src/api'),

},
plugins: {
    babel: {
        sourceMap: true,
        presets: [
            ['env', {
                modules: false
            }]
        ],
        plugins: [
            'transform-decorators-legacy',
            'transform-class-properties',
            'transform-object-rest-spread'
        ]
    }
},
defineConstants: {
},
copy: {
    patterns: [
    ],
    options: {
    }
},
terser: {
    enable: true,
},
mini: {
    webpackChain (chain, webpack) {
        chain.plugin('analyzer')
          .use(require('webpack-bundle-analyzer').BundleAnalyzerPlugin, [])
    },
    module: {
        postcss: {
            autoprefixer: {
                enable: false,
                config: {
                    browsers: [
                        'last 3 versions',
                        'Android >= 5',
                        'ios >= 10'
                    ]
                }
            },
            pxtransform: {
                enable: true,
                config: {

                }
            },
            url: {
                enable: true,
                config: {
                    limit: 1024 // 设定转换尺寸上限
                }
            },
            cssModules: {
                enable: false, // 默认为 false,如需使用 css modules 功能,则设为 true
                config: {
                    namingPattern: 'module', // 转换模式,取值为 global/module
                    generateScopedName: '[name]__[local]___[hash:base64:5]'
                }
            }
        }
    }
},
h5: {
    publicPath: '/',
    staticDirectory: 'static',
    esnextModules: ['taro-ui'],
    router: {
        mode: 'browser' // 或者是 'browser'
    },
    module: {
        postcss: {
            autoprefixer: {
                enable: true,
                config: {
                    browsers: [
                        'last 3 versions',
                        'Android >= 4.1',
                        'ios >= 8'
                    ]
                }
            },
            cssModules: {
                enable: false, // 默认为 false,如需使用 css modules 功能,则设为 true
                config: {
                    namingPattern: 'module', // 转换模式,取值为 global/module
                    generateScopedName: '[name]__[local]___[hash:base64:5]'
                }
            }
        }
    }
}

}`

@luckyadam
Copy link
Member

Taro CLI 和项目依赖的版本保持一致

@ztfstar
Copy link
Author

ztfstar commented Aug 26, 2020

@ztfstar
Copy link
Author

ztfstar commented Aug 26, 2020

@luckyadam 大佬 ,我这边"@tarojs/cli": "1.3.35",和"@tarojs/taro-weapp": "1.3.35",版本一样的

{
"name": "library-miniprogram",
"version": "1.1.5",
"private": true,
"description": "图书馆小程序",
"templateInfo": {
"name": "mobx",
"typescript": true,
"css": "sass"
},
"main": "index.js",
"scripts": {
"build:weapp": "taro build --type weapp",
"build:swan": "taro build --type swan",
"build:alipay": "taro build --type alipay",
"build:tt": "taro build --type tt",
"build:h5": "taro build --type h5",
"build:rn": "taro build --type rn",
"dev:weapp": "npm run build:weapp -- --watch",
"dev:swan": "npm run build:swan -- --watch",
"dev:alipay": "npm run build:alipay -- --watch",
"dev:tt": "npm run build:tt -- --watch",
"dev:h5": "npm run build:h5 -- --watch",
"dev:rn": "npm run build:rn -- --watch"
},
"author": "",
"license": "MIT",
"dependencies": {
"@tarojs/async-await": "1.3.35",
"@tarojs/components": "^3.0.8",
"@tarojs/mini-runner": "^3.0.8",
"@tarojs/mobx": "1.3.35",
"@tarojs/mobx-h5": "1.3.35",
"@tarojs/mobx-rn": "1.3.35",
"@tarojs/react": "^3.0.8",
"@tarojs/rn-runner": "1.3.35",
"@tarojs/router": "1.3.35",
"@tarojs/runtime": "^3.0.8",
"@tarojs/taro": "^3.0.8",
"@tarojs/taro-alipay": "1.3.35",
"@tarojs/taro-h5": "1.3.35",
"@tarojs/taro-swan": "1.3.35",
"@tarojs/taro-tt": "1.3.35",
"@tarojs/taro-weapp": "1.3.35",
"@xmly/xlog-xmlite": "^1.0.0-rc.0",
"classnames": "^2.2.6",
"eslint-config-prettier": "^6.7.0",
"eslint-plugin-prettier": "^3.1.1",
"mobx": "4.8.0",
"mobx-react": "^6.1.4",
"nerv-devtools": "^1.5.6",
"nervjs": "^1.5.7",
"prettier": "^1.19.1",
"react": "^16.13.1",
"taro-listview": "^1.1.11",
"taro-ui": "^2.2.4"
},
"devDependencies": {
"@tarojs/cli": "1.3.35",
"@tarojs/plugin-babel": "1.3.35",
"@tarojs/plugin-csso": "1.3.35",
"@tarojs/plugin-sass": "1.3.35",
"@tarojs/plugin-uglifyjs": "1.3.35",
"@tarojs/webpack-runner": "1.3.35",
"@types/react": "16.3.14",
"@types/webpack-env": "^1.13.6",
"@typescript-eslint/eslint-plugin": "^2.10.0",
"@typescript-eslint/parser": "^2.10.0",
"babel-eslint": "^8.2.3",
"babel-plugin-transform-class-properties": "^6.24.1",
"babel-plugin-transform-decorators-legacy": "^1.3.4",
"babel-plugin-transform-jsx-stylesheet": "^0.6.5",
"babel-plugin-transform-object-rest-spread": "^6.26.0",
"babel-preset-env": "^1.6.1",
"eslint": "^5.16.0",
"eslint-config-taro": "1.3.35",
"eslint-plugin-import": "^2.12.0",
"eslint-plugin-react": "^7.8.2",
"eslint-plugin-react-hooks": "^1.6.1",
"eslint-plugin-taro": "1.3.35",
"husky": "^3.1.0",
"lint-staged": "^9.5.0",
"stylelint": "9.3.0",
"stylelint-config-taro-rn": "1.3.35",
"stylelint-taro-rn": "1.3.35",
"typescript": "^3.0.1",
"webpack-bundle-analyzer": "^3.8.0"
},
"husky": {
"hooks": {
"pre-commit": "lint-staged"
}
},
"lint-staged": {
"src/**/*.{js,jsx,ts,tsx,css,scss,json,md}": [
"prettier --write",
"git add"
]
}
}

@luckyadam
Copy link
Member

没有复现这个问题,希望可以提供个 demo 看看

@jenerse
Copy link

jenerse commented Aug 28, 2020

建议用3.0.8创建项目,然后把页面代码迁移过去。可以减少配置上的问题。

@ztfstar
Copy link
Author

ztfstar commented Aug 30, 2020

@jenerse 谢谢

@Chen-jj
Copy link
Contributor

Chen-jj commented Sep 1, 2020

同没有复现,再检查下吧。

@Chen-jj Chen-jj closed this as completed Sep 1, 2020
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
None yet
Development

No branches or pull requests

4 participants