72e63a7368f2d1b5733035a45eca8f83ee24b4eb32e6ed9a340dcc774779f245adee155bdb27bdbde1ddc7d2626b7872aa1bf54ee9985790bb7f9e8186fe63 1.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  1. # babel-plugin-transform-strict-mode
  2. > This plugin places a `"use strict";` directive at the top of all files to enable [strict mode](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Strict_mode).
  3. This plugin may be enabled via `babel-plugin-transform-es2015-modules-commonjs`.
  4. If you wish to disable it you can either turn `strict` off or pass
  5. `strictMode: false` as an option to the commonjs transform.
  6. ## Example
  7. **In**
  8. ```javascript
  9. foo();
  10. ```
  11. **Out**
  12. ```javascript
  13. "use strict";
  14. foo();
  15. ```
  16. ## Installation
  17. ```sh
  18. npm install --save-dev babel-plugin-transform-strict-mode
  19. ```
  20. ## Usage
  21. ### Via `.babelrc` (Recommended)
  22. **.babelrc**
  23. Without options:
  24. ```json
  25. {
  26. "plugins": ["transform-strict-mode"]
  27. }
  28. ```
  29. With options:
  30. ```json
  31. {
  32. "plugins": [
  33. ["transform-strict-mode", {
  34. "strict": true
  35. }]
  36. ]
  37. }
  38. ```
  39. ### Via CLI
  40. ```sh
  41. babel --plugins transform-strict-mode script.js
  42. ```
  43. ### Via Node API
  44. ```javascript
  45. require("babel-core").transform("code", {
  46. plugins: ["transform-strict-mode"]
  47. });
  48. ```