rollup / rollup/rollup

es transform cjs error result

Open
#4,874 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

t¹ 🐞 bug t⁸ ⋅ triage
Dominant language
JavaScript
Stars
26.3k
Forks
1.8k
Avg merge
2d 11h
Merged PRs (30d)
20

Description

Rollup Version

3.2.37

Operating System (or Browser)

window

Node Version (if applicable)

16.15.1

Link To Reproduction

https://rollupjs.org/repl/?version=3.17.2&shareable=JTdCJTIyZXhhbXBsZSUyMiUzQW51bGwlMkMlMjJtb2R1bGVzJTIyJTNBJTVCJTdCJTIyY29kZSUyMiUzQSUyMmltcG9ydCUyMHRlc3QlMkMlN0JhJTdEJTIwZnJvbSUyMCcuJTJGYWJjLnRzJyU1Q24lNUNuY29uc29sZS5sb2codGVzdCUyQ2ElMkMxMjMpJTVDbiU1Q25leHBvcnQlMjBkZWZhdWx0JTIwdGVzdCU1Q25leHBvcnQlMjAlN0JhJTdEJTIyJTJDJTIyaXNFbnRyeSUyMiUzQXRydWUlMkMlMjJuYW1lJTIyJTNBJTIybWFpbi5qcyUyMiU3RCUyQyU3QiUyMmNvZGUlMjIlM0ElMjJjb25zdCUyMGElMjAlM0QlMjAxMjMlNUNuY29uc3QlMjB0ZXN0JTIwJTNEJTIwJTdCJTdEJTVDbiU1Q25leHBvcnQlMjBkZWZhdWx0JTIwdGVzdCU1Q25leHBvcnQlMjAlN0JhJTdEJTIyJTJDJTIyaXNFbnRyeSUyMiUzQWZhbHNlJTJDJTIybmFtZSUyMiUzQSUyMmFiYy50cyUyMiU3RCU1RCUyQyUyMm9wdGlvbnMlMjIlM0ElN0IlMjJvdXRwdXQlMjIlM0ElN0IlMjJmb3JtYXQlMjIlM0ElMjJlcyUyMiU3RCUyQyUyMnRyZWVzaGFrZSUyMiUzQXRydWUlN0QlN0Q=

Expected Behaviour

expect to be console.log(test['default'],test.a,123) or console.log(test.default,test,a,123)

Actual Behaviour

`
// index.ts
import test,{a} from './abc'

console.log(test,a,123)

export default test
export {a}

// abc.ts
const a = 123
const test = {}

export default test
export {a}
`

------------------------>

`
// index.js
'use strict';

Object.defineProperty(exports, '__esModule', { value: true });

var test = require('./abc');

console.log(test,test.a,123); // error log

Object.defineProperty(exports, 'a', {
enumerable: true,
get: function () { return test.a; }
});
exports.default = test;

// abc. js
'use strict';

Object.defineProperty(exports, '__esModule', { value: true });

const a = 123;
const test = {};

exports.a = a;
exports.default = test;

`

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the linked Rollup REPL reproduction and compare the ES-to-CommonJS output for the default and named imports. Trace the output-generation entry point responsible for this transformation; done means the generated CommonJS code matches the expected console.log behavior without changing the other exports.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript
Domain
build-system
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
38/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.