webbower
webbower2y ago

Globally import files for Deno subcommands

I’ve looked at Deno docs and searched online to no avail for this answer. Is there a capability in Deno similar to node -r <packageOrFilepath> or some other ability to globally import one or more files for the whole script lifetime? For a concrete example, how would I load a polyfill for a global method to be present in my application code and again for individual test files to ensure the polyfilled method is always available?
2 Replies
bartlomieju
bartlomieju2y ago
No, there's no such way right now - unless you use deps.js/ts convention, then you can just import that file in your deps file
webbower
webbowerOP2y ago
Oh interesting. I figured out a conceptually similar solution in my Fresh project to import it into main.ts. For my tests, I created a test entry point file which my deno test command runs and it explicitly imports all the test files after the bootstrapping import.

Did you find this page helpful?