How to remove global “use strict” added by babel

后端 未结 16 2276
不思量自难忘°
不思量自难忘° 2020-11-27 03:46

I\'m using function form of \"use strict\" and don\'t want global form which Babel adds after transpilation. The problem is I\'m using some libraries that aren\'t using \"us

16条回答
  •  孤城傲影
    2020-11-27 04:16

    There's now a babel plugin that you can add to your config that will remove strict mode: babel-plugin-transform-remove-strict-mode. It's a little ugly in that the "use strict" gets added and then removed, but it makes the config much nicer.

    Docs are in the GitHub repo: https://github.com/genify/babel-plugin-transform-remove-strict-mode

    Your .babelrc ends up looking like this:

    {
      "presets": ["env"],
      "plugins": ["transform-remove-strict-mode"]
    }
    

提交回复
热议问题