FredKSchott / FredKSchott/rollup-plugin-polyfill-node

Missing polyfil when compiling to esnext

Open
#91 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
TypeScript
Stars
193
Forks
60
PR merge metrics
No merged PRs in 30d

Description

I get the following error when trying to compile a typescript library to ES modules using rollup and polyfill-node

```
[!] RollupError: node_modules/.pnpm/tslog@4.9.3/node_modules/tslog/dist/esm/runtime/nodejs/index.js (3:9): "types" is not exported by "polyfill-node.util.js", imported by "node_modules/.pnpm/tslog@4.9.3/node_modules/tslog/dist/esm/runtime/nodejs/index.js".
https://rollupjs.org/troubleshooting/#error-name-is-not-exported-by-module
node_modules/.pnpm/tslog@4.9.3/node_modules/tslog/dist/esm/runtime/nodejs/index.js (3:9)
1: import { hostname } from "os";
2: import { normalize as fileNormalize } from "path";
3: import { types, formatWithOptions } from "util";
^
4: import { formatTemplate } from "../../formatTemplate.js";
5: export default {
at getRollupError (/home/ramses/projects/github.com/golem-base/golem-base-sdk-ts/node_modules/.pnpm/rollup@4.40.1/node_modules/rollup/dist/shared/parseAst.js:285:41)
at Object.error (/home/ramses/projects/github.com/golem-base/golem-base-sdk-ts/node_modules/.pnpm/rollup@4.40.1/node_modules/rollup/dist/shared/parseAst.js:281:42)
at Module.error (/home/ramses/projects/github.com/golem-base/golem-base-sdk-ts/node_modules/.pnpm/rollup@4.40.1/node_modules/rollup/dist/shared/rollup.js:18337:28)
at Module.traceVariable (/home/ramses/projects/github.com/golem-base/golem-base-sdk-ts/node_modules/.pnpm/rollup@4.40.1/node_modules/rollup/dist/shared/rollup.js:18786:29)
at ModuleScope.findVariable (/home/ramses/projects/github.com/golem-base/golem-base-sdk-ts/node_modules/.pnpm/rollup@4.40.1/node_modules/rollup/dist/shared/rollup.js:16449:39)
at FunctionScope.findVariable (/home/ramses/projects/github.com/golem-base/golem-base-sdk-ts/node_modules/.pnpm/rollup@4.40.1/node_modules/rollup/dist/shared/rollup.js:9339:38)
at FunctionBodyScope.findVariable (/home/ramses/projects/github.com/golem-base/golem-base-sdk-ts/node_modules/.pnpm/rollup@4.40.1/node_modules/rollup/dist/shared/rollup.js:9339:38)
at MemberExpression.bind (/home/ramses/projects/github.com/golem-base/golem-base-sdk-ts/node_modules/.pnpm/rollup@4.40.1/node_modules/rollup/dist/shared/rollup.js:11042:49)
at ChainExpression.bind (/home/ramses/projects/github.com/golem-base/golem-base-sdk-ts/node_modules/.pnpm/rollup@4.40.1/node_modules/rollup/dist/shared/rollup.js:6552:23)
at BinaryExpression.bind (/home/ramses/projects/github.com/golem-base/golem-base-sdk-ts/node_modules/.pnpm/rollup@4.40.1/node_modules/rollup/dist/shared/rollup.js:6552:23)

 ELIFECYCLE  Command failed with exit code 1.
```

The code is available here: https://github.com/Golem-Base/typescript-sdk/tree/e43cf4eee53c6bab4bbecc30250d5a46d71f1eee

The error is triggered when running `pnpm build` with the following patch applied:
```diff
diff --git a/rollup.config.js b/rollup.config.js
index 05fc4fb..8f24798 100644
--- a/rollup.config.js
+++ b/rollup.config.js
@@ -49,7 +49,7 @@ export default [
compilerOptions: {
// TODO: we want to generate es modules, but when we do, we get an error
// from node-polyfill
- //module: "esnext",
+ module: "esnext",
},
}),
],
```

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.