Skip to content

fix(init): write ESM config files in CommonJS packages - #970

Merged
cpojer merged 1 commit into
mainfrom
fix/init-commonjs-vite-config
Nov 29, 2026
Merged

cpojer merged 1 commit into
mainfrom
fix/init-commonjs-vite-config

Conversation

@hyfdev

@hyfdev hyfdev commented Nov 29, 2026 •

Copy link
Copy Markdown
Contributor

In a package with "type": "commonjs", which npm init -y writes, the React, Vue, Svelte and Solid starters from void init fail in dev, build and preview:

Error: Failed to resolve "@void/svelte/plugin". This package is ESM only but it was tried to load by `require`.

In these packages, the starters now use vite.config.mts, and all four work.

An inferred env schema goes to env.mts there, because void env check can't load env.ts (Cannot use import statement outside a module).

When sourceDir is set, the inferred schema now goes there, where Void reads it, instead of to a root file Void ignores.

The warning from #176 to add "type": "module" is removed, because it only showed after the Vite config had loaded as ESM, and those builds work.

@cloudflare-workers-and-pages

cloudflare-workers-and-pages Bot commented Nov 29, 2026 •

Copy link
Copy Markdown

🚀 Deploying Preview to Cloudflare 🚀

Preview URL: https://fix-init-commonjs-vite-config-void-cloud.voidzero-docs.workers.dev (commit 17e6c65)

This URL reflects your latest Preview deployment

Preview Deployments by commit

Status Deployment URL Commit Updated (UTC) See this deployment's details
  • Build: Success ✅
  • Deployment: Success ✅

View logs ↗
https://8ef5d7cb-void-cloud.voidzero-docs.workers.dev 17e6c65 2026-11-29T01:06:49.435Z Visit the dashboard ↗

@hyfdev
hyfdev marked this pull request as ready for review November 29, 2026 01:41
Copilot AI balanced review requested due to automatic review settings November 29, 2026 01:41

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Copilot was unable to review this pull request because the user who requested the review has insufficient remaining quota. Try requesting a review at a lower effort level.

An organization owner can choose the repository organization as the billing source for reviews requested by members with a paid Copilot license. Learn about Copilot code review billing. Review the Copilot code review billing settings.

@cpojer cpojer left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Nice fix!

@cpojer
cpojer merged commit e07eedd into main Nov 29, 2026
22 checks passed
@cpojer
cpojer deleted the fix/init-commonjs-vite-config branch November 29, 2026 05:33
cpojer pushed a commit that referenced this pull request Nov 29, 2026
Every dev, build and preview of a new Svelte starter prints:

```
[vite-plugin-svelte] no Svelte config found at /path/to/app - using default configuration.
```

The starter now includes a `svelte.config.mjs` that exports `{}`, so the
notice goes away and the compiler options stay the same.

An unedited copy of this config doesn't stop `void init` from
scaffolding in an otherwise empty directory.

Builds on #970, which fixes starters in CommonJS packages.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants