Skip to content

Add support for import defer proposal - #60757

Merged
Wesley Wigham (weswigham) merged 25 commits into
microsoft:mainfrom
nicolo-ribaudo:import-defer
Jun 6, 2025
Merged

Wesley Wigham (weswigham) merged 25 commits into
microsoft:mainfrom
nicolo-ribaudo:import-defer

Conversation

@nicolo-ribaudo

@nicolo-ribaudo Nicolò Ribaudo (nicolo-ribaudo) commented Dec 13, 2024 •

Copy link
Copy Markdown
Contributor

This proposal is currently at Stage 3.

This PR only needs to add parsing support for the proposal:

  • it does not support downleveling it, as it's not possible to transpile it to older ESM versions
    • it would be possible add support for transpiling to CommonJS, if needed.
  • it does not introduce any type-checking changes, as the object created by import defer * as ns is meant to "look like" the one created by import * as ns

As you'll see from the code, whether a module is deferred or not is not a boolean but an enum. That's because of the import source proposal: there is no PR for it yet, but once it will be implemented it should be done by adding one more possible "import phase" to this enum. A question I have is if that should be an enum, or just an union of undefined | DeferKeyword (which will one day become undefined | DeferKeyword | SourceKeyword).

Fixes #59391

This patch was originally written by Ujjwal Sharma (@ryzokuken)

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

Labels

For Uncommitted Bug PR for untriaged, rejected, closed or missing bug

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

import defer Stage 3 proposal support