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): add workspace dependencies to transpilePackages automatically #16774

Merged
merged 1 commit into from
May 4, 2023

Conversation

jaysoo
Copy link
Member

@jaysoo jaysoo commented May 4, 2023

There are issues with Next.js not transpiling workspace libraries (i.e. packages with aliases in tsconfig). You can see this problem even without Nx, where you have to manually specify transpilePackages if you use aliases.

See: https://github.com/jaysoo/next-with-libs/tree/no-nx

This PR adds a feature where we will automatically add those packages for the user since we know they need to be specified anyway.

Note: This only applies if the user is not using the apps/libs setup.

Current Behavior

Expected Behavior

Related Issue(s)

Fixes #16658

@vercel
Copy link

vercel bot commented May 4, 2023

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
nx-dev ✅ Ready (Inspect) Visit Preview 💬 Add feedback May 4, 2023 9:19pm

@jaysoo jaysoo changed the title fix(nextjs): add workspace dependencies to transpilePackages automati… fix(nextjs): add workspace dependencies to transpilePackages automatically May 4, 2023
@@ -204,6 +207,22 @@ function withNx(
dependencies = result.dependencies;
}

// For Next.js 13.1 and greater, make sure workspace libs are transpiled.
forNextVersion('>=13.1.0', () => {
Copy link
Member Author

Choose a reason for hiding this comment

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

Added a util function that will us to support different configuration that are introduced in different Next.js versions.

updatePaths(dependencies, paths);
return paths;
}

function readPaths(tsConfig: string | ts.ParsedCommandLine) {
Copy link
Member Author

Choose a reason for hiding this comment

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

Moved this to ts utils since it's not specific to buildable libs.

@jaysoo jaysoo force-pushed the fix/issue-16658 branch from f8633ac to b047ba5 Compare May 4, 2023 17:50
@jaysoo jaysoo marked this pull request as ready for review May 4, 2023 17:54
@jaysoo jaysoo requested review from nartc and xiongemi as code owners May 4, 2023 17:54
@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 May 10, 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.

Module parse failed: Unexpected token (24:7)
3 participants