Responsible JavaScript

Responsible JavaScript

Jeremy Wagner

CommonJS modules can’t be statically analyzed. This is because both CommonJS’s module.exports and require constructs accept dynamic expressions. Therefore, bundlers can’t easily or reliably mark which CommonJS modules are unused (http://bkaprt.com/rjs39/05-08). ESM resolves this via the static import statement, which can only accept a plain string. This makes tree shaking loads more predictable for bundlers.
2367-2373