-
Notifications
You must be signed in to change notification settings - Fork 3
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
In the module resolution playground app the remix route does not work in preview #83
Comments
Ok, I've investigated this and unfortunately this is a bit tricky... TLDR: preview is correct in throwing, dev is correct in not throwing and I am not sure if we can align the two 😓 The issue is caused by this
The problem here is that this In dev, we never encounter this module as an actual ES module, since, based on the environment API, run it through vite-plugin-cloudflare/packages/vite-plugin-cloudflare/src/runner/module-runner.ts Line 52 in c5667eb
And in this way the issue of this operation being at the top level of a dynamically imported module disappears, so here it is somewhat correct that the error is not thrown... So unfortunately I think there is very little we can do about this (besides obviously removing the I will check with the runtime team to see if there is any way for us to trigger this error inside |
Nice work getting to the bottom of this! On the plus this shouldn't happen for users with this |
It just occurred to me that if the dev behaviour was altered here to match production then this would create other problems for us. Currently, despite #64, we are able to use the HMR WebSocket at the top level of a module because this restriction is not enforced (see here for example - https://github.com/flarelabs-net/vite-plugin-cloudflare/blob/main/playground/hot-channel/src/index.ts). If this was changed then we wouldn't be able to use HMR at all so I think the current tradeoff is preferable. |
What code here would have issues with the restriction?
Yes that's a worry I have too, so as I mentioned in my workerd issue I think we should have a way to enable (if possible) this isolation and not to always enforce it, so that we can use potentially apply it only when appropriate |
Wouldn't top-level code that uses a WebSocket (i.e. |
I think that but this is a good point, if the code was isolated I wonder if the module would even get access to |
It would not. |
And to be certain, it's not actually possible to monkey patch console.log(globalThis.import) // undefined
globalThis.import = { meta: { hot: true }, };
console.log(globalThis.import.meta === import.meta); // false
console.log(import.meta);
console.log(global.import.meta); The Also, |
@jasnell yes, sorry such a stupid mistake on my part 😓 🙇 🤦 The gist of this in any case is that vite injects this So the question is wether the |
Yep. It's because, like I said, |
Ok, so, in our plugin we can't really cause modules not to have access to Thanks a bunch for checking this and sorry for the inconvenience @jasnell 🙏 🙇 |
If you run the module resolution playground app in dev mode everything seems to be working fine
But if you run it in preview mode and fetch from
/third-party/remix
you get the following error:We should properly investigate why this happens and see if/how we can address this.
Ideally the app should prevent the exact same behavior in dev and preview.
The text was updated successfully, but these errors were encountered: