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.

Web builds should polyfill node libraries

See original GitHub issue

Currently building a nodejs project that the path module:

The web output (esm/web.js) currently has this import:

...
// Generated with Packemon: https://packemon.dev
// Platform: browser, Support: current, Format: esm
import { relative, dirname, join, posix, resolve, basename, isAbsolute } from 'path';
...

This first of all breaks parsing as browsers do not like non relative import paths (Uncaught TypeError: Failed to resolve module specifier "path". Relative references must start with either "/", "./", or "../")

It also is not a valid import as the path module library is not available in browsers. It would great if it could “polyfill” / “shim” the path module similar to webpack for web builds

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:8 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
milesjcommented, Jan 20, 2021

This would solve the problem and support more than path. However, need to wait for an official release. https://github.com/snowpackjs/rollup-plugin-polyfill-node

0reactions
milesjcommented, Feb 9, 2021

Awesome, glad to hear!

Read more comments on GitHub >

github_iconTop Results From Across the Web

How to polyfill node core modules in webpack 5 - Alchemy
In this tutorial, you'll learn how to polyfill node core modules in webpack version 5 and above using the react-app-rewired package, ...
Read more >
How to Polyfill node core modules in webpack 5
Install the needed pollyfills.(do an initial build of your application and it will tell you.) Modify node_modules/react-scripts/config/webpack.
Read more >
v5 used to include polyfills for node.js core modules by default
Package maintainers should ideally build node or browser specific bundles. Again this is my personal view I support the move in Webpack, ...
Read more >
How to polyfill node core modules in webpack - DevDojo
In this tutorial you will learn how to polyfill node core modules in ... gain access to tools that will help you build...
Read more >
Polyfilling a JavaScript library the right way | by Lee Cheneler
I recently wrote a post about polyfilling a web app (which you can read here) and ... you should always polyfill JavaScript libraries...
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