Skip to content

Migrate to ESM (and get dynamic await) #32

Closed
@CMCDragonkai

Description

@CMCDragonkai

What is your research hypothesis/question?

There is a conjunction of 4 features:

  • dynamic imports
  • top level await
  • nodejs module type (es modules in nodejs)
  • explicit exports in package.json

That enables some nifty capabilities:

  • The ability to create modules that can do feature tests and import the right module for a given platform - cross platform compatibility (especially in terms of platform-native features vs importing specific modules)
  • The ability to move away from commonjs modules and use esmodules as a standard for all platforms - this can reduce the dependence on bundling if all platforms support esmodules
  • The ability to create explicit package exports, so one can create subdirectory imports import x from 'a/b/c'; - this can allow us to flexibly export things without having to go down the dist/... route all the time

These features are all coming online in various forms, however some initial experiments show that they involve alot of changes.

Review existing ideas, literature and prior work

  1. motivation from nativescript React Native and Mobile OS (iOS and Android) Compatibility Polykey#155 (comment)
  2. experiment in js-id ID standardisation for all projects and domains js-id#1 (comment)
  3. ts-node support ESM support: soliciting feedback TypeStrong/ts-node#1007
  4. Wait for TS 4.5 release

Research conclusion

See the notes in MatrixAI/js-logger#29

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions