Skip to content

module: unflag --experimental-import-text? #67267

Open

Description

@pdeveltere

What is the problem this feature will solve?

Text modules (import text from './file.txt' with { type: 'text' }) landed in #62300 behind --experimental-import-text and are documented as Stability 1.0 (Early development). They have shipped in 26.x and were backported to 24.19.0.

The flag makes the feature hard to use in practice. Libraries can't rely on it, because they would have to tell every consumer to pass a CLI flag. #65210 also showed that the flag gate affects userland loaders that handle type: 'text' themselves. #64992 fixed that, but it's a sign that "on behind a flag" and "off" are two separate behaviours that loader authors have to keep in mind.

Standards status:

What is the feature you are proposing to solve the problem?

Remove the flag requirement while keeping the feature experimental, following what was done for JSON modules. JSON modules were unflagged in #41736 (v17.5.0) while import assertions were still Stage 3, and were only marked stable in #55333 after the proposal reached Stage 4.

Concretely:

  • Stop gating on --experimental-import-text in lib/internal/modules/esm/assert.js and lib/internal/modules/esm/get_format.js.
  • Keep the existing emitExperimentalWarning('Text import') in the text translator.
  • Turn --experimental-import-text into a NoOp option, like --experimental-json-modules, so existing scripts keep working.
  • Move the docs to Stability 1.1 (Active development).
  • Update the tests: test-esm-import-text-disabled.mjs would need to change or be removed.

Question for @nodejs/loaders: are there open semantics questions (BOM handling, non-UTF-8 sources, the text/plain charset regex in mimeToFormat) that should be settled first?

If there's agreement, I'm happy to send the PR.

Activity

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions