Slide 1

Slide 1 text

#dotjs Software Engineer, Facebook Revisiting node_modules Maël Nison - @arcanis

Slide 2

Slide 2 text

#dotjs

Slide 3

Slide 3 text

#dotjs A legacy system that happens to work-ish node_modules aren’t great

Slide 4

Slide 4 text

#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

Slide 5

Slide 5 text

#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

Slide 6

Slide 6 text

#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

Slide 7

Slide 7 text

#dotjs Are node_modules needed?

Slide 8

Slide 8 text

#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

Slide 9

Slide 9 text

#dotjs Leveraging semantic installations to the rescue Static resolution • Dependencies can be statically retrieved at runtime • The path to the packages as well

Slide 10

Slide 10 text

#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

Slide 11

Slide 11 text

#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

Slide 12

Slide 12 text

#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 !