Skip to content

Commit

Permalink
Upgrade Next.js & enable Turbopack (#281)
Browse files Browse the repository at this point in the history
* Move next/headers to be used correctly

* Upgrade Next.js

* Enable Turbopack
  • Loading branch information
timneutkens authored Sep 26, 2024
1 parent 0a3b252 commit fcf07ca
Show file tree
Hide file tree
Showing 7 changed files with 901 additions and 835 deletions.
9 changes: 5 additions & 4 deletions apps/web/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"private": true,
"scripts": {
"build": "next build --debug",
"dev": "NODE_DEBUG=latitude:debug next dev",
"dev": "NODE_DEBUG=latitude:debug next dev --turbo",
"dev:debug": "NODE_DEBUG=latitude:debug NODE_OPTIONS='--inspect=0.0.0.0:9229' ./node_modules/.bin/next dev",
"dev:local": "USE_LOCALHOST=true pnpm run dev",
"lint": "next lint",
Expand Down Expand Up @@ -38,13 +38,14 @@
"lucia": "^3.2.0",
"monaco-editor": "^0.50.0",
"nanoid": "^5.0.7",
"next": "^14.3.0-canary.87",
"next": "15.0.0-canary.168",
"next-themes": "^0.3.0",
"nextjs-toploader": "^1.6.12",
"nprogress": "^0.2.0",
"oslo": "1.2.0",
"posthog-js": "^1.161.6",
"react": "19.0.0-rc-f994737d14-20240522",
"react-dom": "19.0.0-rc-f994737d14-20240522",
"react": "19.0.0-rc-5d19e1c8-20240923",
"react-dom": "19.0.0-rc-5d19e1c8-20240923",
"socket.io-react-hook": "^2.4.5",
"swr": "^2.2.5",
"use-debounce": "^10.0.1",
Expand Down
2 changes: 1 addition & 1 deletion apps/web/src/actions/user/logoutAction.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import { authProcedure } from '$/actions/procedures'
import { removeSession } from '$/services/auth/removeSession'
import { ROUTES } from '$/services/routes'
import { ReadonlyRequestCookies } from 'next/dist/server/web/spec-extension/adapters/request-cookies'
import { cookies as getCookies } from 'next/headers'
import { redirect } from 'next/navigation'

function removeSocketCookie({
Expand All @@ -21,7 +22,6 @@ export const logoutAction = authProcedure
.createServerAction()
.handler(async ({ ctx }) => {
removeSession({ session: ctx.session })
const { cookies: getCookies } = await import('next/headers')

const cookies = getCookies()
removeSocketCookie({ name: 'websocket', cookies })
Expand Down
2 changes: 1 addition & 1 deletion apps/web/src/actions/user/refreshWebsocketTokenAction.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,13 @@

import { verifyWebsocketToken } from '@latitude-data/core/websockets/utils'
import { setWebsocketSessionCookie } from '$/services/auth/setSession'
import { cookies } from 'next/headers'

import { authProcedure } from '../procedures'

export const refreshWebesocketTokenAction = authProcedure
.createServerAction()
.handler(async ({ ctx: { user, workspace } }) => {
const { cookies } = await import('next/headers')
const refreshWebsocketCookie = cookies().get('websocketRefresh')
const refreshToken = refreshWebsocketCookie?.value
const result = await verifyWebsocketToken({
Expand Down
2 changes: 1 addition & 1 deletion apps/web/src/services/auth/getSession.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import type { Session, User } from 'lucia'
import { cookies } from 'next/headers'

import { lucia } from '.'

Expand All @@ -7,7 +8,6 @@ export async function getSession(): Promise<
> {
// NOTE: We dynamically import the cookies function to make Nextjs happy
// Info: https://github.com/vercel/next.js/issues/49757
const { cookies } = await import('next/headers')
const sessionId = cookies().get(lucia.sessionCookieName)?.value ?? null
if (!sessionId) {
return {
Expand Down
4 changes: 1 addition & 3 deletions apps/web/src/services/auth/removeSession.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,9 @@
import { Session } from 'lucia'
import { cookies } from 'next/headers'

import { lucia } from '.'

export async function removeSession({ session }: { session: Session }) {
// NOTE: We dynamically import the cookies function to make Nextjs happy
// Info: https://github.com/vercel/next.js/issues/49757
const { cookies } = await import('next/headers')
await lucia.invalidateSession(session.id)
const sessionCookie = lucia.createBlankSessionCookie()
cookies().set(
Expand Down
2 changes: 1 addition & 1 deletion packages/web-ui/tailwind.config.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/** @type {import('tailwindcss').Config} */
module.exports = {
export default {
darkMode: ['class'],
content: ['./src/**/*.{ts,tsx}'],
theme: {
Expand Down
Loading

0 comments on commit fcf07ca

Please sign in to comment.