strictMode option should be documented by @babel/plugin-transform-modules-commonjs
See original GitHub issueBug Report
Current Behavior
There’s no documentation for strictMode
and only for strict
which doesn’t help remove “use strict”.
Expected behavior/code This should be properly documented.
Babel Configuration (.babelrc, package.json, cli command)
{
"plugins": [
"@babel/plugin-syntax-object-rest-spread",
["@babel/plugin-transform-modules-commonjs", {
"strictMode": false
}]
]
}
Environment
- Babel version(s): 7.0.0-beta.46
- Node/npm version: Node 8/npm 5
- OS: OSX 10.13.1
- Monorepo no
- How you are using Babel: cli, register
Possible Solution
Update Readme file
Additional context/Screenshots
Issue Analytics
- State:
- Created 5 years ago
- Reactions:11
- Comments:15 (7 by maintainers)
Top Results From Across the Web
How to remove global "use strict" added by babel
This will disable modules and strict mode, while keeping all other es2015 transformations enabled. Share.
Read more >@babel/plugin-transform-strict-mode | Yarn - Package Manager
This plugin places a 'use strict'; directive at the top of all files to enable strict mode. babel-plugin. readme. babel. The compiler for...
Read more >babel/plugin-transform-strict-mode
This plugin may be enabled via @babel/plugin-transform-modules-commonjs . ... strict off or pass strictMode: false as an option to the commonjs transform.
Read more >Strict mode - JavaScript - MDN Web Docs
Browsers not supporting strict mode will run strict mode code with different ... Strict mode forbids setting properties on primitive values.
Read more >babel-plugin-transform-remove-strict-mode
This plugin may be enabled via @babel/plugin-transform-modules-commonjs. ... So setting it to false ["transform-strict-mode", {"strict": false}] will change ...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Because ES module syntax automatically means that a file is strict, and you rely on non-strict features, it would make sense for you to write your module using standard CommonJS, with
module.exports
andrequire
and such, in my opinion.If you do that, you can just set
sourceType: "script"
in your Babel options, and it will skip adding theuse strict
. Of course, since you’re manually enabling the module transform, you can also just leave that out of your config and you’d be fine too.I think perhaps strict mode could be disabled by default in development, as I’d like to access
arguments.callee
~>Uncaught TypeError: 'caller', 'callee', and 'arguments' properties may not be accessed on strict mode
in the console.