4

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?

Alana Storm
  • 164,128
  • 91
  • 395
  • 599

1 Answers1

0

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?

DevLoverUmar
  • 11,809
  • 11
  • 68
  • 98
  • Thank you for response. I'm afraid my question was unclear, and while your answer contains useful information (+1), it is not the information I am looking for. I would like a way to intercept/listen-for modules loaded in deno via the `import` statement. My question mentioned require only to explain how I achieved something similar in Node.js. I've added some additional context to my question to make it clearer. – Alana Storm Jul 12 '20 at 20:32