Skip to content
This repository has been archived by the owner on Mar 23, 2023. It is now read-only.

Fix for next@9.4.0 #55

Merged
merged 5 commits into from
May 15, 2020
Merged

Fix for next@9.4.0 #55

merged 5 commits into from
May 15, 2020

Conversation

jescalan
Copy link
Contributor

@jescalan jescalan commented May 15, 2020

Nextjs made a change to the way that babel plugins are added to the client side bundle, which caused this plugin to work for the server but not client bundles. This was a very weird error, but it should be worked out now.

Interestingly, this was a case that was not caught by our tests, which compare the server-rendered output and don't test with javascript active after hydration. It mat be worth adding a test where everything is evaluated after hydrating in the future, I have one in next-mdx-remote.

Closes #53

Copy link
Contributor

@pruett pruett left a comment

Choose a reason for hiding this comment

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

Nit, review is a bit more difficult with formatting changes

index.js Outdated
Comment on lines 58 to 74
config.module.rules = config.module.rules.map((rule) => {
if (rule.use) {
if (Array.isArray(rule.use)) {
// client babel config is different from server - this is client
if (rule.use[1] && rule.use[1].loader === 'next-babel-loader') {
if (!rule.use[1].options.plugins) rule.use[1].options.plugins = []
rule.use[1].options.plugins.push(
babelPluginFrontmatter(options, pluginOptions)
)
}
// and this is server
} else if (rule.use.loader === 'next-babel-loader') {
if (!rule.use.options.plugins) rule.use.options.plugins = []
rule.use.options.plugins.push(
babelPluginFrontmatter(options, pluginOptions)
)
}
Copy link
Contributor

Choose a reason for hiding this comment

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

🤯

Copy link
Contributor

@pruett pruett left a comment

Choose a reason for hiding this comment

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

🍒 Great sleuthing!!

@jescalan jescalan merged commit effa78a into master May 15, 2020
@jescalan jescalan deleted the je.upgrade-next-9-4 branch May 15, 2020 21:31
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Next.js 9.4 breaking error
2 participants