Using Babel to compile ES modules to CommonJs is always an option, and often a necessity for production builds.
However, if you just want to run some code using ES modules now and to experiment with it, for example in a tool like Quokka, then installing and configuring Babel just to get ES modules support can ruin your experimenter’s mood quickly. Quick and dirty conversion of import-s to CommonJs require-s may seem like a good option for the experiment’s scratch file, until you realise that you need to load some of your source files or modules that are using ES imports/exports.
Today we are happy to announce that now you can use ES Modules in Quokka with zero config — just open Quokka scratch file in your editor and start typing:
The solution is using the awesome standard-things/esm module loader by John-David Dalton. Special thanks go to John for creating the module and for helping with us to create the working solution not only for Quokka but for Wallaby as well, if you would like to run your unit tests in node without Babel transpilation.