dnt icon indicating copy to clipboard operation
dnt copied to clipboard

import meta ponyfill isn't compatible with frontend only npm packages

Open MirKml opened this issue 4 months ago • 0 comments

When I use some import.meta stuff e.g. import.meta.url for frontend only npm package, dnt adds ponyfill wich is for node.js. It has imports like import { createRequire } from "node:module", import { fileURLToPath, pathToFileURL } from "node:url", import { dirname } from "node:path";

Webpack (and other bundlers I think) has serious trouble with such npm package. Mostly it cannot be compiled, bundled and ends with errors like

ERROR in node:module
#14 33.40 Module build failed: UnhandledSchemeError: Reading from "node:module" is not handled by plugins (Unhandled scheme).
#14 33.40 Webpack supports "data:" and "file:" URIs by default.
#14 33.40 You may need an additional plugin to handle "node:" URIs.

It's highly desired to use polyfills, ponyfills conditionally (#471) .

MirKml avatar Aug 26 '25 10:08 MirKml