Skip to content
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

Closed
wants to merge 5 commits into from

Conversation

yavorsky
Copy link
Member

This PR is intended to fix 2 issues:

  1. For now, if you are ignoring presets option in 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 or babel option in package.json file.
  2. babel-brunch ignore files with jsx/es6 extensions unless it finds react preset in presets from brunch-config. Again, if you are using configuration from .baberc/package.json even with react preset, plugin won't catch it and will observe only .js files.

Proposed solution:

  1. Make js/jsx/es6 pattern static.
  2. Remove default presets. For now, many people can use babel-brunch without configuration with default presets and we must allow this enhancement only with 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.
  3. If users are using plugin with empty babel configuration and without lookupConfigs option - warn them to add presets they need.
  4. Warn people using ES6to5 option and to change it to babel.

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.

@@ -83,5 +106,6 @@ class BabelCompiler {
BabelCompiler.prototype.brunchPlugin = true;
BabelCompiler.prototype.type = 'javascript';
BabelCompiler.prototype.extension = 'js';
Copy link
Contributor

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 = {};
Copy link
Contributor

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 &&
Copy link
Contributor

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) => {
Copy link
Contributor

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) {
Copy link
Contributor

@shvaikalesh shvaikalesh Dec 27, 2016

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

@yavorsky yavorsky mentioned this pull request Jan 23, 2017
@shvaikalesh
Copy link
Contributor

I believe this was superseded by #49

@paulmillr paulmillr closed this Feb 15, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants