Skip to content
This repository has been archived by the owner on May 28, 2019. It is now read-only.

Modularize internals; use a bundler to generate the resulting source file #75

Open
ghost opened this issue Jan 26, 2015 · 2 comments
Open

Comments

@ghost
Copy link

ghost commented Jan 26, 2015

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.

@ghost ghost self-assigned this Jan 26, 2015
@ghost ghost added the enhancement label Jan 26, 2015
@ghost
Copy link
Author

ghost commented Jan 26, 2015

@D10 Thoughts? This is a yak I've been wanting to shave for a while, but it could just be an awful, harebrained scheme. 😸

@bnjmnt4n
Copy link
Member

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.

ghost pushed a commit that referenced this issue Mar 8, 2015
* Add `makeRunInContext`.
* Modularize `build.js`.
* Use Bower to download the Closure Compiler.
ghost pushed a commit that referenced this issue Apr 9, 2015
* Add `makeRunInContext`.
* Modularize `build.js`.
* Use Bower to download the Closure Compiler.
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Development

No branches or pull requests

1 participant