question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

strictMode option should be documented by @babel/plugin-transform-modules-commonjs

See original GitHub issue

Bug 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:open
  • Created 5 years ago
  • Reactions:11
  • Comments:15 (7 by maintainers)

github_iconTop GitHub Comments

16reactions
loganfsmythcommented, May 12, 2018

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 and require and such, in my opinion.

If you do that, you can just set sourceType: "script" in your Babel options, and it will skip adding the use 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.

0reactions
dezmancommented, May 1, 2021

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.

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found