How to remove global “use strict” added by babel

后端 未结 16 2273
不思量自难忘°
不思量自难忘° 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:25

    Since babel 6 you can install firstly babel-cli (if you want to use Babel from the CLI ) or babel-core (to use the Node API). This package does not include modules.

    npm install --global babel-cli
    # or
    npm install --save-dev babel-core
    

    Then install modules that you need. So do not install module for 'strict mode' in your case.

    npm install --save-dev babel-plugin-transform-es2015-arrow-functions
    

    And add installed modules in .babelrc file like this:

    {
      "plugins": ["transform-es2015-arrow-functions"]
    }
    

    See details here: https://babeljs.io/blog/2015/10/31/setting-up-babel-6

提交回复
热议问题