Open ghost opened 9 years ago
@d10 Thoughts? This is a yak I've been wanting to shave for a while, but it could just be an awful, harebrained scheme. :smile_cat:
It seems great to me. The various if
branches have been leaving me confused for a while. It also makes sense to download only the code for say JSON.parse
if that is the only function you use.
The source is currently delivered as a single monolithic blob, with a giant
runInContext
function. This makes it difficult to follow what we're exporting, and tangles up internal state in each function.It also means we can't break up JSON 3 into custom builds—i.e., just the date serialization fixes,
stringify
only,parse
only, or including a subset of the feature tests. (This isn't nearly as important as for a general-purpose library like jQuery or lodash, but it's still painful to download ~4 KB of dead code). This might also make it easier for the Closure Compiler to prune unused code paths.The
feature/webpack
branch is my first cut at making this happen—break up the internals, then use a builder like webpack (or Browserify) to stitch them together. We'll need to rework our exports system, but there are modules for adding AMD and global wrappers that we could use.