-
-
Notifications
You must be signed in to change notification settings - Fork 6.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Inconsistent SSR require/import paths on Windows #6080
Comments
The last version that seemed to work on Windows was Vite [
'C:\\DevTemp\\my-app\\node_modules\\solid-js\\web\\dist\\server.cjs',
'C:\\DevTemp\\my-app\\node_modules\\solid-js\\dist\\server.cjs'
]
[
'C:\\DevTemp\\my-app\\node_modules\\solid-js\\web\\dist\\server.cjs',
'C:/DevTemp/my-app/node_modules/solid-js/dist/server.cjs',
'C:\\DevTemp\\my-app\\node_modules\\solid-js\\dist\\server.cjs'
] |
Just tested recently released Best place to console.log when testing with try {
const mod = await dynamicImport(url);
//add log here to see issue
console.log(Object.keys(require.cache).filter(k => k.includes("solid-js")))
return proxyESM(mod);
} Result in
|
Tested latest Place to log is line 67508 in |
Tested latest Place to log is line 67835 in |
Tested latest Place to log is line 67835 in |
Possible hack/solution? // When an ESM module imports an ESM dependency, this hook is *not* used.
const unhookNodeResolve = hookNodeResolve(
(nodeResolve) => (id, parent, isMain, options) => {
// Fix #5709, use require to resolve files with the '.node' file extension.
// See detail, https://nodejs.org/api/addons.html#addons_loading_addons_using_require
if (id[0] === '.' || isBuiltin(id) || id.endsWith('.node')) {
return nodeResolve(id, parent, isMain, options)
}
if (parent) {
return viteResolve(id, parent.id)
}
// Importing a CJS module from an ESM module. In this case, the import
// specifier is already an absolute path, so this is a no-op.
// Options like `resolve.dedupe` and `mode` are not respected.
return normalizePath(id) // ******************* HACK adding normalizePath (need to import this from utils.ts) *********************
}
) I'm not sure quite why though as [
'C:\\DevTemp\\my-app\\node_modules\\solid-js\\web\\dist\\server.cjs',
'C:/DevTemp/my-app/node_modules/solid-js/web/dist/server.cjs',
'C:/DevTemp/my-app/node_modules/solid-js/dist/server.cjs',
'C:\\DevTemp\\my-app\\node_modules\\solid-js\\dist\\server.cjs'
] Maybe this is at least a clue for someone who understands this stuff?? |
VERY INTERESTING... It seems when BUT, if These seem to be the steps occurring with the problem example:
So the paths resolved from the SUMMARY Hopefully I've got that all straight and it makes sense to someone who knows a lot more about this stuff. |
Tested latest 2.7.7 which has same issue. Place to log is line 67846 in Although I think the most useful comment is here |
Tested latest 2.7.9 which has same issue. Place to log is line 60152 in Although I think the most useful comment is here |
you are welcome to create pull request |
Thanks - but I wouldn't know where to start. I'm just blindly trying to provide as much info as I can muster. |
Thanks @Brendan-csel for looking into this. I don't have the means to debug this, but seems to break every Solid SSR project on Windows. Which makes this a high priority for me. I will see if I can do anything to help. |
Tested latest 2.7.10 which has same issue. Place to log is line 60153 in Although I think the most useful comment is here |
Tested latest v2.8.0-beta.1 which has same issue. Place to log is line 55594 in Although I think the most useful comment is here |
This issue seems to be resolved in |
Thank you @Brendan-csel for all the testing in the issue! |
Describe the bug
The following entries appear in
require.cache
on Windows...Note the 2nd and 3rd paths above refer to the same file.
Whereas on Linux in the same project we see...
The second entry results from a
require()
call within the preceding.cjs
file. Whereas the others result from Vite calling itsdynamicImport()
function.On Windows the duplication of the second and third import above results in errors in this particular library as it is expected to run once.
These were observed by calling
console.log(Object.keys(require.cache).filter(k => k.includes("solid-js")))
in strategic locations on both OSs.Reproduction
Browse http://localhost:3000/ and observe an error (on Windows only).
Add this console log somewhere:
console.log(Object.keys(require.cache).filter(k => k.includes("solid-js")))
eg. line 67385 of
node_modules\vite\dist\node\chunks\dep-3daf770c.js
Observe the above mentioned
require.cache
entries differ from Windows to Linux.System Info
Used Package Manager
npm
Logs
No response
Validations
The text was updated successfully, but these errors were encountered: