Sideways S
Sideways S

Reputation: 717

How to prevent Rollup from adding `$1` suffix to names?

I don't see how the answer to this question, @rollup/plugin-inject, solves my problem. So I'm asking a new question. Rollup is appending a $1 suffix to four names that my rolled-up module exports. My module has no external dependencies and I can't find any of the four names documented as already defined in the global scope

Why does Rollup consider these previously declared? Or is there another reason for this?

How do I prevent this? Or should I wrap these in a namespace? Anyone who imports them can wrap them or alias them.

This is a JavaScript library with named exports. The repo is here: https://github.com/sidewayss/rAF

See src/globals/js for the first three names. The fourth is declared in src/prop/func.js. See rollup.config.mjs for the Rollup configuration.

Also, see this previous question for various answers to a part of this question: Rollup says my const names are global, renames them with $1 suffix

Upvotes: 0

Views: 92

Answers (1)

Sideways S
Sideways S

Reputation: 717

I figured this all the way out, and only because @rollup/plugin-replace doesn't replace all the $1 suffixes (it does replace some). This was caused by two things:

  • Circular import dependencies that Rollups warns about. I was paying no attention until I saw the warnings. I ended up being able to eliminate them all, with only one small inconvenience. After doing so I got back to this issue and saw that most of the $1 had been eliminated.
  • Undiscovered just-in-time compile bugs in obscure, untested functions, where the referenced name had not been imported. import {name} from "..."; solved that.

Now there is no more $1 in my bundled file, and I can uncomment my plugins and continue debugging.

Upvotes: 1

Related Questions