-
Notifications
You must be signed in to change notification settings - Fork 2.4k
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
feat(nextjs): update to Next.js 13.3.0 #16130
Conversation
The latest updates on your projects. Learn more about Vercel for Git ↗︎
|
b6c8dc3
to
e73de13
Compare
e73de13
to
bf4d78c
Compare
41d8187
to
9eea4af
Compare
9eea4af
to
af92f57
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
af92f57
to
d9abfc1
Compare
d9abfc1
to
d6a2399
Compare
8476786
to
e2ea7a4
Compare
@@ -47,6 +47,19 @@ export function createFiles(host: Tree, options: NormalizedSchema) { | |||
host.delete(`${options.projectRoot}/package.json`); | |||
} | |||
|
|||
if (options.additionalImportPaths) { | |||
for (const additionalImportPath of options.additionalImportPaths) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is just creating an empty file for additional import paths (e.g. src/server.ts
for RSC). Other generators using this generator should fill them in with more useful content.
e2ea7a4
to
e0a1650
Compare
e0a1650
to
b03383c
Compare
b03383c
to
2935d9c
Compare
2935d9c
to
a484dd4
Compare
a484dd4
to
2019f0a
Compare
if (options.additionalImportPaths) { | ||
for (const additionalImportPath of options.additionalImportPaths) { | ||
c.paths[`${options.importPath}/${additionalImportPath}`] = [ | ||
joinPathFragments( | ||
options.projectRoot, | ||
`./src/${additionalImportPath}.${options.js ? 'js' : 'ts'}` | ||
), | ||
]; | ||
} | ||
} | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't know if I'm a huge fan of having this here..
Not a big deal probably... but this currently doesn't check if those paths already exist and would just overwrite them 🤷.
I feel like we should rework this function's API to be more like addTsConfigImportPaths(tree, importPath: string, importModules: string[])
function jsLibraryGenerator(tree) {
addTsConfigPath(tree, importPath, [joinPathFragments(projectRoot, 'src/index.ts')])
addTsConfigPath(tree, joinPathFragments(importPath, 'server'), [joinPathFragments(projectRoot, 'src/server.ts')])
}
This would open us up to adding import paths which are not under src
.
We could add the new function and keep the current usages the same.. then transition them over. What do you think?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah we can do something like that.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Removed the original function updateRootTsConfig
and added addTsConfigPath
so each library generator can add the import paths that are needed. The original function wasn't named clearly to understand the intention, the new function is more specific.
For now, the new server.ts
entry is only for Next.js apps, and we can look at adding something similar to @nrwl/react:lib
later when it's more clear the direction of RSCs.
2019f0a
to
e024a2b
Compare
e024a2b
to
99f6619
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sweet!
99f6619
to
83818c3
Compare
83818c3
to
4c34f67
Compare
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. |
This PR updates the installed version of Next.js to 13.3.0
and migrates existing workspaces.We will hold off on migrating existing workspaces to 13.3 until we can put together a better migration experience for those using Storybook (they need to go to v7).
Also includes a few fixes. See below.
Use Storybook v7 for React/Next.jsStorybook v7 is stable now, and v6 is no longer maintained. Next.js 13.2 requires v7 to work, so it will be the default moving forward unless the user passes--storybook7Configuration=false
when generating Storybook config (i.e.nx g @nrwl/react:storybook-configuration --storybook7Configuration=false
).Disable type checks by default (app/layout types are incorrect)
This only applies when appDir is enabled in
next.config.js
.The Next.js type generation has a bug where the paths are wrong inside a monorepo. The PR is merged but waiting for a release (vercel/next.js#47534).
Once released we can re-enable the type-check by default. In the meantime the user can update
next.config.js
config to enable it if the patch is released before we update.Generate libraries with separate RSC entry
Add a server-only entry for libraries generated with
@nrwl/next:lib
to help with libraries that export both client and server components. So users can import client-only components using deep import path. See: #15830e.g.
Say our library
my-lib
exported both RSC and client components inindex.ts
.Then importing this in a client component will error out.
Fails:
But if we separate the two components into separate entry files.
Then importing from client entry file will work in both server and client components.
Works:
Also works:
This isn't an Nx issue because it's coming from
@next/swc
: