Upgrade to Pro — share decks privately, control downloads, hide ads and more …

DotJS - Revisiting node_modules

Maël Nison
November 09, 2018

DotJS - Revisiting node_modules

Yarn recently unveiled exciting work on an alternative installation strategy, Plug'n'Play. By using it, one can avoid entirely the node_modules hell. Let's discuss why we would do that, and how.

Maël Nison

November 09, 2018
Tweet

Other Decks in Programming

Transcript

  1. #dotjs • Lots of I/O required • 30,000+ files required

    for a typical project • Impractical for the HTTP use case • Has a runtime impact as well The ugly sides of a system used by the planet node_modules flaws
  2. #dotjs • Limiting factor in the optimization space The v2

    cannot be optimized and must be copied twice The ugly sides of a system used by the planet node_modules flaws
  3. #dotjs • Permit unsafe accesses No way to know if

    this code will work – all about hoisting The ugly sides of a system used by the planet node_modules flaws
  4. #dotjs The Node resolution: simple, makes no assumptions Overview of

    the resolution foo/file.js Package manager (yarn install) Node Resolver (node_modules) What is the closest node_modules? Which file asks for foo/file.js? Does it contain foo/file.js? require(“foo/file.js”) /n_m/bar/n_m/foo/file.js
  5. #dotjs Leveraging semantic installations to the rescue Static resolution •

    Dependencies can be statically retrieved at runtime • The path to the packages as well
  6. #dotjs The Node resolution: simple, makes no assumptions Overview of

    the resolution foo/file.js Package manager (yarn install) Node Resolver (node_modules) What is the closest node_modules? Which file asks for foo/file.js? Does it contain foo/file.js? require(“foo/file.js”) /n_m/bar/n_m/foo/file.js
  7. #dotjs Leveraging semantic installations to the rescue Static resolution foo/file.js

    Package manager (yarn install) Node Resolver (.pnp.js) What version of foo does bar depends on? Which package asks for foo? Where is located this version of foo? require(“foo/file.js”) /cache/foo-1.0/file.js
  8. #dotjs • Faster installs in every cases • Immediate installs

    across multiple projects • Strict safety mechanisms for ensure consistency • Enable tight integrations with the dependency tree • … node_modules? no_modules !