Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion packages/create-mail/generators/package.json.mustache
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
"jsx-email": "^2.0.0"
},
"devDependencies": {
"react": "^19.1.0"{{{ typeDep }}}
"react": "^19.1.0",
"react-dom": "^19.1.0"{{{ typeDep }}}
}
Comment on lines 14 to 17

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

The scaffold template now places {{{ typeDep }}} only on react-dom. If typeDep conditionally injects additional dev deps (e.g., @types/react/@types/react-dom) or toggles formatting, attaching it to only the second entry can be brittle: it may rely on template expansion producing valid commas/newlines in all cases. It’s safer to keep template conditionals independent of a specific dependency line (or ensure the conditional itself includes its own leading comma/newline).

Suggestion

To reduce coupling between typeDep and the react-dom line, consider moving {{{ typeDep }}} onto its own line (and ensure it includes any needed leading comma/newline), e.g.:

"devDependencies": {
  "react": "^19.1.0",
  "react-dom": "^19.1.0"{{{ typeDep }}}
}

If typeDep does not include its own leading comma, change it to do so, or restructure like:

"react-dom": "^19.1.0"{{{ typeDep }}}

(where typeDep expands to ,\n "@types/react": ... etc.).

Reply with "@CharlieHelps yes please" if you’d like me to add a commit that refactors the template to make the conditional insertion more robust.

}
17 changes: 17 additions & 0 deletions test/cli/create-mail.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,23 @@ describe('create-mail', async () => {

expect(plain).toMatchSnapshot();

type PackageJson = {
dependencies?: Record<string, string>;
devDependencies?: Record<string, string>;
};

const packageJson = JSON.parse(
await readFile(join(__dirname, '.test/new/package.json'), 'utf8')
) as PackageJson;

expect(packageJson.devDependencies).toMatchObject({
react: expect.any(String),
'react-dom': expect.any(String)
});

expect(packageJson.dependencies ?? {}).not.toHaveProperty('react');
expect(packageJson.dependencies ?? {}).not.toHaveProperty('react-dom');

const contents = await readFile(join(__dirname, '.test/new/templates/email.tsx'), 'utf8');
expect(contents).toMatchSnapshot();

Expand Down
Loading