Projekt

Obecné

Profil

Stáhnout (1.02 KB) Statistiky
| Větev: | Revize:
1 3a515b92 cagy
# babel-plugin-transform-strict-mode
2
3
> 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).
4
5
This plugin may be enabled via `babel-plugin-transform-es2015-modules-commonjs`.
6
If you wish to disable it you can either turn `strict` off or pass
7
`strictMode: false` as an option to the commonjs transform.
8
9
## Example
10
11
**In**
12
13
```javascript
14
foo();
15
```
16
17
**Out**
18
19
```javascript
20
"use strict";
21
22
foo();
23
```
24
25
## Installation
26
27
```sh
28
npm install --save-dev babel-plugin-transform-strict-mode
29
```
30
31
## Usage
32
33
### Via `.babelrc` (Recommended)
34
35
**.babelrc**
36
37
Without options:
38
39
```json
40
{
41
  "plugins": ["transform-strict-mode"]
42
}
43
```
44
45
With options:
46
47
```json
48
{
49
  "plugins": [
50
    ["transform-strict-mode", {
51
      "strict": true
52
    }]
53
  ]
54
}
55
```
56
57
### Via CLI
58
59
```sh
60
babel --plugins transform-strict-mode script.js
61
```
62
63
### Via Node API
64
65
```javascript
66
require("babel-core").transform("code", {
67
  plugins: ["transform-strict-mode"]
68
});
69
```