babel / babel/babel-polyfills

When I use polyfill-es-shims plugin on my code it tries to import nodeJS `util.inspect` which requires rollup-plugin-polyfill-node...

Open
#205 3 comments 0 reactions 0 assignees View on GitHub
Dominant language
TypeScript
Stars
357
Forks
62
PR merge metrics
No merged PRs in 30d

Description

And adding 'rollup-plugin-polyfill-node' to my plugins adds a load of additional unnecessary code to the top of all my output files.

I struggle at the best of times to understand what I'm doing with babel and rollup, perhaps I'm doing something wrong.
This makes no sense.
Please help me out.

```
import { nodeResolve as rollup_node_resolve } from '@rollup/plugin-node-resolve';
import rollup_typescript from '@rollup/plugin-typescript';
import rollup_commonjs from '@rollup/plugin-commonjs';
...
var plugins = [];
plugins.push(
rollup_typescript({
"include": ["index.d.ts", "src/js/**/*.ts"],
compilerOptions: {
"module": "esnext",
"target": "es6",
"isolatedModules": true,
}
}),
rollup_node_resolve(),
rollup_commonjs(),
);

if (PRODUCTION) {
var babel_presets = [];
var babel_plugins = [];
babel_plugins.push(["polyfill-es-shims", { "method": "usage-global" }]);
babel_presets.push(
[
"@babel/preset-env",
{
"useBuiltIns": "entry",
"corejs": "3.22"
}
]
);
plugins.push(
rollup_babel({
"extensions": [".js", ".ts"],
"babelHelpers": "bundled",
"presets": babel_presets,
"plugins": babel_plugins,
})
);
```

Contributor guide

Open the contributing guide

Research direction

Use the provided Rollup and Babel configuration as the reproduction case, starting by checking which dependency introduces Node.js util.inspect and why the polyfill plugin requires it. Done means the cause is identified and the configuration no longer adds unnecessary code to output files while preserving the requested polyfills.

Written by the indexing model from the issue text.

Assessment

Tech stack
babel, typescript
Domain
build-system, tooling
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.