2021-08-03

#dev

Découverte de JavaScript modules(ESM)

Pure ESM package

CommonJS has served us well for many years, but ESM comes with many benefits, like language-level syntax, browser support, defaults to strict mode, async loading, top-level await, improved static analysis & tree-shaking, and more.

If you’re not familiar with ESM, start by reading the MDN overview. The Node.js docs on ESM are also very comprehensive, and IMHO required reading.

Introducing a new module system is not a simple thing. The ecosystem is huge and it’s going to take many years to move the whole ecosystem. Luckily, smart people have spent a lot of effort into making these module systems fairly compatible. ESM can import CommonJS and CommonJS can import ESM. However, and it’s a big however, CommonJS can only import ESM asynchronously.

Mise en place de JEST avec REWIRE

Intégration dans le projet Movie Scrapping pour Unit Testing (UT) de:

Rewire est l'élément que j'ai souvent imaginé et chercher activement lorsque je pratiquait AngularJS. Tout marche parfaitement, il faut tout de même que je regarde les limitations d'une telle solution qui semble trop magique.