-
Notifications
You must be signed in to change notification settings - Fork 142
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Export version
property on base object
#25
Conversation
👎 on uglify for the main dep. I'm fine with an uglify second dep, but
|
uglify is required to prune
I don't normally insert the built versions but did so intentionally in this branch so that we can see the uglified-without-version-property build and diff it with the uglified-with-version-property build. Can remove if still desired.
we probably could simply by |
Regardless, I don't want to minify it by default (I don't care if the package.json is in the built asset, but I also don't care if
Yes I only want to have anything generated to
That or any other means is fine. Bizarre to me that there's not a browserify functionality for this. Is publishing browser-consumed libraries not a common use case for browserify? |
Browser-consumed libraries are almost entirely consumed in minified/uglified form. (not to mention how impossible they are to read with browserify scaffolding) I think for that reason I'm seeing less and less use of comments for versioning and more use of the version property on the exported object instead. anecdotal
If this is the case, then we can kill uglifyify and envify both, and just export |
removed all the dist builds and removed uglifyify/envify. so package.json contents are currently being included in the bundle. we can fix this without using uglifyify when zertosh/unreachable-branch-transform#9 is fixed by using envify + unreachable-branch-transform |
well this PR got a lot smaller. i therefore demand we write a test for this since our coverage is pretty fab right now |
as it gets the version from package.json (via require), the entire package.json contents end up in the bundle
the envify transform will replace any `process.env` usage with the static values at build time. If the env variable isn't set, nothing will be substituted so it will still pick up the runtime value. This means that any build-time env vars can be statically added to the build without browserify needing to include the browserify-core to get `process` at runtime. Specifically for us, we're grabbing the version out of npm_package_version so that we can skip the package.json require
This transform eliminates dead-code branches. Specifically, we use this so that once the npm_package_version variable has been substituted with a static value (via envify), the || conditional is now satisfied so the package.json require becomes dead code. This transform removes the require so browserify doesn't need to include package.json in the bundle.
@searls rebased to master. test added. put envify back in now that unreachable-branch-transform is usable in place of uglifyify. So browser build runs through envify; gets version string from process.env.npm_package_version; runs through unreachable-branch-transform which kills the package.json require; so package.json is omitted from the build. In node, the version is plucked from the require('package.json').version |
LGTM |
Export `version` property on base object
✨ |
No description provided.