Skip to content
This repository has been archived by the owner on Aug 4, 2021. It is now read-only.

Commit

Permalink
Remove unnecessary guard against missing plugins in preflight check
Browse files Browse the repository at this point in the history
  • Loading branch information
Andarist committed Dec 30, 2018
1 parent 31a6f88 commit 0a764c0
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 6 deletions.
4 changes: 2 additions & 2 deletions src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import * as babel from '@babel/core';
import { createFilter } from 'rollup-pluginutils';
import createPreflightCheck from './preflightCheck.js';
import helperPlugin from './helperPlugin.js';
import { escapeRegExpCharacters, warnOnce } from './utils.js';
import { addBabelPlugin, escapeRegExpCharacters, warnOnce } from './utils.js';
import { RUNTIME, EXTERNAL, HELPERS } from './constants.js';

const unpackOptions = ({
Expand Down Expand Up @@ -106,7 +106,7 @@ function createBabelPluginFactory(customCallback = returnObject) {
}

if (helpers !== RUNTIME) {
transformOptions = { ...transformOptions, plugins: transformOptions.plugins.concat(helperPlugin) };
transformOptions = addBabelPlugin(transformOptions, helperPlugin);
}

const result = babel.transformSync(code, transformOptions);
Expand Down
6 changes: 2 additions & 4 deletions src/preflightCheck.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { transformSync } from '@babel/core';
import { INLINE, RUNTIME, EXTERNAL } from './constants.js';
import { addBabelPlugin } from './utils.js';

const MODULE_ERROR =
'Rollup requires that your Babel configuration keeps ES6 module syntax intact. ' +
Expand Down Expand Up @@ -39,10 +40,7 @@ export default function createPreflightCheck() {
let check = transformed.code;

if (~check.indexOf('class ')) {
check = transformSync(inputCode, {
...options,
plugins: (options.plugins || []).concat(fallbackClassTransform),
}).code;
check = transformSync(inputCode, addBabelPlugin(options, fallbackClassTransform)).code;
}

if (
Expand Down
2 changes: 2 additions & 0 deletions src/utils.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
export const addBabelPlugin = (options, plugin) => ({ ...options, plugins: options.plugins.concat(plugin) });

let warned = {};
export function warnOnce(ctx, msg) {
if (warned[msg]) return;
Expand Down

0 comments on commit 0a764c0

Please sign in to comment.