Skip to content

Commit 15a4d43

Browse files
committed
feat: add babel-plugin-transform-not-strict
1 parent 72655a8 commit 15a4d43

File tree

4 files changed

+33
-9
lines changed

4 files changed

+33
-9
lines changed

README.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -120,6 +120,9 @@ Enable `"@babel/preset-react"`. `true` by default.
120120

121121
Enable `"@babel/preset-flow"`. `true` by default.
122122

123+
8) `removeAllUseStrict`
124+
125+
Remove all `'use strict'` from all files. Passed to `babel-plugin-transform-not-strict`. This is `false` by default.
123126

124127
## Behind the scenes
125128

@@ -141,3 +144,6 @@ It includes the plugins for compile time code generation:
141144

142145
It has the preset that automatically adds default export for older Node versions (so no `require().default` is needed).
143146
- `"babel-plugin-add-module-exports"`
147+
148+
It has the plugin for removing `'use strict'`:
149+
- `"babel-plugin-transform-not-strict"`

index.js

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,12 +42,16 @@ function handleOptions(options) {
4242
flow = true
4343
}
4444

45-
return {targets, keepModules, addModuleExports, addModuleExportsDefaultProperty, sourceMap, react, flow }
45+
if (removeAllUseStrict == null) {
46+
removeAllUseStrict = false
47+
}
48+
49+
return {targets, keepModules, addModuleExports, addModuleExportsDefaultProperty, sourceMap, react, flow, removeAllUseStrict }
4650
}
4751

4852
module.exports = (api, options, dirname) => {
4953

50-
const {targets, keepModules, addModuleExports, addModuleExportsDefaultProperty, sourceMap, react, flow } = handleOptions(options)
54+
const {targets, keepModules, addModuleExports, addModuleExportsDefaultProperty, sourceMap, react, flow, removeAllUseStrict } = handleOptions(options)
5155

5256
let presets = [
5357
[
@@ -94,6 +98,9 @@ module.exports = (api, options, dirname) => {
9498
// compile time code generation
9599
require("babel-plugin-codegen"),
96100
require("babel-plugin-preval"),
101+
102+
// not strict
103+
[require("babel-plugin-transform-not-strict"), {removeAll: removeAllUseStrict}],
97104
];
98105

99106
// transform modules (e.g when without Rollup)

package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,8 @@
3535
"@babel/preset-react": "7.10.4",
3636
"babel-plugin-add-module-exports": "^1.0.4",
3737
"babel-plugin-codegen": "^4.0.1",
38-
"babel-plugin-preval": "^5.0.0"
38+
"babel-plugin-preval": "^5.0.0",
39+
"babel-plugin-transform-not-strict": "^0.2.0"
3940
},
4041
"peerDependencies": {
4142
"@babel/cli": "7.11.6",

pnpm-lock.yaml

Lines changed: 16 additions & 6 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)