-
Notifications
You must be signed in to change notification settings - Fork 2.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Support
type
import attribute with "text"
, "json"
, "toml"
, an…
…d `"file"` (#10456) * Fixes #3449 Fixes #10206 Fixes #5710 * Apply formatting changes * Update loaders.md * Update text-loader-fixture-import.ts * Add guide * Update bundler_loader.test.ts * Address comment --------- Co-authored-by: Jarred-Sumner <[email protected]>
- Loading branch information
1 parent
ff62414
commit 024c274
Showing
21 changed files
with
516 additions
and
42 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
--- | ||
name: Import HTML file as text | ||
--- | ||
|
||
To import a `.html` file in Bun as a text file, use the `type: "text"` attribute in the import statement. | ||
|
||
```ts | ||
import html from "./file.html" with { type: "text" }; | ||
|
||
console.log(html); // <!DOCTYPE html><html><head>... | ||
``` | ||
|
||
This can also be used with hot module reloading and/or watch mode to force Bun to reload whenever the `./file.html` file changes. | ||
|
||
This feature was added in Bun v1.1.5. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.