This repository was archived by the owner on Oct 15, 2019. It is now read-only.
File tree 4 files changed +19
-4
lines changed
4 files changed +19
-4
lines changed Original file line number Diff line number Diff line change @@ -36,4 +36,7 @@ export default {
36
36
If you use the ` es2015 ` preset, make sure you install ` es2015-rollup ` too. See
37
37
this project's own [ ` rollup.config.js ` ] [ rollup-config ] for an example.
38
38
39
+ For any presets you use in ` .babelrc ` , this module will look for one with the
40
+ same name but with a ` -rollup ` suffix.
41
+
39
42
[ rollup-config ] : https://github.com/eventualbuddha/babelrc-rollup/blob/master/rollup.config.js
Original file line number Diff line number Diff line change 42
42
},
43
43
"publishConfig" : {
44
44
"registry" : " https://registry.npmjs.org/"
45
+ },
46
+ "dependencies" : {
47
+ "resolve" : " ^1.1.7"
45
48
}
46
49
}
Original file line number Diff line number Diff line change @@ -6,7 +6,7 @@ let pkg = require('./package.json');
6
6
export default {
7
7
entry : 'src/index.js' ,
8
8
plugins : [ babel ( babelrc ( ) ) ] ,
9
- external : [ ' fs'] ,
9
+ external : Object . keys ( pkg [ 'dependencies' ] ) . concat ( [ ' fs'] ) ,
10
10
targets : [
11
11
{
12
12
dest : pkg [ 'jsnext:main' ] ,
Original file line number Diff line number Diff line change 1
1
/* @flow */
2
2
3
3
import { readFileSync } from 'fs' ;
4
+ import { sync as resolve } from 'resolve' ;
4
5
5
6
function startsWith ( string : string , prefix : string ) : boolean {
6
7
return string . lastIndexOf ( prefix , 0 ) === 0 ;
@@ -48,9 +49,7 @@ export function configWithoutModules(config: BabelConfig): BabelConfig {
48
49
if ( Object . prototype . hasOwnProperty . call ( config , key ) ) {
49
50
if ( key === 'presets' && config . presets ) {
50
51
// Replace the es2015 preset with the es2015-rollup preset.
51
- result . presets = config . presets . map (
52
- preset => preset === 'es2015' ? 'es2015-rollup' : preset
53
- ) ;
52
+ result . presets = config . presets . map ( mapPreset ) ;
54
53
} else if ( key === 'plugins' && config . plugins ) {
55
54
// Remove any explicit module plugins, e.g. es2015-modules-commonjs.
56
55
result . plugins = config . plugins . filter (
@@ -67,3 +66,13 @@ export function configWithoutModules(config: BabelConfig): BabelConfig {
67
66
68
67
return result ;
69
68
}
69
+
70
+ function mapPreset ( preset : string ) : string {
71
+ try {
72
+ // this will throw if it can't resolve it
73
+ resolve ( `babel-preset-${ preset } -rollup` ) ;
74
+ return `${ preset } -rollup` ;
75
+ } catch ( err ) {
76
+ return preset ;
77
+ }
78
+ }
You can’t perform that action at this time.
0 commit comments