-
-
Notifications
You must be signed in to change notification settings - Fork 38
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix bugs when using .babelrc, and babel option in package.json #48
Conversation
@@ -83,5 +106,6 @@ class BabelCompiler { | |||
BabelCompiler.prototype.brunchPlugin = true; | |||
BabelCompiler.prototype.type = 'javascript'; | |||
BabelCompiler.prototype.extension = 'js'; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
pattern
has precedence over extension
. Let's remove extension
logger.warn(`${warning}`); | ||
} | ||
}; | ||
|
||
class BabelCompiler { | ||
constructor(config) { | ||
if (!config) config = {}; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's remove this line.
logger.warn(`${warning}`); | ||
} | ||
}; | ||
|
||
class BabelCompiler { | ||
constructor(config) { | ||
if (!config) config = {}; | ||
const options = config.plugins && |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
const options = config.plugins.babel || config.plugins.ES6to5 || {};
while we at it
@@ -15,20 +20,39 @@ const prettySyntaxError = (err) => { | |||
} | |||
}; | |||
|
|||
const warnIf = (condition, warning) => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's drop this helper.
opts.sourceMap = !!config.sourceMaps; | ||
if (!opts.presets) opts.presets = ['es2015', 'es2016']; | ||
if (!opts.presets || opts.presets.length === 0) { | ||
if (!config.lookupConfigs) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's check babelrc
, package.json
's babel
field and lastly, dependencies
and devDependencies
of package.json
I believe this was superseded by #49 |
This PR is intended to fix 2 issues:
brunch-config
file or just set it as an empty array, babel-brunch will automatically set es2015, es2016 presets. It causes conflicts if you keep your babel config in .babelrc orbabel
option in package.json file.Proposed solution:
js/jsx/es6
pattern static.config.lookupConfigs = true
to prevent crashes . It would add the ability to use people babelrc and package.json configs, but must prevent other users' incomprehension.lookupConfigs
option - warn them to add presets they need.ES6to5
option and to change it tobabel
.So after these changes, we will protect users from crashes and at the same time add the ability to use babelrc + pckg.json configuration normally by providing
lookupConfigs
option.