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

Commit

Permalink
Fix usage with externalHelpers flag
Browse files Browse the repository at this point in the history
  • Loading branch information
Andarist committed Jan 19, 2019
1 parent 66f2f41 commit a7e7676
Show file tree
Hide file tree
Showing 6 changed files with 10 additions and 10 deletions.
2 changes: 1 addition & 1 deletion src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ function createBabelPluginFactory(customCallback = returnObject) {
);
}

if (helpers !== RUNTIME) {
if (helpers !== RUNTIME && !externalHelpers) {
transformOptions = addBabelPlugin(transformOptions, helperPlugin);
}

Expand Down
18 changes: 9 additions & 9 deletions test/test.js
Original file line number Diff line number Diff line change
Expand Up @@ -91,13 +91,6 @@ describe('rollup-plugin-babel', function() {
});
});

it('does not add helpers when externalHelpers option is truthy', () => {
return bundle('samples/class/main.js').then(({ code }) => {
assert.ok(code.indexOf('babelHelpers =') === -1, code);
assert.ok(code.indexOf(`${HELPERS}.classCallCheck =`) === -1, code);
});
});

it('does not babelify excluded code', () => {
return bundle('samples/exclusions/main.js', { exclude: '**/foo.js' }).then(({ code }) => {
assert.ok(code.indexOf('${foo()}') === -1, code);
Expand Down Expand Up @@ -188,14 +181,21 @@ describe('rollup-plugin-babel', function() {
});
});

it('warns about deprecated usage with external-helper plugin', () => {
it('allows using external-helpers plugin in combination with externalHelpers flag', () => {
return bundle('samples/external-helpers/main.js', { externalHelpers: true }).then(({ code }) => {
assert.ok(code.indexOf('function _classCallCheck') === -1);
assert.ok(code.indexOf('babelHelpers.classCallCheck') !== -1);
});
});

it('warns about deprecated usage with external-helpers plugin (without externalHelpers flag)', () => {
/* eslint-disable no-console */
const messages = [];
const originalWarn = console.warn;
console.warn = msg => {
messages.push(msg);
};
return bundle('samples/external-helpers-deprecated/main.js').then(() => {
return bundle('samples/external-helpers/main.js').then(() => {
console.warn = originalWarn;

assert.deepEqual(messages, [
Expand Down

0 comments on commit a7e7676

Please sign in to comment.