Skip to content

Commit 7ab924c

Browse files
authored
fix(preview-server): typescript automatically being installed (#2677)
1 parent e25aaad commit 7ab924c

File tree

4 files changed

+16
-9
lines changed

4 files changed

+16
-9
lines changed

.changeset/tricky-meals-hope.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"@react-email/preview-server": patch
3+
---
4+
5+
fix unwanted dependency installation when typescript's not installed

packages/preview-server/next.config.ts renamed to packages/preview-server/next.config.mjs

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
1-
import type { NextConfig } from 'next';
2-
3-
const nextConfig: NextConfig = {
1+
/**
2+
* @type {import('next').NextConfig}
3+
*/
4+
const nextConfig = {
45
serverExternalPackages: ['esbuild'],
56
// Noticed an issue with typescript transpilation when going from Next 14.1.1 to 14.1.2
67
// and I narrowed that down into this PR https://github.com/vercel/next.js/pull/62005

packages/preview-server/tsconfig.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,8 @@
4040
"**/*.ts",
4141
"**/*.tsx",
4242
".next/types/**/*.ts",
43-
".next/dev/types/**/*.ts"
43+
".next/dev/types/**/*.ts",
44+
"next.config.mjs"
4445
],
4546
"exclude": [".next", "dist", "node_modules"]
4647
}

packages/react-email/src/commands/build.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -76,11 +76,11 @@ const setNextEnvironmentVariablesForBuild = async (
7676
builtPreviewAppPath: string,
7777
) => {
7878
const nextConfigContents = `
79-
const path = require('path');
79+
import path from 'path';
8080
const emailsDirRelativePath = path.normalize('${emailsDirRelativePath}');
8181
const userProjectLocation = '${process.cwd().replace(/\\/g, '/')}';
8282
/** @type {import('next').NextConfig} */
83-
module.exports = {
83+
const nextConfig = {
8484
env: {
8585
NEXT_PUBLIC_IS_BUILDING: 'true',
8686
EMAILS_DIR_RELATIVE_PATH: emailsDirRelativePath,
@@ -95,12 +95,12 @@ module.exports = {
9595
experimental: {
9696
webpackBuildWorker: true
9797
},
98-
}`;
98+
}
9999
100-
await fs.promises.rm(path.resolve(builtPreviewAppPath, './next.config.ts'));
100+
export default nextConfig`;
101101

102102
await fs.promises.writeFile(
103-
path.resolve(builtPreviewAppPath, './next.config.js'),
103+
path.resolve(builtPreviewAppPath, './next.config.mjs'),
104104
nextConfigContents,
105105
'utf8',
106106
);

0 commit comments

Comments
 (0)