如何在使用 webpack 捆绑 React 时禁用严格模式 [英] How to disable strict mode while bundling React using webpack

查看:111
本文介绍了如何在使用 webpack 捆绑 React 时禁用严格模式的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

您好,我被我的应用程序困住了,我的应用程序在所有其他浏览器中工作正常,而不是在 IE 中,它抛出错误

Hello I am stuck with my application, my application working fine in all other browser not in IE it's throw the error

0x800a0416 - JavaScript runtime error: Multiple definitions of a property not allowed in strict mode

我已经在 webpack.config 中实现了 loader

I have implemented loader in webpack.config

  module: {
    loaders: [{
        test: /\.js?$/,
        exclude: /(node_modules|bower_components)/,
        loaders: ['babel'],
        include: path.join(__dirname, 'scripts')
    }]
}

和我的 Package.json 脚本包含 "build": "./node_modules/.bin/webpack --config webpack.config.production.js --progress --profile --colors", 用于构建包

and my Package.json Script contain "build": "./node_modules/.bin/webpack --config webpack.config.production.js --progress --profile --colors", for build the bundle

如果我会明确地找到 use strict 并将其从 bundle 中删除,那么它可以正常工作,那么如何在使用 webpack 创建 bundle 时删除该严格模式

If I will explicitly find use strict and remove it from bundle then it works fine so how can I remove that strict mode while create a bundle using webpack

推荐答案

我在我的 .babelrc 文件中包含了黑名单选项,例如

I have include the blacklist option in my .babelrc file like

 blacklist: ["useStrict"]

而且它工作正常.

这篇关于如何在使用 webpack 捆绑 React 时禁用严格模式的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆