11

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

I have implemented loader in webpack.config

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

and my Package.json Script contain "build": "./node_modules/.bin/webpack --config webpack.config.production.js --progress --profile --colors", for build the 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

Bergi
  • 630,263
  • 148
  • 957
  • 1,375
Dhaval Patel
  • 7,471
  • 6
  • 37
  • 70
  • From the looks of it you are using es6 since you are using babel and if you read here http://stackoverflow.com/questions/31685262/not-recommended-to-write-out-use-strict-with-es6. Why do you need to write strict? – Mike D Jan 20 '16 at 18:35
  • 2
    See http://stackoverflow.com/questions/33821312/how-to-remove-global-use-strict-added-by-babel – Eric O'Connell Jan 20 '16 at 23:35
  • @MikeD: I have checked in my project I didn't write anywhere in my code "use strict" it will automatically came in bundle.js file – Dhaval Patel Jan 21 '16 at 06:17
  • @EricO'Connell: Thanks Can you please answer it with above mentioned post so I can upvote and other people can use it – Dhaval Patel Jan 21 '16 at 06:18

4 Answers4

10

If you're seeing that error then most likely you've got somewhere in your codebase where you're declaring multiple properties on the same object. Disabling the alarm bell just fixes the symptom.

I've found this error to pop up if I declare duplicate properties in my JSX, e.g. when doing <MyComponent className="foo" onClick={onClick} className="foobar" /> or accidentally duplicating some other property.

Find and fix the actual error instead of just suppressing the error message. IE should tell you what line it's happening on and it shouldn't be too hard to look at what's there and figure out which component has the problem.

ivarni
  • 17,658
  • 17
  • 76
  • 92
5

Check out this package: https://www.npmjs.com/package/babel-plugin-transform-remove-strict-mode

I was looking for a convenient way to get rid of the 'use strict' and it seems to be doing just that.

creimers
  • 4,975
  • 4
  • 33
  • 55
2

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

 blacklist: ["useStrict"]

and it's working fine.

Dhaval Patel
  • 7,471
  • 6
  • 37
  • 70
0

You have few ways around this, bottom line setting modules to false either in .babelrc or your webpack since you use webpack

webpack.mix.js

module : {
        loaders : [
            {
                test: /\.js?/,
                include: APP_DIR,
                use: {
                    loader: 'babel-loader',
                    options: {
                        "presets": [
                            ['es2015', {modules: false}]
                        ],
                    }
                },
                exclude: /node_modules/
            },
        ]
    },

or .babelrc

{
    "presets": [
        [
            "@babel/preset-env",
            {
                "debug": true,
                "modules": false,
                "forceAllTransforms": true,
                "useBuiltIns": "usage"
            }
        ]
    ]
}
DAVID AJAYI
  • 1,912
  • 20
  • 13