Skip to content

Commit

Permalink
Peer dep (#153)
Browse files Browse the repository at this point in the history
* make an inline plugin for the preflight check, make babel-core a peerDep

* turn babel-core dep into a peerDep

* fix reference to old class plugin
  • Loading branch information
hzoo authored and Andarist committed Apr 11, 2020
1 parent e58dfeb commit 52b8a39
Show file tree
Hide file tree
Showing 5 changed files with 25 additions and 5 deletions.
6 changes: 4 additions & 2 deletions packages/rollup-plugin-babel/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -31,11 +31,13 @@
"lint": "eslint src"
},
"dependencies": {
"babel-core": "7.0.0-alpha.17",
"babel-plugin-transform-es2015-classes": "7.0.0-alpha.17",
"rollup-pluginutils": "^1.5.0"
},
"peerDependencies": {
"babel-core": "6 || 7 || ^7.0.0-alpha || ^7.0.0-beta || ^7.0.0-rc"
},
"devDependencies": {
"babel-core": "7.0.0-alpha.17",
"babel-plugin-external-helpers": "7.0.0-alpha.17",
"babel-plugin-transform-decorators": "7.0.0-alpha.17",
"babel-plugin-transform-runtime": "7.0.0-alpha.17",
Expand Down
9 changes: 9 additions & 0 deletions packages/rollup-plugin-babel/src/helperPlugin.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
export default function importHelperPlugin () {
return {
visitor: {
Program (path, state) {
state.file.addHelper('classCallCheck');
}
}
};
}
4 changes: 2 additions & 2 deletions packages/rollup-plugin-babel/src/preflightCheck.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { join } from 'path';
import { transform } from 'babel-core';
import { INLINE, RUNTIME, BUNDLED } from './constants.js';
import classes from 'babel-plugin-transform-es2015-classes';
import importHelperPlugin from './helperPlugin.js';

let preflightCheckResults = {};

Expand All @@ -15,7 +15,7 @@ export default function preflightCheck ( options, dir ) {

options.filename = join( dir, 'x.js' );

options.plugins = options.plugins ? options.plugins.concat( classes ) : [ classes ];
options.plugins = options.plugins ? options.plugins.concat( importHelperPlugin ) : [ importHelperPlugin ];

const check = transform( 'export default class Foo {}', options ).code;

Expand Down
9 changes: 9 additions & 0 deletions packages/rollup-plugin-babel/test/helperPlugin.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
module.exports = function importHelperPlugin () {
return {
visitor: {
Program (path, state) {
state.file.addHelper('classCallCheck');
}
}
};
}
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
{
"plugins": [ "transform-es2015-classes" ]
"plugins": [ "../../helperPlugin" ]
}

0 comments on commit 52b8a39

Please sign in to comment.