Open aaronadamsCA opened 1 month ago
We require Node v18+ across all of our packages (e.g. https://github.com/remix-run/remix/blob/main/packages/remix-react/package.json#L50), so I don't think supporting Node16
resolution makes sense for us. Closing, but if you think there's a reason to support Node16 resolution on Node 18+, let me know!
These module resolution modes are for all modern Node.js versions, not for old ones.
Per the TypeScript docs:
node16
,nodenext
These modes reflect the module resolution behavior of Node.js v12 and later. (
node16
andnodenext
are currently identical, but if Node.js makes significant changes to its module system in the future,node16
will be frozen whilenodenext
will be updated to reflect the new behavior.)
For context, moduleResolution: "NodeNext"
is compatible with, but stricter than, moduleResolution: "Bundler"
. Its more accurate type resolution behaviour has revealed all kinds of type import problems in the ecosystem, like packages using the same definition file for ESM and CommonJS entry points (which was a no-no from the start).
Honestly, Vite probably screwed up here by shipping a CommonJS entry point with no types. There are much better ways to deprecate an entry point!
But I think you can fix this with a TypeScript 5.3 feature that should let you import Vite's ESM types from your Vite plugin's CommonJS package:
Reproduction
typescript-eslint playground
System Info
Used Package Manager
pnpm
Expected Behavior
Switching TypeScript to
Node16
orNodeNext
module resolution should not affect the return type ofcloudflareDevProxyVitePlugin
.Actual Behavior
The
Plugin
type returned bycloudflareDevProxyVitePlugin()
doesn't exist.What I think is happening:
@remix-run/dev
is a CommonJS package.Node16
module resolution, TypeScript transitively resolves Vite's CJS types, wherePlugin
doesn't exist.Thankfully it's easy to work around.
I'm not sure if this would get better or worse once Vite v6 goes ESM-only, but hopefully React Router v7 can ship an ESM Vite plugin before then so we won't need to find out!