-
Notifications
You must be signed in to change notification settings - Fork 146
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
Using banner option results in an incorrect source-map #362
Comments
Looking into the code, the problem is that the banner is added after the bundle is created (and thus the source-map) which explains why the source code appears to be offset from the real position. I don't know browserify internals enough to give a solution right now, but imagine the banner should be added to the buffer earlier on, probably before creating the source-map. |
Having a quick look, a better solution would probably be to change the browerify bundle pipeline (could probably be done in the prebundlecb option) and inject a "banner" handler before the If I get some time over later I'll have a 🔪 at this. |
To whoever who encounters this issue here is a workaround until I get time to implement a PR, or if someone beats me to it 🙏 Provide a custom var path = require('path');
var defaultPreludePath = grunt.file.read(
path.join('node_modules', 'browserify', 'node_modules', 'browser-pack', '_prelude.js')
);
...
browserifyOptions: {
debug: true, // to generate source maps
prelude: [
'// the custom header',
'// another line',
defaultPreludePath
].join("\n")
... |
I've just encountered this problem also. I worked around it by adding a banner only in my production build, and enabling source maps only in my dev build. This met my needs, since I don't want source maps in production and I don't care about a banner when i'm developing. Hopefully this is helpful to someone :) |
Really the same issue as @lcrespom wrote on the merged&closed PR #253, just creating a separate issue for this:
Sounds like a bug to me, does anyone have a solution/workaround for this?
The text was updated successfully, but these errors were encountered: