Hacker News new | ask | show | jobs
by ianertson 1953 days ago
What I mean with "adapts the code through static analysis" is:

1. Finds dead code and removes it 2. It converts nodejs code that isn't compatible with the browser into browser code 2. It converts JS code that isn't compatible with nodejs to nodejs code

It tries to always make things work both in nodejs and browser js.

One example is the optional chain syntax which doesn't work in nodejs but works in the browser. FJB converts it to something that works everywhere.

2 comments

> 2. It converts nodejs code that isn't compatible with the browser into browser code 2. It converts JS code that isn't compatible with nodejs to nodejs code

I’m not sure what that lot means. Are you talking about converting CommonJS to… I dunno, ECMAScript Modules? and vice versa? And there’s plenty that’s available in the NodeJS or web environments that’s simply unavailable in the other, e.g. the "http" and "https" modules from NodeJS and the fetch() global in the web, and you often can’t translate between the two at all, and even if you can, it’d be decidedly messy.

Output format is almost orthogonal to what I understand you to be talking about. In the terms of other bundling stuff, you seem to be talking more about features of Babel rather than features of webpack/Rollup, and if so, then output format is completely orthogonal.

Optional chaining's in Node as of v14.5.
Sure, but it was just an example of what kind of things FJB is doing to the code