Skip to content

Commit

Permalink
Allow disabling ESM modules via options + added more docs
Browse files Browse the repository at this point in the history
  • Loading branch information
swernerx committed Jun 19, 2017
1 parent f77bb6d commit 4be13a5
Showing 1 changed file with 16 additions and 1 deletion.
17 changes: 16 additions & 1 deletion src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,15 +26,30 @@ export default function buildPreset(context, opts = {})

const looseMode = true

const defaults = {
modules: false
}
const options = { ...defaults, ...opts }

const envValue = process.env.BABEL_ENV || process.env.NODE_ENV || "development"
const isProduction = envValue === "production"

presets.push([ envPreset, {
// Setting this to false will not transform modules.
// "modules": false,
modules: options.modules,

// Prefer built-ins which also prefers global polyfills which is the right thing to do
// for most scenarios like SPAs and NodeJS environments.
useBuiltIns: true,

loose: looseMode,

// We prefer the transpilation of the "fast-async" plugin over the
// slower and more complex Babel internal implementation.
exclude: [ "transform-regenerator", "transform-async-to-generator" ],

// Differ between development and production for our scope.
// NodeJS is generally fine in development to match the runtime version which is currently installed.
targets: {
browsers: [ "last 2 versions" ],
node: "current"
Expand Down

0 comments on commit 4be13a5

Please sign in to comment.