question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Use node builtin module within prerender

See original GitHub issue

In 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:closed
  • Created 3 years ago
  • Comments:12 (1 by maintainers)

github_iconTop GitHub Comments

1reaction
sastancommented, Jan 9, 2021

Thanks. I’ll be using the workaround then.

0reactions
danielweckcommented, Mar 11, 2021

Your rollup plugin idea is a great idea! And it got me thinking if we could create a rollup plugin that would add the node: prefix to all prerender dependencies. What do you think?

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

😃

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found