Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[WIP] Support requiring .mjs files #30891

Commits on Dec 10, 2019

  1. module: support requiring .mjs files

    This implements the ability to use require on .mjs files, loaded
    via the esm loader, using the same tradeoffs that top level await
    makes in esm itself.
    
    What this means: If possible, all execution and evaluation is done
    synchronously, via immediately unwrapping the execution's component
    promises. This means that any and all existing code should have no
    observable change in behavior, as there exist no asynchronous modules as
    of yet. The catch is that once a module which requires asynchronous
    execution is used, it must yield to the event loop to perform that
    execution, which, in turn, can allow other code to execute before the
    continuation after the async action, which is observable to callers of
    the now asynchronous module. If this matters to your callers, this means
    making your module execution asynchronous could be considered a breaking
    change to your library, however in practice, it will not matter for most
    callers. Moreover, as the ecosystem exists today, there are zero
    asynchronously executing modules, and so until there are, there are no
    downsides to this approach at all, as no execution is changed from what
    one would expect today (excepting, ofc, that it's no longer an error to
    require("./foo.mjs").
    
    Ref: nodejs/modules#308
    Ref: https://github.com/nodejs/modules/issues/299
    Ref: nodejs/modules#454
    weswigham committed Dec 10, 2019
    Configuration menu
    Copy the full SHA
    219964b View commit details
    Browse the repository at this point in the history
  2. Fix lints

    weswigham committed Dec 10, 2019
    Configuration menu
    Copy the full SHA
    286692b View commit details
    Browse the repository at this point in the history
  3. Remove unneeded call to promiseWait - we only need this once TLA su…

    …pport is in, and until then, the results are a bit off
    weswigham committed Dec 10, 2019
    Configuration menu
    Copy the full SHA
    fe74e6f View commit details
    Browse the repository at this point in the history
  4. Fix mjs test

    weswigham committed Dec 10, 2019
    Configuration menu
    Copy the full SHA
    afe50b9 View commit details
    Browse the repository at this point in the history
  5. Fix lints, again

    weswigham committed Dec 10, 2019
    Configuration menu
    Copy the full SHA
    0a1faa4 View commit details
    Browse the repository at this point in the history