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

Commit 0a764c0

Browse files
committedDec 30, 2018
Remove unnecessary guard against missing plugins in preflight check
1 parent 31a6f88 commit 0a764c0

File tree

3 files changed

+6
-6
lines changed

3 files changed

+6
-6
lines changed
 

‎src/index.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import * as babel from '@babel/core';
22
import { createFilter } from 'rollup-pluginutils';
33
import createPreflightCheck from './preflightCheck.js';
44
import helperPlugin from './helperPlugin.js';
5-
import { escapeRegExpCharacters, warnOnce } from './utils.js';
5+
import { addBabelPlugin, escapeRegExpCharacters, warnOnce } from './utils.js';
66
import { RUNTIME, EXTERNAL, HELPERS } from './constants.js';
77

88
const unpackOptions = ({
@@ -106,7 +106,7 @@ function createBabelPluginFactory(customCallback = returnObject) {
106106
}
107107

108108
if (helpers !== RUNTIME) {
109-
transformOptions = { ...transformOptions, plugins: transformOptions.plugins.concat(helperPlugin) };
109+
transformOptions = addBabelPlugin(transformOptions, helperPlugin);
110110
}
111111

112112
const result = babel.transformSync(code, transformOptions);

‎src/preflightCheck.js

+2-4
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import { transformSync } from '@babel/core';
22
import { INLINE, RUNTIME, EXTERNAL } from './constants.js';
3+
import { addBabelPlugin } from './utils.js';
34

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

4142
if (~check.indexOf('class ')) {
42-
check = transformSync(inputCode, {
43-
...options,
44-
plugins: (options.plugins || []).concat(fallbackClassTransform),
45-
}).code;
43+
check = transformSync(inputCode, addBabelPlugin(options, fallbackClassTransform)).code;
4644
}
4745

4846
if (

‎src/utils.js

+2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
export const addBabelPlugin = (options, plugin) => ({ ...options, plugins: options.plugins.concat(plugin) });
2+
13
let warned = {};
24
export function warnOnce(ctx, msg) {
35
if (warned[msg]) return;

0 commit comments

Comments
 (0)
This repository has been archived.