Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: update import.meta API code blocks #673

Merged
merged 2 commits into from
Aug 6, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 8 additions & 12 deletions runtime/manual/runtime/import_meta_api.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,13 @@ title: "`import.meta` API"

Deno supports a number of properties and methods on the
[`import.meta`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/import.meta)
API:
API. It can be used to get information about the module like the module's URL.

## `import.meta.url`

Returns the URL of the current module.

```ts
// main.ts
```ts title="main.ts"
console.log(import.meta.url);
```

Expand All @@ -27,13 +26,13 @@ https://example.com/main.ts

Returns whether the current module is the entry point to your program.

```ts
// main.ts
```ts title="main.ts"
import "./other.ts";

console.log(`Is ${import.meta.url} the main module?`, import.meta.main);
```

// other.ts
```ts title="other.ts"
console.log(`Is ${import.meta.url} the main module?`, import.meta.main);
```

Expand All @@ -51,8 +50,7 @@ _This property is only available for local modules (module that have
Returns the fully resolved path to the current module. The value contains OS
specific path separators.

```ts
// main.ts
```ts title="main.ts"
console.log(import.meta.filename);
```

Expand Down Expand Up @@ -84,8 +82,7 @@ _This property is only available for local modules (module that have
Returns the fully resolved path to the directory containing the current module.
The value contains OS specific path separators.

```ts
// main.ts
```ts title="main.ts"
console.log(import.meta.dirname);
```

Expand Down Expand Up @@ -132,8 +129,7 @@ With such import map loaded...

...you can now resolve:

```js
// resolve.js
```js title="resolve.js"
console.log(import.meta.resolve("fresh"));
```

Expand Down