Closed thebuilder closed 3 years ago
I haven't tested this plugin in Vite's middleware mode.
Can you fork the master branch and setup the demo
folder with your bare bones example? That would help a ton!
I've added a server example to your demo folder: https://github.com/thebuilder/vite-tsconfig-paths/tree/bug/middleware-demo
Run yarn serve
(or node server.mjs
) to start it.
I'm guessing it should possible to write a Jest test for it, by just creating the Vite server and loading a module:
import { createServer } from "vite";
const vite = await createServer({
server: {
middlewareMode: true
}
});
await vite.ssrLoadModule("/src/entry-server.ts");
Thanks!
I've submitted a PR to vite
that fixes this.
https://github.com/vitejs/vite/pull/3080
Looks like this is resolved w/ vite@2.2.4 !
Edit: actually seems like it is still happening on production build only?
#9 41.98 vite v2.2.4 building SSR bundle for production...
#9 42.35 /app/node_modules/vite-tsconfig-paths/dist/index.js:58
#9 42.35 done(viteResolve(path, importer));
#9 42.35 ^
#9 42.35
#9 42.35 TypeError: viteResolve is not a function
#9 42.35 at /app/node_modules/vite-tsconfig-paths/dist/index.js:58:34
#9 42.35 at /app/node_modules/tsconfig-paths/lib/match-path-async.js:72:24
#9 42.35 at /app/node_modules/tsconfig-paths/lib/filesystem.js:46:9
#9 42.35 at FSReqCallback.oncomplete (fs.js:184:5)
@chrisvariety That looks unrelated, and I can't reproduce it. Please open a new issue with a repository link for reproducing it. 👍
Looks like this is resolved w/ vite@2.2.4 !
Edit: actually seems like it is still happening on production build only?
#9 41.98 vite v2.2.4 building SSR bundle for production... #9 42.35 /app/node_modules/vite-tsconfig-paths/dist/index.js:58 #9 42.35 done(viteResolve(path, importer)); #9 42.35 ^ #9 42.35 #9 42.35 TypeError: viteResolve is not a function #9 42.35 at /app/node_modules/vite-tsconfig-paths/dist/index.js:58:34 #9 42.35 at /app/node_modules/tsconfig-paths/lib/match-path-async.js:72:24 #9 42.35 at /app/node_modules/tsconfig-paths/lib/filesystem.js:46:9 #9 42.35 at FSReqCallback.oncomplete (fs.js:184:5)
@chrisvariety Are you running Windows? Got a developer running Windows that gets this issue, while the same code builds fine on my machine. Something to investigate
@thebuilder nope, Mac over here. I'll try to put together a minimal reproduction.
Interesting - Could it be an async
execution order issue?🤔
I'm running Vite dev with a custom Express server, and after upgrading
vite-tsconfig-paths
from version 2.5.1 it breaks. Seems to work if just runningvite dev
.viteResolve
is set inbuildStart
, but this function is never called. https://github.com/aleclarson/vite-tsconfig-paths/blob/master/src/index.ts#L21It breaks the moment I try to load a module using
vite.ssrLoadModule
. I've tried trim theserver.mjs
file down to the essentials:server.mjs