问题
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