Skip to content

Commit

Permalink
(refactor): make preset-env variable naming more explicit (jaredpalme…
Browse files Browse the repository at this point in the history
…r#643)

- I was reading this and was confused which "preset" and "idx" it was
  talking about (despite having worked on some of the code here
  myself), so just make it more explicit
  • Loading branch information
agilgur5 authored and paul-vd committed Dec 1, 2020
1 parent b1c7783 commit 785db32
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions src/babelPluginTsdx.ts
Original file line number Diff line number Diff line change
Expand Up @@ -102,27 +102,27 @@ export const babelPluginTsdx = babelPlugin.custom(() => ({
const babelOptions = config.options || {};
babelOptions.presets = babelOptions.presets || [];

const envIdx = babelOptions.presets.findIndex((preset: any) =>
const presetEnvIdx = babelOptions.presets.findIndex((preset: any) =>
preset.file.request.includes('@babel/preset-env')
);

// if they use preset-env, merge their options with ours
if (envIdx !== -1) {
const preset = babelOptions.presets[envIdx];
babelOptions.presets[envIdx] = createConfigItem(
if (presetEnvIdx !== -1) {
const presetEnv = babelOptions.presets[presetEnvIdx];
babelOptions.presets[presetEnvIdx] = createConfigItem(
[
preset.file.resolved,
presetEnv.file.resolved,
merge(
{
loose: true,
targets: customOptions.targets,
},
preset.options,
presetEnv.options,
{
modules: false,
exclude: merge(
['transform-async-to-generator', 'transform-regenerator'],
(preset.options && preset.options.exclude) || []
(presetEnv.options && presetEnv.options.exclude) || []
),
}
),
Expand Down

0 comments on commit 785db32

Please sign in to comment.