-
-
Notifications
You must be signed in to change notification settings - Fork 355
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
Cannot resolve console [Building for Cloudflare Workers] #129
Comments
This is also reproducible in the examples/cloudflare-workers example:
|
|
I've just confirmed that I run into the same issue with
|
I will have a look |
I can reproduce. It's webpack.
@frandiox Maybe you have seen this |
Vite will ship a new feature this week that will allow us to get rid of webpack altogether. |
In the meantime; is someone up for digging into this webpack error? I'm tempted to wait until we can remove Webpack entirely. ETA this week. |
@brillout Thanks for checking on this. What is the feature that's coming out for Vite this week? |
This one: vitejs/vite#4490 |
@brillout hmm, no, i don't recall seeing that error in Vitedge 🤔 |
Fix released in Thanks @frandiox @marshallswain. |
I do run into the same issue about the window - #129 (comment)
I've updated my test repo and that's how far i went. Shall I make a new issue? |
@hrgui You sure it has something to do with vite-plugin-ssr? It seems more CF Worker related. (It actually makes sense: |
I'll dig into it some more - it has to do with I am suspecting its one of these: getPageFile=t.getPageFiles=void 0;const a=n(1),i=n(0);let r,o;async function s(e){if(o){const e=a.getSsrEnv();r&&e.isProduction||(r=await o()),i.assert(i.hasProp(r,".page"))}i.assert(i.hasProp(r,".page"));return Object.entries(r[e]).map(([e,t])=>({filePath:e,loadFile:t}))}!function(){const t=Symbol(),n=i.isNodejs()?e:window;i.assert(!n[t]),n[t]=!0}(),t.setPageFiles=function(e){i.assert(i.hasProp(e,".page")),r=e},t.isPageFilesSet=function(){return!!r},t.setPageFilesAsync=function(e){o=e},t.getPageFiles=s,t.getPageFile=async function(e,t){i.assert(!t.includes("\\"));const n=await s(e),a=function(e,t){if(0===(e=e.filter(({filePath:e})=>e.startsWith(t+".page."))).length)return startsWith("/")||e.startsWith("http")||e.startsWith("./"),t+"Wrong `base` value `"+e+"`; `base` should start with `/`, `./`, or `http`.")}},function(e,t){var n;n=function(){return this}();try{n=n||new Function("return this")()}catch(e){"object"==typeof window&&(n=window)}e.exports=n},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.projectInfo=void 0;t.projectInfo={name:"vite-plugin-ssr",version:"0.2.6",npmPackageName:"vite-plugin-ssr", I was able to reproduce this with the cloudflare workers example in this repo also after updating to 0.2.6. |
Your error
is a runtime error. So yes You can try to add You can then try to add |
I see. I just copied the worker example from https://github.com/brillout/vite-plugin-ssr/blob/master/examples/cloudflare-workers/worker/ssr.js#L1-L20. When I changed ssr.js to this: // import { createPageRender } from "vite-plugin-ssr";
// We load `importBuild.js` so that the worker code can be bundled into a single file
// import "../dist/server/importBuild.js";
export { handleSsr };
const renderPage = () => null;
async function handleSsr(url) {
const pageContext = { url };
const result = await renderPage(pageContext);
if (result.nothingRendered) {
return null;
} else {
return new Response(result.renderResult, {
headers: { "content-type": "text/html" },
status: result.statusCode,
});
}
} It is able to be deployed, but I need to figure out what about these three lines are causing window to be evaluated in runtime: import { createPageRender } from "vite-plugin-ssr";
// We load `importBuild.js` so that the worker code can be bundled into a single file
import "../dist/server/importBuild.js";
export { handleSsr };
const renderPage = createPageRender({ isProduction: true }) I'll report back when I get more info. Cloudflare workers are hard to debug. update 08/10 10:30 AM PST Even after removing all update 08/10 10:33 AM PST When hardcoding |
@hrgui Nice digging 👌 |
In my case, the behavior of the IDE led to this error. import console from 'console'; I then spent a lot of time to understand what happened. I hope my comment saves someone some energy and nerves) |
@Aleksandr-JS-Developer Good to know, thanks for sharing 💚. |
Following the Cloudflare Workers example, upon running
build:worker
, I get this error:Here's a test repo: https://github.com/hrgui/pokedex-vite-plugin-ssr
The text was updated successfully, but these errors were encountered: