feat: option to keep imports when generating cjs as const destructoring pattern
Nobody has claimed this yet.
- Dominant language
- JavaScript
- Stars
- 26.3k
- Forks
- 1.8k
- Avg merge
- 2d 11h
- Merged PRs (30d)
- 20
Description
Feature Use Case
Repl example
this example shows that it translates the import patterns to for example node_fs.existsSync but i need it to be
entrypoint.js
import { existsSync } from 'node:fs';
existsSync();
output.cjs
'use strict';
const node_fs = require('node:fs');
node_fs.existsSync();
but desired output should be:
'use strict';
const { existsSync } = require('node:fs');
existsSync();
what would be the best way to integrate that without simply patching the existing logic.
Feature Proposal
add a option that enables the desired output.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with the linked Rollup Repl example and compare the generated output.cjs with the desired destructuring pattern for entrypoint.js. Trace the CommonJS output generation path and define an option whose completed behavior preserves named imports instead of rewriting references through a namespace object, with coverage for this example.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- javascript
- Domain
- build-system
- Issue type
- Feature
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100