-
Notifications
You must be signed in to change notification settings - Fork 128
Open
Description
Hi, I'm trying to add a non-exported 3rd party class to global scope, using rewire
The class looks like this: https://github.com/Dogfalo/materialize/blob/v1-dev/js/component.js
I'm doing it this way:
const ComponentModule = require('rewire')('materialize-css/js/component');
global.Component = ComponentModule.__get__('Component');
And it almost works, but inside component.js, there are usages of Element and cash. And during runtime, they fail as "is not defined"
I managed to solve the problem by:
const ComponentModule = require('rewire')('materialize-css/js/component');
ComponentModule.__set__('Element', Element);
ComponentModule.__set__('cash', cash);
global.Component = ComponentModule.__get__('Component');
And it works.
However, it seems very strange to me, since both of these variables are available before rewiring. Is there any way to add these globals implicitly?
I think it might be the same problem: #99
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels