-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
How about adding a generate header(like CoffeeScript)? #380
Comments
You can already do this with
This isn't the sort of thing isn't in scope for browserify. browserify doesn't know what coffee script is, it just provides a transform api for other modules. |
One more concern: if I add one line before that file by hand, will it break sourecemap? |
@substack: You've misunderstood the request. @jiyinyiyong was asking for browserify to mark the code it generates as generated by browserify. @jiyinyiyong : Yes, it would if browserify generated real source maps. Yet another reason for browserify to work with a structured representation of JS (preferably a standard like the spidermonkey AST format). Asking people to do string manipulation of the output is insane. |
Yeah, I think a header generated from browserify is more reliable. |
@michaelficarra That is really silly. Transforms work on strings. Strings are easy. If you want an AST just As for the other points, what is the benefit of adding a header comment to browserify builds? I don't understand the upside well enough to support this. |
The same reason the CoffeeScript compiler adds it. So people (and programs) that read the output know that it was generated from other source files.
And strings are lossy. They don't preserve information such as the source file/position through transforms. They are also much less useful to other tools. My browser bundler, commonjs-everywhere, supports taking input from arbitrary compile-to-JS languages, bundling, and running the program through a minifier, all while preserving source content/position information because all of these tools use a standard, structured JS representation as an IR. This means people can debug their CoffeeScript source files from minified browser bundles, with basically no extra work on my part. Arguments like "strings are easy" from maintainers of popular projects are why we can't have nice things. You should be more concerned with what is objectively the best solution for your users and the JS ecosystem as a whole. |
Browserify already has a very nice way of nesting inline source maps, which removes the need for this. Please stop adding noise to my issues feed. You are very uninformed about how browserify actually works and just seem to be hijacking my issues to promote your own project. |
BTW to not break or fix source maps you have two options:
I agree that b) seems like a lot of work, but if you must have a header in the bundle file that no one will look at, you at least have this option. |
I was trying to do a simple builds with an attached version comment at the top using the following script "scripts": {
"build": "cat <(echo '// mypkg-x.y.z') <(NODE_ENV=production browserify -r ./client/main.js:mypkg | uglifyjs -cm) > dist/mypkg.min.js"
} But "scripts": {
"build": "{ echo '// mypkg-x.y.z'; NODE_ENV=production browserify -r ./client/main.mypkg | uglifyjs -cm; } > dist/mypkg.min.js"
} If there's a better way to do this kind of thing without lots of other configuration/dependencies, I'm unaware. Anyone with +1 intelligence should chime in here and help us plebs out. |
When I put my repo onto Github, it was recognized as a JS repo.
Actually it's writtern in CoffeeScript, with
build.js
generated by BrowserifyHow about adding a header which is similar to CoffeeScript's?
// Generated by CoffeeScript 1.6.2
jashkenas/coffeescript#1778
The text was updated successfully, but these errors were encountered: