denoland / denoland/dnt

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

Open
#474 0 comments 1 reaction 0 assignees View on GitHub
Dominant language
Rust
Stars
1.3k
Forks
49
PR merge metrics
No merged PRs in 30d

Description

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) .

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.