This repository has been archived by the owner on May 28, 2019. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 150
Use webpack for builds #78
Open
ghost
wants to merge
11
commits into
master
Choose a base branch
from
feature/webpack
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
} | ||
var serializeDate = makeSerializeDate(UTCDate); | ||
if (has("json-stringify")) { | ||
// TODO: Revert via `JSON3.noConflict()`. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Making this work with noConflict
is going to be interesting, since noConflict
isn't a module, but a browser-only function that's injected by the webpack WrapperPlugin
. We'd need to make noConflict
context-aware...
var destPath = path.join(__dirname, "lib", "json3.min.js"); | ||
writeMinified(srcPath, destPath, function afterMinify(err, fileSizes) { | ||
if (err) { | ||
console.error("Error compressing JSON 3: %s", err); | ||
return; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should this be callback(err)
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice catch! 👓
* Add `makeRunInContext`. * Modularize `build.js`. * Use Bower to download the Closure Compiler.
Expose `noConflict` in CommonJS environments. Add an optional `preventNoConflict` flag to `runInContext` that controls whether `noConflict` is a no-op. This flag is used when exporting for CommonJS environments, where the global scope is not modified.
Add missing `nextTask` callback to `compress`.
ghost
mentioned this pull request
Apr 9, 2015
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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 themake*
factories that return the exported methods—but it's a little tricky withrunInContext
,has
, and our export system. For now, I just added a webpackWrapperPlugin
that wraps the build inbuild/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-offgulp-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. 😸
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).master
feature/webpack