two.js: `var root = this` breaks in bundlers.
Using var root = this seems to be breaking Rollup.js bundle. The resulting bundle looks something like
(function() {
"use strict"
commonjsGlobal.Two = (function() {
// Inside here it Two.js code...
var root = this // but this is not window
// ...
})()
})()
The issue is here: https://github.com/jonobr1/two.js/blob/e791c2c57cc799522d8795fdb5d9c3bbb12005e6/src/two.js#L3
My Rollup bundle is importing Two from the two.js npm package.
About this issue
- Original URL
- State: closed
- Created 7 years ago
- Comments: 18 (12 by maintainers)
I’m trying to bundle it with Rollup. It’s the same use case as @trusktr.
Here’s the config.
Is this fixed? I’m still getting the error.
There’s actually a more standard way to reference the global context:
selfAfter doing that, I am able to
importTwo in Rollup-bundled code.