Adds strictMode option to strict-mode transform (#3562)
This commit is contained in:
parent
52683f0018
commit
c561312bee
@ -0,0 +1,3 @@
|
|||||||
|
{
|
||||||
|
"plugins": ["external-helpers", ["transform-es2015-modules-commonjs", { "strictMode": false }]]
|
||||||
|
}
|
||||||
@ -0,0 +1,3 @@
|
|||||||
|
import "foo";
|
||||||
|
import "foo-bar";
|
||||||
|
import "./directory/foo-bar";
|
||||||
@ -0,0 +1,5 @@
|
|||||||
|
require("foo");
|
||||||
|
|
||||||
|
require("foo-bar");
|
||||||
|
|
||||||
|
require("./directory/foo-bar");
|
||||||
@ -1,6 +1,11 @@
|
|||||||
# babel-plugin-transform-strict-mode
|
# babel-plugin-transform-strict-mode
|
||||||
|
|
||||||
TODO
|
Add the `"use strict";` directive to the top of your files if it is not there
|
||||||
|
already.
|
||||||
|
|
||||||
|
> This plugin may be enabled via `babel-plugin-transform-es2015-modules-commonjs`.
|
||||||
|
> If you wish to disable it you can either turn `strict` off or pass
|
||||||
|
> `strictMode: false` as an option to the commonjs transform.
|
||||||
|
|
||||||
## Installation
|
## Installation
|
||||||
|
|
||||||
|
|||||||
@ -4,7 +4,7 @@ export default function () {
|
|||||||
return {
|
return {
|
||||||
visitor: {
|
visitor: {
|
||||||
Program(path, state) {
|
Program(path, state) {
|
||||||
if (state.opts.strict === false) return;
|
if (state.opts.strict === false || state.opts.strictMode === false) return;
|
||||||
|
|
||||||
let { node } = path;
|
let { node } = path;
|
||||||
|
|
||||||
|
|||||||
5
packages/babel-plugin-transform-strict-mode/test/fixtures/disable-strict-mode/options.json
vendored
Normal file
5
packages/babel-plugin-transform-strict-mode/test/fixtures/disable-strict-mode/options.json
vendored
Normal file
@ -0,0 +1,5 @@
|
|||||||
|
{
|
||||||
|
"plugins": [
|
||||||
|
["transform-strict-mode", { "strictMode": false }]
|
||||||
|
]
|
||||||
|
}
|
||||||
@ -0,0 +1 @@
|
|||||||
|
foo();
|
||||||
@ -0,0 +1 @@
|
|||||||
|
foo();
|
||||||
Loading…
x
Reference in New Issue
Block a user