Commit Graph

1 Commits

Author SHA1 Message Date
James Anderson 1d57274ba4 test(config): regression coverage for next.config runtime value shapes (#1297)
Adds 12 ported upstream fixtures as unit tests for loadNextConfig,
covering shapes not exercised by the four extension/import tests added
in #1296 (which validates the runner's resolve.extensions + commonjs()
configuration). These complement that coverage by asserting the
returned config value is actually surfaced for shapes that historically
build successfully but resolve to empty/undefined when normalisation
has gaps:

  - async default-function export (next-config-ts/async-function)
  - plain default object export (next-config-ts/export-default)
  - aliased default export, 'export { x as default }' (export-as-default)
  - mixed sibling extensions under both type:commonjs and type:module
    (next-config-ts/import-js-extensions-{cjs,esm})
  - nested-import propagation under both module-type flavours
    (next-config-ts/nested-imports-{cjs,esm})
  - Node API at module scope under type:module (next-config-ts/node-api-cjs)
  - bare-specifier CJS packages (next-config-ts/import-from-node-modules)

Originally this PR also introduced a hand-rolled cjsImportsPlugin that
used createRequire + globalThis stashing to interop CJS siblings. After
#1296 (cf20845) was refactored to reuse the existing vite-plugin-commonjs
dependency, that hand-rolled plugin became fully redundant — all 12
tests pass against main's commonjs()-based loader unchanged. Dropped
the implementation and kept the tests as additional regression
coverage.
2026-05-18 12:25:49 +01:00