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:
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.
Rollup Plugin Name
@rollup/plugin-babelPlugin Version
6.1.0Rollup Version
4.60.1Operating 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_UNDEFINEDfor generated helper code that has no original source mapping, using@rollup/plugin-babelshould not add extraSOURCEMAP_ERRORwarnings.Bare Rollup reports only
THIS_IS_UNDEFINEDfor the same input.Actual Behavior
With
@rollup/plugin-babelin the pipeline, Rollup emits additionalSOURCEMAP_ERRORwarnings before the originalTHIS_IS_UNDEFINEDwarnings:Steps to Reproduce
git clone https://github.com/shrinktofit/rollup-babel-sourcemap-bug.git cd rollup-babel-sourcemap-bug pnpm install pnpm run buildFor comparison, bare Rollup does not emit
SOURCEMAP_ERROR:Notes
The repro simulates TypeScript legacy decorator output:
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_UNDEFINEDwithoutSOURCEMAP_ERROR. Once@rollup/plugin-babelis 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 noisySOURCEMAP_ERRORwarnings.This shape appears in real projects when bundling TypeScript output that contains inline legacy decorator helpers and sourcemaps.