links: JS MOC


What is module in JS?

Have you seen module in any of react codebase or storybook. That is used to enable Hot-Module-Replacement.

module is a node way of import/export variables, functions

For example:

ES5 export syntax module.exports

Webpack

  • Webpack runs on node, so it kind of uses module syntax (needs verification)

Eslint and typescript fix

  • Since typescript and eslint look for variables, both cannot find module and shows warning about it
  • In order to fix it

For Eslint:

Add environment of node to eslint globals

For typescript

declare var module

So typescript knows there is module


tags: basics

source