Use node builtin module within prerender
See original GitHub issueIn twind we are using async_hooks
to support async renders. As i understand wmr the prerender bundles are used only on server side. Would it be possible to support builtin modules for prerender?
Not working example
import {executionAsyncId, createHook} from "async_hooks";
The build fails with:
Could not load async_hooks (imported bynpm/twind@0.11.2/server/server.js): Error: async_hooks is a Node built-in - WMR does not polyfill these
Current workaround: Using node:
prefix
import {executionAsyncId, createHook} from "node:async_hooks";
The works but leads to the following warning:
'node:async_hooks' is imported bynpm/twind@0.11.2/server/server.js, but could not be resolved – treating it as an external dependency
Issue Analytics
- State:
- Created 3 years ago
- Comments:12 (1 by maintainers)
Top Results From Across the Web
Node.js Built-in Modules - W3Schools
Node.js has a set of built-in modules which you can use without any further installation. Here is a list of the built-in modules...
Read more >prerender-node - npm
Prerender is perfect for Angular SEO, React SEO, Vue SEO, and any other JavaScript framework. This middleware intercepts requests to your Node.
Read more >Server-Side Rendering - Vite
Vite provides built-in support for server-side rendering (SSR). The Vite playground contains example SSR setups for Vue 3 and React, which can be...
Read more >Polyfill Node.js built-in modules with Vite - Medium
A build command that bundles your code with Rollup, pre-configured to output highly optimized static assets for production. It's very similar to Snowpack...
Read more >How to implement SEO in applications made in Javascript
The crawler never knows that you are using Prerender.io since the ... manager for Node.js applications with a built-in load balancer.
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Thanks. I’ll be using the workaround then.
FYI: I created a tiny Preact WMR plugin to improve Twind’s hydration performance (i.e. post-prerender / static SSR):
https://github.com/tw-in-js/typescript-plugin/issues/7
On a related note, I look forward to seeing the outcome of this work:
https://github.com/preactjs/wmr/pull/400 https://github.com/preactjs/wmr/pull/169
😃