You are viewing documentation generated from a user contribution or an upcoming release. The contents of this document may not have been reviewed by the Deno team. Click here to view the documentation for the latest release.

import.meta API

Deno supports a number of methods on the import.meta API:

  • import.meta.url: returns the URL of the current module.
  • import.meta.main: returns whether the current module is the entry point to your program.
  • import.meta.resolve: resolve specifiers relative to the current module.

import.meta.resolve Example

const worker = new Worker(import.meta.resolve("./worker.ts"));

The import.meta.resolve API takes into account the currently applied import map, which gives you the ability to resolve "bare" specifiers as well.

With such import map loaded...

  "imports": {
    "fresh": ""
} can now resolve:

// resolve.js
$ deno run resolve.js