Skip to content

Conversation

@jakubrohleder
Copy link
Contributor

Recently I've been fiddling a lot with multiple approaches to styles. By accident I've discovered a small bug that this pull request is fixing.

Babel docs allows two type of plugin syntax: string or an array with options e.g.

{
  "plugins": [
    "add-module-exports",
    ["css-in-js", { "vendorPrefixes": true, "bundleFile": "public/bundle.css" }]
  ]
}

The second syntax caused an error, as normalization casts array to string.

plugins.forEach(plugin => {
normalizedConfig.plugins.push(resolvePlugin(plugin, directory, 'plugin'))
let normalizedPlugin
console.log(plugin, isArray(plugin))
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

console.log slipped in

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

my bad :)

@KyleAMathews
Copy link
Contributor

LGTM, @benstepp?

@benstepp
Copy link
Contributor

👍

Now that I'm looking at the whole range of options Babel let's you use, we should probably Object.assign the normalized plugins/presets with the user's .babelrc rather than just creating a new object.

@KyleAMathews
Copy link
Contributor

@jakubrohleder what do you think about @benstepp's idea?

@jakubrohleder
Copy link
Contributor Author

@KyleAMathews Sorry for late response I've had quite a busy weekend. I completely agree with @benstepp idea of using Object.assign(), but as far as I see it is already implemented in #294

@benstepp
Copy link
Contributor

Yeah I needed it when supporting cacheDirectory. This PR looks great now.

@KyleAMathews
Copy link
Contributor

@jakubrohleder I'll still merge this PR then Ben's over it so you get the commit credit as this was your initiative after all. And no worries about the slow reply! We're all volunteers here :-) Thanks!

@KyleAMathews KyleAMathews merged commit f7b62a4 into gatsbyjs:master May 23, 2016
@KyleAMathews
Copy link
Contributor

@jakubrohleder @benstepp so... I might of merged things together wrong. I removed the

if (isArray(plugin)) {
  normalizedPlugin = [resolvePlugin(plugin[0], directory, 'plugin'), plugin[1]]
} else {
  normalizedPlugin = resolvePlugin(plugin, directory, 'plugin')
}

stuff when merging in Ben's object-assign addition but now the babel config tests broke. Was I supposed to have left the above code in?

@benstepp
Copy link
Contributor

benstepp commented May 23, 2016

Leave the above in (also the lodash import). It's the change that support the babel plugin configs.

npm run test of the current master 6d79282 still pass for me.

@KyleAMathews
Copy link
Contributor

Ok, thanks. Restored these changes in f77efe6

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.

3 participants