Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

babel-preset-daun

Package Overview
Dependencies
Maintainers
1
Versions
8
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

babel-preset-daun

A babel preset

  • 6.2.0
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
3
decreased by-78.57%
Maintainers
1
Weekly downloads
 
Created
Source

Babel Preset

A default babel preset for my personal projects.

Transforms

Contains transforms for all stage 4 and stage 3 syntax. Stage 4 syntax that is excluded is as follows:

  • generators: regenerator-runtime is too heavyweight for our use.
  • async/await: regenerator-runtime is too heavyweight for our use, and async-to-promises is not yet complete enough to be safely used.
  • async iterators: depends on both generators and async functions
  • lifted template literal restrictions: we do not use tagged template literals, nor implement custom DSLs, otherwise we would enable this.

Install

npm install --save-dev babel-preset-daun

Usage

Add the preset to your .babelrc:

{
  "presets": ["daun"]
}

Targeting Environments

This module uses @babel/preset-env to target specific environments. Please refer to @babel/preset-env#targets for a list of available options.

For a list of browsers please see browserlist.

You may override the default list of targets by providing a targets key.

{
  "presets": [["daun", {
    "targets": {
      "chrome": 50,
      "ie": 11,
      "firefox": 45
    }
  }]]
}

Or inherit the default list of browsers and extend them using additionalTargets.

{
  "presets": [["daun", {
    "additionalTargets": {
      "chrome": 42,
      "ie": 8
    }
  }]]
}

Debugging

Enable debugging by providing a debug key.

{
  "presets": [["daun", {
    "debug": true
  }]]
}

Classes loose mode

By default, this preset will compile classes in normal mode. This is safer, but comes with a bundle size and runtime overhead. To compile classes in loose mode, set the looseClasses option to true:

{
  "presets": [["daun", {
    "looseClasses": true,
  }]]
}

The risks of enabling loose classes are outlined in the Babel docs.

Specifying a babel runtime version

By default @babel/plugin-transform-runtime will assume the oldest version of the runtime to avoid importing helpers that don't exist which would fail at runtime. This can result in newer helpers being inlined into modules (ex. objectSpread2) which increases bundle size.

To avoid this you can configure the preset to use the same version of the runtime that's installed in your package.json.

ex. If package.json has "@babel/runtime": "^7.5.5" then you can use:

{
  "presets": [["daun", {
    "runtimeVersion": "7.5.5",
  }]]
}

Note that this will result in a runtime breakage if the version passed into the preset is newer than the version of the babel runtime actually being used at build time.

Disabling plugin-transform-runtime

You can use the transformRuntime option to disable @babel/plugin-transform-runtime. Specifying false will disable the plugin. This option defaults to true.

Specifying module transforms

You can use the modules option to enable transformation of modules given to this preset:

{
  "presets": [["daun", {
    "modules": "auto"
  }]]
}

Both true and the option default auto will not transform modules if ES6 module syntax is already supported by the environment, or "commonjs" otherwise. false will not transform modules.

You can use the runtimeHelpersUseESModules option to prevent transformation of runtime helpers to CommonJS modules.

{
  "presets": [["daun", {
    "runtimeHelpersUseESModules": true
  }]]
}

true will not transform runtime helpers to CommonJS modules. false will transform runtime helpers to CommonJS modules. The option defaults to true if modules is set to false, and false otherwise.

Keywords

FAQs

Package last updated on 30 Jul 2020

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc