Skip to content
Merged
Show file tree
Hide file tree
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
7 changes: 4 additions & 3 deletions examples/scripts/importing_text.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,15 @@
* @title Importing text files
* @difficulty beginner
* @tags cli
* @run --unstable-raw-imports https://docs.deno.com/examples/scripts/importing_text.ts
* @run <url>
* @resource {https://github.com/whatwg/html/issues/9444} HTML specification proposal
* @group Unstable APIs
* @group Basics
*
* Text files can be imported in JS and TS files using the `import` keyword.
* This makes including static data in a library much easier.
*
* Using this feature requires `--unstable-raw-imports` CLI flag.
* Stable as of Deno 2.8 — no flag required. (Binary `bytes` imports are still
* experimental and require `--unstable-raw-imports`.)
*/

// File: ./main.ts
Expand Down
22 changes: 14 additions & 8 deletions runtime/fundamentals/modules.md
Original file line number Diff line number Diff line change
Expand Up @@ -78,14 +78,6 @@ console.log(data.property); // Access JSON data as an object

Starting with Deno 2.4 it's possible to import `text` and `bytes` modules too.

:::info

Support for importing `text` and `bytes` modules is experimental and requires
`--unstable-raw-imports` CLI flag or `unstable.raw-import` option in
[`deno.json`](/runtime/fundamentals/configuration/).

:::

```ts
import text from "./log.txt" with { type: "text" };

Expand All @@ -95,6 +87,12 @@ console.log(text);
// Hello from a text file
```

:::info `text` imports

Stable in Deno 2.8 and no longer require a flag.

:::

```ts
import bytes from "./image.png" with { type: "bytes" };

Expand All @@ -108,6 +106,14 @@ Uint8Array(12) [
// ]
```

:::info `bytes` imports

Still experimental. Enable with the `--unstable-raw-imports` CLI flag or the
`unstable.raw-import` option in
[`deno.json`](/runtime/fundamentals/configuration/).

:::

## Deferred module evaluation

Starting in Deno 2.8, the
Expand Down