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(nextjs): fix .babelrc for libraries #8075

Merged
merged 1 commit into from Jan 6, 2022

Conversation

puku0x
Copy link
Contributor

@puku0x puku0x commented Dec 9, 2021

Current Behavior

The .babelrc generated by nx g @nrwl/next:library does not use @nrwl/next/babel preset.

Expected Behavior

It should be generated with @nrwl/next/babel preset.

// Example of `nx g @nrwl/next:library --style=@emotion/styled`
{
  "presets": [
    [
      "@nrwl/next/babel",  // 👈 The preset should be changed from next/babel to @nrwl/next/babel
      {
        "preset-react": {
          "runtime": "automatic",
          "importSource": "@emotion/react"
        }
      }
    ]
  ],
  "plugins": ["@emotion/babel-plugin"]
}

Related Issue(s)

https://nrwlcommunity.slack.com/archives/C015WMB2A8P/p1639043467125800
https://nrwlcommunity.slack.com/archives/C015WMB2A8P/p1641384957180500
#6728

@vercel
Copy link

vercel bot commented Dec 9, 2021

This pull request is being automatically deployed with Vercel (learn more).
To see the status of your deployment, click below or on the icon next to each commit.

🔍 Inspect: https://vercel.com/nrwl/nx-dev/4guZpfexM8ynp18LekqM4YKsWVvy
✅ Preview: Canceled

[Deployment for 5d1c31c canceled]

@kirjai
Copy link
Contributor

kirjai commented Dec 23, 2021

i forget why we switched away from @nrwl/next/babel in favor of next/babel other than aligning ourselves closer to the default Nextjs configuration. so to be honest, i'm a bit reluctant switching back, considering that this doesn't solve any issues, it'd be done just for consistency. That's if i understood the motivation behind this PR correctly. if not - please let me know!

@jaysoo do you happen to recall why we switched away from @nrwl/next/babel, perhaps?

@zanettin
Copy link

zanettin commented Jan 5, 2022

just a side note but this also fixes the issue that custom libraries are not able to be unit tested. with the published solution you'll get this error:

    import React from "react";
    ^^^^^^

    SyntaxError: Cannot use import statement outside a module

    > 1 | export * from './lib/testlib';

@vsavkin vsavkin force-pushed the master branch 2 times, most recently from 3a99403 to 334c230 Compare January 6, 2022 18:35
@kirjai kirjai merged commit 054d4eb into nrwl:master Jan 6, 2022
@puku0x puku0x deleted the fix-next-lib-generator-nrwl-next-babel branch June 20, 2022 05:19
@github-actions
Copy link

This pull request has already been merged/closed. If you experience issues related to these changes, please open a new issue referencing this pull request.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Mar 18, 2023
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.

None yet

3 participants