babel-preset-es2015-without-strict
raw JSON → 0.0.4 verified Sat Apr 25 auth: no javascript deprecated
A Babel preset that includes all ES2015 plugins (like babel-preset-es2015) but disables the automatic prepending of 'use strict' directives. This is useful when you want ES2015 transpilation without forcing strict mode, for example when combining with other scripts that are not strict-mode compatible or when targeting environments where strict mode causes issues. Version 0.0.4 is the latest and only release; there are no updates, and the preset is now obsolete because Babel 7+ deprecated the es2015 preset in favor of individual plugins or @babel/preset-env. This preset works only with Babel 6.x.
Common errors
error Error: Requires Babel 6.x, but you have Babel 7.x installed. ↓
cause This preset is incompatible with Babel 7+.
fix
Downgrade to Babel 6, or migrate to Babel 7 and use @babel/preset-env with the 'strict' option set to false.
error ReferenceError: regeneratorRuntime is not defined ↓
cause The preset does not include the regenerator runtime for generators/async functions.
fix
In Babel 6, add babel-polyfill or babel-plugin-transform-runtime.
error Module not found: Can't resolve 'babel-preset-es2015-without-strict' ↓
cause The preset is not installed or the name is misspelled in .babelrc.
fix
Run 'npm install --save-dev babel-preset-es2015-without-strict' and use 'es2015-without-strict' (without 'babel-preset-' prefix) in config.
Warnings
deprecated This preset is for Babel 6 only and is no longer maintained. Babel 7 uses @babel/preset-env which can control strict mode via the 'strict' option. ↓
fix Upgrade to Babel 7 and use @babel/preset-env with the 'modules' and 'strict' options to achieve the same effect.
breaking The preset does not include any polyfills. You must separately include babel-polyfill or core-js for features like Promises, Map, Set, etc. ↓
fix Add 'babel-polyfill' to your entry point or use @babel/preset-env with 'useBuiltIns'.
gotcha Omitting 'use strict' can lead to issues when transpiled code is concatenated with other scripts that rely on strict mode. In non-strict mode, 'this' in functions defaults to the global object, which can cause bugs. ↓
fix Ensure your final bundle is wrapped in a function scope or use a module bundler that adds strict mode per module.
Install
npm install babel-preset-es2015-without-strict yarn add babel-preset-es2015-without-strict pnpm add babel-preset-es2015-without-strict Imports
- default (preset) wrong
{ "presets": ["babel-preset-es2015-without-strict"] }correct{ "presets": ["es2015-without-strict"] } - preset via Node API wrong
require('babel-core').transform(code, { presets: [require('babel-preset-es2015-without-strict')] });correctrequire('babel-core').transform(code, { presets: ['es2015-without-strict'] }); - preset via CLI wrong
babel script.js --presets babel-preset-es2015-without-strictcorrectbabel script.js --presets es2015-without-strict
Quickstart
// Install
npm install --save-dev babel-preset-es2015-without-strict babel-preset-es2015 babel-cli
// .babelrc
{
"presets": ["es2015-without-strict"]
}
// Example ES2015 code (input.js)
const hello = () => 'Hello World';
export default hello;
// Transpile via CLI
babel input.js --out-file output.js
// Output will be ES5 without 'use strict'
"use strict"; // this line is omitted
var hello = function hello() {
return 'Hello World';
};
exports.default = hello;