In a compiled node module, why do I see (private) methods omitted from the compiled version that exist in the source?

拈花ヽ惹草 提交于 2019-12-11 14:40:23

问题


I'm using Mapbox GL JS, and I've found a private method that might be useful in solving a problem. It's _requestRenderFrame in map.js, and looks like this:

/**
 * Request that the given callback be executed during the next render
 * frame.  Schedule a render frame if one is not already scheduled.
 * @returns An id that can be used to cancel the callback
 * @private
 */
_requestRenderFrame(callback: () => void): TaskID {
    this._update();
    return this._renderTaskQueue.add(callback);
}

If I try to reference it in my project, I get undefined.

console.log(this.host.map['_requestRenderFrame']) // undefined;

When I search the mapbox package within my node_modules folder, I only see results for "_requestRenderFrame" in dist/mapbox-gl-dev.js.map.

There's other stuff that goes along with this feature that's not in there, so I can't really just hack the method back in on the fly.

I'm missing something. How can a method in source be omitted from compiled code? I have a hunch it may be just for testing??? But still, is there any way for me to use the omitted feature?

来源:https://stackoverflow.com/questions/49808049/in-a-compiled-node-module-why-do-i-see-private-methods-omitted-from-the-compi

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!