Skip to content

Commit

Permalink
Revert "more generic workaround for rollup/rollup-plugin-commonjs#105"
Browse files Browse the repository at this point in the history
This reverts commit 18701d2.
  • Loading branch information
jochenberger committed Sep 11, 2017
1 parent 4dab887 commit e903416
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 12 deletions.
12 changes: 12 additions & 0 deletions rollup/react-select.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,15 @@
import Select from 'react-select';
import React from 'react';

function defaultChildren (props) {
return (
<Select {...props} />
);
};

// work around https://github.com/rollup/rollup-plugin-commonjs/issues/105,
// https://github.com/JedWatson/react-select/issues/1517,
// https://github.com/JedWatson/react-select/pull/1741
Select.Async.defaultProps.children = defaultChildren;

export default Select;
14 changes: 2 additions & 12 deletions rollup/rollup.config.react-select.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,25 +24,15 @@ export default {
replace({
'propTypes: {': 'propTypes: process.env.NODE_ENV === \'production\' ? {} : {'
}),

{
transform: (source,id)=>{
let transformedSource = source;

// work around https://github.com/rollup/rollup-plugin-commonjs/issues/105,
// https://github.com/JedWatson/react-select/issues/1517,
// https://github.com/JedWatson/react-select/pull/1741
if(id[0] === '/' && (id.endsWith('AsyncCreatable.js')||id.endsWith('Async.js'))){
transformedSource = transformedSource.replace(/_Select2\['default'\]/g, "require('./Select')");
}

if (isProduction){
transformedSource = transformedSource.replace(/\.propTypes =/g, '.propTypes = (process.env.NODE_ENV === \'production\') ? {} :');
let transformedSource = source.replace(/\.propTypes =/g, '.propTypes = (process.env.NODE_ENV === \'production\') ? {} :');
transformedSource = transformedSource.replace(/var propTypes = /g, 'var propTypes = true ? null : ');
transformedSource = transformedSource.replace(/var stringOrNode = /g, 'var stringOrNode = true ? null : ');
return transformedSource;
} else {
return transformedSource;
return source;
}
}
},
Expand Down

0 comments on commit e903416

Please sign in to comment.