Skip to content

feat(template)!: unify JS/TS templates#4229

Open
erickzhao wants to merge 26 commits into
nextfrom
template-unification
Open

feat(template)!: unify JS/TS templates#4229
erickzhao wants to merge 26 commits into
nextfrom
template-unification

Conversation

@erickzhao

@erickzhao erickzhao commented Apr 20, 2026

Copy link
Copy Markdown
Member

Having separate packages for TypeScript-based templates is a burden. You need to duplicate any bundler-related template work, which leaves our templates open to drift.

This PR attempts to reconcile the two templates variants together, and to have --typescript as an instantiation option.

The crux to this approach is that a lot of TypeScript files can be stripped by default in Node 22.13+ with node:module's stripTypeScriptTypes function.

For app code: this works great.

For bundler-specific config: This works great for Vite, since it supports TS out of the box without additional configuration. For webpack, we still need to configure additional loaders, so the bundler configurations are kept separate for JS/TS.

@github-actions github-actions Bot added the next label Apr 20, 2026
@socket-security

socket-security Bot commented May 21, 2026

Copy link
Copy Markdown

Review the following changes in direct dependencies. Learn more about Socket for GitHub.

Diff Package Supply Chain
Security
Vulnerability Quality Maintenance License
Added@​electron-forge/​plugin-webpack@​0.0.0-use.local100100100100100

View full report

@erickzhao erickzhao marked this pull request as ready for review May 22, 2026 00:14
@erickzhao erickzhao requested a review from a team as a code owner May 22, 2026 00:14
Comment thread packages/template/base/package.json Outdated
Comment thread package.json Outdated
@erickzhao erickzhao requested a review from erikian May 23, 2026 00:25
Comment thread packages/template/base/src/BaseTemplate.ts Outdated
Comment thread packages/template/base/src/BaseTemplate.ts Outdated
Comment thread packages/template/base/src/BaseTemplate.ts Outdated
Comment thread packages/external/create-electron-app/src/create-electron-app.ts
Comment thread packages/template/vite/src/ViteTemplate.ts
Comment thread packages/template/webpack/src/WebpackTemplate.ts Outdated
Comment thread packages/template/webpack/src/WebpackTemplate.ts
Comment thread vitest.config.mts Outdated
@erickzhao

Copy link
Copy Markdown
Member Author

@claude review

Comment thread packages/external/create-electron-app/src/init-scripts/find-template.ts Outdated
Comment thread packages/template/webpack/tmpl/renderer.ts Outdated
Comment thread packages/template/webpack/src/WebpackTemplate.ts
The 3-line comment explaining "TypeScript magic constants" survives
type stripping and appears in the generated JS output, referencing
declarations that no longer exist. Remove it since the declare const
lines are self-explanatory for TS users.

Co-Authored-By: Claude <svc-devxp-claude@slack-corp.com>
@erickzhao erickzhao requested a review from MarshallOfSound June 6, 2026 06:52
@erickzhao

Copy link
Copy Markdown
Member Author

@claude review

Comment thread packages/external/create-electron-app/src/init.ts Outdated
Comment thread packages/template/webpack/tmpl/main.ts
…int directive

Move the "base does not support TypeScript" rejection into
BaseTemplate.initializeTemplate (gated on the base templateDir) so it
fires regardless of how the template was resolved, including the
fully-qualified `@electron-forge/template-base` name that bypassed the
string compare in init.ts.

Switch webpack's main.ts to the ESM `import started from
'electron-squirrel-startup'` pattern that vite already uses. This removes
the `// oxlint-disable-next-line @typescript-eslint/no-require-imports`
directive that stripTypeScriptTypes preserved verbatim into the generated
JS scaffold, where the referenced rule isn't even enabled. Adds
@types/electron-squirrel-startup to the webpack TS devDeps (filtered out of
the JS variant) so `tsc --noEmit` still passes.

Co-Authored-By: Claude <svc-devxp-claude@slack-corp.com>
@erickzhao

Copy link
Copy Markdown
Member Author

@claude review

@erickzhao erickzhao dismissed erikian’s stale review June 10, 2026 02:09

comments addressed

@MarshallOfSound

Copy link
Copy Markdown
Member

@claude review

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants