bestiejs / json3

A JSON polyfill. No longer maintained.
https://bestiejs.github.io/json3
Other
1.02k stars 150 forks source link

Use webpack for builds #78

Open ghost opened 9 years ago

ghost commented 9 years ago

This breaks json3.js into separate CommonJS modules that are stitched together with webpack. The source files are usable as separate modules—requiring them imports the make* factories that return the exported methods—but it's a little tricky with runInContext, has, and our export system. For now, I just added a webpack WrapperPlugin that wraps the build in build/assets/{header, footer}.js.

Various functions from build.js have also been moved into their own modules. I investigated switching to gulp (4.0 adds a lot of nice conveniences), but held off for now...we're using a lot of custom, non-streaming transforms, and I don't think we need one-off gulp-json3-* plugins. getCompiler and friends have been removed entirely; Bower can download and cache the Closure Compiler for us.

@d10 I'd love your feedback, whenever you have some spare cycles. I expect this will need a lot more polish before it's ready for merging. :smile_cat:

There is a slight increase in the size of the minified version, but I think it's acceptable—especially if we can do custom builds in the future that remove some of the corner cases (e.g., Date#toJSON fixes).

Build master feature/webpack
Dev 41.47 KB 40.84 KB
Minified 3.46 KB 3.62 KB