@rollup/plugin-babel causes SOURCEMAP_ERROR while reporting THIS_IS_UNDEFINED from unmapped generated helper code
Nobody has claimed this yet.
Assessment
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Newbie friendliness
- 52/100
- Issue type
- Bug
- Clarity
- Mostly clear
- Activity status
- Quiet
- Tech stack
- babel, javascript
- Domain
- build-system, tooling
Research direction
Start with the linked reproduction and run pnpm run build, comparing it with pnpm run build:bare. Trace how @rollup/plugin-babel 6.1.0 handles the sourcemap for src/index.js and generated helper code. Done means the plugin no longer adds SOURCEMAP_ERROR warnings while Rollup still reports THIS_IS_UNDEFINED.
Written by the indexing model from the issue text.
Description
Rollup Plugin Name
@rollup/plugin-babel
Plugin Version
6.1.0
Rollup Version
4.60.1
Operating System
Windows 11, but this does not appear to be Windows-specific.
Link to reproduction
https://github.com/shrinktofit/rollup-babel-sourcemap-bug
Expected Behavior
When Rollup reports THIS_IS_UNDEFINED for generated helper code that has no original source mapping, using @rollup/plugin-babel should not add extra SOURCEMAP_ERROR warnings.
Bare Rollup reports only THIS_IS_UNDEFINED for the same input.
Actual Behavior
With @rollup/plugin-babel in the pipeline, Rollup emits additional SOURCEMAP_ERROR warnings before the original THIS_IS_UNDEFINED warnings:
[onwarn] SOURCEMAP_ERROR src/index.js (1:17): Error when using sourcemap for reporting an error: Can't resolve original location of error.
[onwarn] THIS_IS_UNDEFINED src/index.js (1:17): The 'this' keyword is equivalent to 'undefined' at the top level of an ES module, and has been rewritten
[onwarn] SOURCEMAP_ERROR src/index.js (1:25): Error when using sourcemap for reporting an error: Can't resolve original location of error.
[onwarn] THIS_IS_UNDEFINED src/index.js (1:25): The 'this' keyword is equivalent to 'undefined' at the top level of an ES module, and has been rewritten
Steps to Reproduce
git clone https://github.com/shrinktofit/rollup-babel-sourcemap-bug.git
cd rollup-babel-sourcemap-bug
pnpm install
pnpm run build
For comparison, bare Rollup does not emit SOURCEMAP_ERROR:
pnpm run build:bare
Notes
The repro simulates TypeScript legacy decorator output:
var __decorate = (this && this.__decorate) || function () {};
export const value = 1;
//# sourceMappingURL=index.js.map
The sourcemap intentionally has no mapping for generated line 1, representing compiler-generated helper code. The mapping starts at generated line 2.
Bare Rollup reports THIS_IS_UNDEFINED without SOURCEMAP_ERROR. Once @rollup/plugin-babel is added, the input sourcemap enters the sourcemap chain and Rollup tries to map the generated helper location back to an original source location. Since helper code has no original mapping, that remapping fails and produces noisy SOURCEMAP_ERROR warnings.
This shape appears in real projects when bundling TypeScript output that contains inline legacy decorator helpers and sourcemaps.
- Dominant language
- JavaScript
- Stars
- 3.8k
- Forks
- 635
- PR merge metrics
- No merged PRs in 30d
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.
More from rollup/plugins
-
Difficulty 2/5 1-3 hours Newbie friendliness 82/100
-
Difficulty 4/5 3-5 days Newbie friendliness 52/100
-
Difficulty 3/5 1-2 days Newbie friendliness 48/100
-
Difficulty 4/5 3-5 days Newbie friendliness 48/100
-
Support js-yaml v5 Open
Difficulty 4/5 3-5 days Newbie friendliness 45/100
Similar issues
-
bug customer-eng Durable Agents Inngest status: needs triage
Difficulty 2/5 1-3 hours Newbie friendliness 82/100
-
optimization optimization:agents-md-curator
Difficulty 2/5 1-3 hours Newbie friendliness 75/100
githubnext/gh-aw-cao#13475 ·
-
[BUG]: "Clear All" in Settings doesn't clear the saved analysis, old data comes back after reload Openbug
Difficulty 2/5 1-3 hours Newbie friendliness 88/100
AOSSIE-Org/OrgExplorer#253 · 1 comment ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 88/100
oxc-project/oxc#26944 ·
-
ai-observability bug team/ai-observability
Difficulty 2/5 1-3 hours Newbie friendliness 78/100