What this thread does
Do first: put the failing Node-compatible dependency's exact package name in ssr.external and remove its unnecessary ssr.noExternal rule before comparing dev and production behavior.
Short answer
For ReferenceError: exports is not defined, first locate the evaluator and dependency entry. As of November 2026, current Vite docs externalize dependencies by default, except linked dependencies. Transformation is needed when a dependency uses uncompiled Vite-specific features (SSR guide). The historical exports-alias defect in GrygrFlzr's March 18, 2021 report was addressed by PR 8430, merged June 18, 2022. Do not diagnose every present-day failure as that old bug: inspect the exact file and final configuration.
Choose / don't choose
- Externalize: choose for a linked dependency by passing its name to ssr.external (options).
- Transform: choose
ssr.noExternalfor an actual transformation requirement; don't usetruemerely to make all dependency loading uniform (guide). - Framework-owned pipeline: inspect plugin-added SSR configuration and the failing output before changing application imports. mlavesther's October 13, 2026 report shows plugin-inlined CommonJS creating a different ESM export failure; it is not evidence that all CommonJS must be externalized.
Not for: Vite browser dependency-cache failures; see vite-504-outdated-optimize-dep-rebuild-cache.
Settings that matter
| Setting or flag | Value / default | Applies to | Source |
|---|---|---|---|
ssr.external | String array or true; pass a linked dependency’s name to externalize it | Current Vite SSR options | options |
ssr.noExternal | Remove the affected package when no transform is required; accepts string, regexp, array or true | Current Vite SSR options | options |
ssr.external vs ssr.noExternal | Explicit external array entries win over noExternal entries, including true; when both are boolean true, noExternal wins | Current Vite SSR options | options |
ssr.target | Default 'node'; 'webworker' is the other build target | Current Vite SSR options | options |
ssr.resolve.mainFields | package conditional exports takes precedence | Current Vite SSR resolution | options |
Order of operations
1. Locate the first dependency file containing the unbound exports/module reference. Identify whether it was evaluated by Node or Vite's module runner; inspect the dependency's selected entry, package format and framework/plugin transformations (guide, historical report). 2. Remove its explicit noExternal entry. Explicit dependencies in the ssr.external array can still be externalized. By default, only linked dependencies are not externalized; pass a linked dependency’s name to ssr.external to externalize it (options). 3. Compare the same import in SSR development and the emitted server build. Reproduce any required dependency transforms before externalizing the rest of the graph (guide). 4. The report says CommonJS interop rewrites the require call as a default import, while @sentry/core stays external and ESM-only (Sentry report).
Known failures and fixes
| Error (short quote) | Cause | Fix | Source |
|---|---|---|---|
ReferenceError: exports is not defined | The historical report concerns bundling SSR modules using a CommonJS exports alias | Inspect the selected entry and evaluator | 2021 report, merged fix, current options |
does not provide an export named 'default' | In @sentry/react-router 11, build-time instrumentation inlined CommonJS that default-imports @sentry/core (issue closed 19 Oct 2026; PR 25359 released in 11.9.0) | Inspect the generated import and owning plugin's fix; external/noExternal is not a universal interop repair | 2026 report |
Missing
- No claim that the original exports-alias bug persists in the current stable release, and no universal dependency-name list: choose names from the actual failing graph.
- This Node-loading route does not apply unchanged to a worker runtime without Node's CommonJS loader.
Checked
2026-11-12; current Vite SSR guide/options, original issue, dated merged PR and dated Sentry report read. No SSR application started or built.
Started from a post by @Vite, packaged by the editor. Original post