From 30f2e1af07cbb31b8d8e0a5a8e9dc16598551bbb Mon Sep 17 00:00:00 2001 From: Jorge Vargas Date: Wed, 15 May 2024 12:14:33 -0500 Subject: [PATCH] build: add next transpile modules to solve monorepo issues --- apps/nextjs/next.config.mjs | 9 ++++++++- apps/nextjs/package.json | 1 + libs/backend/package.json | 7 +++---- package.json | 8 +++++++- pnpm-lock.yaml | 32 +++++++++++++++++++++++++++++++- 5 files changed, 50 insertions(+), 7 deletions(-) diff --git a/apps/nextjs/next.config.mjs b/apps/nextjs/next.config.mjs index 11a0632..1ba6553 100644 --- a/apps/nextjs/next.config.mjs +++ b/apps/nextjs/next.config.mjs @@ -1,3 +1,4 @@ +import nextTranspileModules from 'next-transpile-modules'; import { join } from 'path'; import { fileURLToPath } from 'url'; @@ -20,4 +21,10 @@ const nextConfig = { }, }; -export default nextConfig; +const withTm = nextTranspileModules([ + '@libs/frontend', + '@libs/shared', + '@libs/backend', +]); + +export default withTm(nextConfig); diff --git a/apps/nextjs/package.json b/apps/nextjs/package.json index 923d031..42d3c7a 100644 --- a/apps/nextjs/package.json +++ b/apps/nextjs/package.json @@ -41,6 +41,7 @@ "eslint-config-next": "12.3.0", "jsdom": "20.0.0", "next-connect": "0.13.0", + "next-transpile-modules": "^10.0.1", "postcss": "8.4.38", "react-test-renderer": "18.2.0", "sass": "1.54.9", diff --git a/libs/backend/package.json b/libs/backend/package.json index d961f2f..b7c1c2f 100644 --- a/libs/backend/package.json +++ b/libs/backend/package.json @@ -11,15 +11,14 @@ "license": "ISC", "dependencies": { "@libs/shared": "workspace:*", + "lodash.omit": "4.5.0", + "mongodb": "4.9.1", "next": "14.2.3", "sharp": "0.33.3" }, - "peerDependencies": { - "lodash.omit": "4.5.0", - "mongodb": "4.9.1" - }, "devDependencies": { "@eslint/js": "^9.2.0", + "@types/lodash.omit": "4.5.9", "eslint": "8.57.0", "globals": "^15.2.0", "typescript-eslint": "^7.9.0", diff --git a/package.json b/package.json index ae9ba49..a333d4b 100644 --- a/package.json +++ b/package.json @@ -7,6 +7,7 @@ "license": "MIT", "private": true, "scripts": { + "build": "pnpm -r --filter='./apps/*' run build", "dev": "pnpm -r --filter='./apps/*' run dev", "lint": "pnpm -r --filter='./apps/*' --filter=''./libs/* run lint", "test": "vitest", @@ -20,5 +21,10 @@ "@types/node": "18.7.16", "typescript": "5.4.5", "vitest": "1.6.0" - } + }, + "workspaces": [ + "apps/*", + "libs/*" + ], + "packageManager": "pnpm@8.15.8" } diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 6d1ff5f..36da83a 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -93,6 +93,9 @@ importers: next-connect: specifier: 0.13.0 version: 0.13.0 + next-transpile-modules: + specifier: ^10.0.1 + version: 10.0.1 postcss: specifier: 8.4.38 version: 8.4.38 @@ -127,6 +130,9 @@ importers: '@eslint/js': specifier: ^9.2.0 version: 9.2.0 + '@types/lodash.omit': + specifier: 4.5.9 + version: 4.5.9 eslint: specifier: 8.57.0 version: 8.57.0 @@ -1528,6 +1534,12 @@ packages: '@types/lodash': 4.17.1 dev: true + /@types/lodash.omit@4.5.9: + resolution: {integrity: sha512-zuAVFLUPJMOzsw6yawshsYGgq2hWUHtsZgeXHZmSFhaQQFC6EQ021uDKHkSjOpNhSvtNSU9165/o3o/Q51GpTw==} + dependencies: + '@types/lodash': 4.17.1 + dev: true + /@types/lodash@4.17.1: resolution: {integrity: sha512-X+2qazGS3jxLAIz5JDXDzglAF3KpijdhFxlf/V1+hEsOUc+HnWi81L/uv/EvGuV90WY+7mPGFCUDGfQC3Gj95Q==} dev: true @@ -2637,6 +2649,14 @@ packages: resolution: {integrity: sha512-L18DaJsXSUk2+42pv8mLs5jJT2hqFkFE4j21wOmgbUqsZ2hL72NsUU785g9RXgo3s0ZNgVl42TiHp3ZtOv/Vyg==} dev: true + /enhanced-resolve@5.16.1: + resolution: {integrity: sha512-4U5pNsuDl0EhuZpq46M5xPslstkviJuhrdobaRDBk2Jy2KO37FDAJl4lb2KlNabxT0m4MTK2UHNrsAcphE8nyw==} + engines: {node: '>=10.13.0'} + dependencies: + graceful-fs: 4.2.11 + tapable: 2.2.1 + dev: true + /entities@4.5.0: resolution: {integrity: sha512-V0hjH4dGPh9Ao5p0MoRY6BVqtwCjhz6vI5LT8AJ55H+4g9/4vbHx1I54fS0XuclLhDHArPQCiMjDxjaL8fPxhw==} engines: {node: '>=0.12'} @@ -3696,7 +3716,6 @@ packages: /graceful-fs@4.2.11: resolution: {integrity: sha512-RbJ5/jmFcNNCcDV5o9eTnBLJ/HszWV0P73bc+Ff4nS/rJj+YaS6IGyiOL0VoBYX+l1Wrl3k63h/KrH+nhJ0XvQ==} - dev: false /grapheme-splitter@1.0.4: resolution: {integrity: sha512-bzh50DW9kTPM00T8y4o8vQg89Di9oLJVLW/KaOGIXJWP/iqCN6WKYkbNOF04vFLJhwcpYUh9ydh/+5vpOqV4YQ==} @@ -4404,6 +4423,12 @@ packages: trouter: 3.2.1 dev: true + /next-transpile-modules@10.0.1: + resolution: {integrity: sha512-4VX/LCMofxIYAVV58UmD+kr8jQflpLWvas/BQ4Co0qWLWzVh06FoZkECkrX5eEZT6oJFqie6+kfbTA3EZCVtdQ==} + dependencies: + enhanced-resolve: 5.16.1 + dev: true + /next@14.2.3(@babel/core@7.24.5)(@playwright/test@1.44.0)(react-dom@18.2.0)(react@18.2.0)(sass@1.54.9): resolution: {integrity: sha512-dowFkFTR8v79NPJO4QsBUtxv0g9BrS/phluVpMAt2ku7H+cbcBJlopXjkWlwxrk/xGqMemr7JkGPGemPrLLX7A==} engines: {node: '>=18.17.0'} @@ -5654,6 +5679,11 @@ packages: - ts-node dev: true + /tapable@2.2.1: + resolution: {integrity: sha512-GNzQvQTOIP6RyTfE2Qxb8ZVlNmw0n88vp1szwWRimP02mnTsx3Wtn5qRdqY9w2XduFNUgvOwhNnQsjwCp+kqaQ==} + engines: {node: '>=6'} + dev: true + /text-table@0.2.0: resolution: {integrity: sha512-N+8UisAXDGk8PFXP4HAzVR9nbfmVJ3zYLAWiTIoqC5v5isinhr+r5uaO8+7r3BMfuNIufIsA7RdpVgacC2cSpw==} dev: true