Deno: Can you Intercept Module Loading/Importing?

丶灬走出姿态 提交于 2020-07-16 06:50:22

问题


Does deno have any features that allow you to intercept the loading of a module that's included via import?

That is -- in Node.js programmers can redefine the require in order to intercept the loading of CommonJS modules. Node.js also features experimental loaders that allow you to intercept ES6 module loading.

Does deno have anything similar to this for its stock module loader (i.e. for import )? If not, are there plans for anything like this in deno, or does the project's philosophy stand opposed to this sort of thing?


回答1:


By default, CommonJS module system is not usable in DENO. However, if you want to intercept the modules loading the Node.js way, you have to use npm modules using createRequire in DENO. For more details Check this answer for How to use npm module in DENO?



来源:https://stackoverflow.com/questions/62855201/deno-can-you-intercept-module-loading-importing

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