Skip to content

loader: add experimental text import#62300

Open
efekrskl wants to merge 3 commits intonodejs:mainfrom
efekrskl:loader/experimental-raw-imports
Open

loader: add experimental text import#62300
efekrskl wants to merge 3 commits intonodejs:mainfrom
efekrskl:loader/experimental-raw-imports

Conversation

@efekrskl
Copy link
Contributor

@efekrskl efekrskl commented Mar 17, 2026

Closes #62082

Adds support for text import under --experimental-import-text flag.

Example:

import text from './file.txt' with { type: 'text' };

Import text is a Stage 3 TC39 proposal

Deno supports text imports with --unstable-raw-imports.
Bun supports text imports directly.

Not entirely sure what the current stance is on not-yet-landed proposals, but putting this up for discussion and feedback.

@nodejs-github-bot
Copy link
Collaborator

Review requested:

  • @nodejs/config
  • @nodejs/loaders

@nodejs-github-bot nodejs-github-bot added lib / src Issues and PRs related to general changes in the lib or src directory. needs-ci PRs that need a full CI run. labels Mar 17, 2026
@bakkot
Copy link
Contributor

bakkot commented Mar 18, 2026

Note that the import-bytes proposal requires producing Uint8Arrays backed by immutable ArrayBuffers, which are not yet supported in V8. I would be hesitant to ship this with mutable backing buffers, even flagged as experimental, lest people come to rely on that.

Text imports don't have the same problem.

@efekrskl efekrskl changed the title loader: add experimental text and bytes import loader: add experimental text import Mar 20, 2026
@efekrskl efekrskl marked this pull request as ready for review March 20, 2026 18:40
@efekrskl
Copy link
Contributor Author

Note that the import-bytes proposal requires producing Uint8Arrays backed by immutable ArrayBuffers, which are not yet supported in V8. I would be hesitant to ship this with mutable backing buffers, even flagged as experimental, lest people come to rely on that.

Text imports don't have the same problem.

That's a great point, looks like I've missed that. I've removed bytes related part of the code. Thank you!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

lib / src Issues and PRs related to general changes in the lib or src directory. needs-ci PRs that need a full CI run.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Support for importing text modules

3 participants