babel-preset-es2015-loose

raw JSON →
8.0.0 verified Sat Apr 25 auth: no javascript deprecated

Babel preset that enables loose mode for all es2015 plugins. Latest version 8.0.0, deprecated since Babel v6.13+ because the official babel-preset-es2015 now natively supports loose mode via configuration. This preset works by modifying babel-preset-es2015 using modify-babel-preset. It requires installing both babel-preset-es2015-loose and babel-preset-es2015. No longer recommended for Babel v6.13+; directly use ["es2015", {"loose": true}] instead.

error Cannot find module 'babel-preset-es2015'
cause Missing peer dependency babel-preset-es2015 was not installed.
fix
Run: npm install --save-dev babel-preset-es2015
error Unknown preset "es2015-loose" is not a valid preset or plugin
cause Preset not installed or Babel cannot locate it.
fix
Verify babel-preset-es2015-loose is in node_modules and listed in package.json devDependencies.
error Error: Preset es2015-loose requires babel-preset-es2015 (>=6.0.0) to be installed
cause babel-preset-es2015 version does not satisfy the peer dependency range.
fix
Update babel-preset-es2015 to version 6.0.0 or higher.
deprecated This preset is deprecated for Babel v6.13+. Use official babel-preset-es2015 with loose option.
fix Replace 'es2015-loose' with ["es2015", {"loose": true}] in your Babel config and uninstall babel-preset-es2015-loose.
breaking Breaking change from v6 to v7: requires explicit installation of babel-preset-es2015 due to modify-babel-preset.
fix Ensure babel-preset-es2015 is listed as a dependency in package.json and installed.
gotcha Loose mode may deviate from spec; cross-browser compatibility may be affected.
fix Test thoroughly in target environments, or avoid loose mode for spec compliance.
gotcha The preset version is tied to modify-babel-preset, not babel core; updates may lag.
fix Consider using official babel-preset-es2015 directly with loose option if on Babel v6.13+.
npm install babel-preset-es2015-loose
yarn add babel-preset-es2015-loose
pnpm add babel-preset-es2015-loose

Install, configure in .babelrc, and run a transpilation example using the loose preset. (250+ chars)

// Install both packages
npm install --save-dev babel-preset-es2015-loose babel-preset-es2015

// .babelrc
{
  "presets": ["es2015-loose"]
}

// Example input (test.js)
const x = [1, 2, 3];
const y = [...x, 4];
console.log(y);

// Transpile with Babel CLI
babel test.js --presets es2015-loose

// Or programmatically
const babel = require('babel-core');
const result = babel.transform('const x = [1, 2, 3]; const y = [...x, 4];', {
  presets: ['es2015-loose']
});
console.log(result.code);