Skip to content
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

Add comment header to bundle #2459

Closed
magcius opened this issue Dec 24, 2018 · 6 comments
Closed

Add comment header to bundle #2459

magcius opened this issue Dec 24, 2018 · 6 comments
Labels

Comments

@magcius
Copy link

magcius commented Dec 24, 2018

❔ Question

Hi. How can I provide a comment header in the final bundle output?

πŸ”¦ Context

I would like to point users to where they can see the original GitHub project.

This is also a legal requirement to include proper license headers on external modules. I tried using "@preserve" JSDoc, and while terser does seem to include it sometimes, it's tucked away in a module (which is in random order in the final output), and it doesn't seem to consistently be kept in the output, bizarrely enough.

πŸ’» Code Sample

None.

🌍 Your Environment

Software Version(s)
Parcel 1.10.0
Node v10.0.0
npm/Yarn npm v6.5.0
Operating System Windows 10
@DeMoorJasper
Copy link
Member

Pretty sure it's not an issue to have license headers above the actual licensed code instead of on top of the bundle. Pretty sure terser doesn't remove license headers by default and neither does parcel.

@magcius
Copy link
Author

magcius commented Dec 26, 2018

terser will remove all comments by default unless you pass { "output": { "comments": "some" } }.

Since each module by default is on its own newline from what I can tell, the module's license header can get lost down at the bottom. And the newline after the license header appears to be stripped (probably a terser bug). So it just becomes very difficult to see.

Try to find the license header in this: http://noclip.website/main.cdfad9f2.js

@DeMoorJasper
Copy link
Member

DeMoorJasper commented Dec 26, 2018

@magcius Thought the original issue was about license headers of libraries, but bundler licenses makes sense. Although not sure how this should be implemented.

@outofambit
Copy link

@DeMoorJasper Is there interest from the maintainers to add a comment header to the bundle? I would be happy to take this on, as I'm hitting this issue in processing/p5.js#3431. I think it would be relatively straightforward.

I think we could add the option in as 'bundleHeader' (or maybe 'banner' like rollup?), which would be an optional string.

normalizeOptions(options) {

and write in the bundle somewhere near

async setup() {
// Create sub-directories if needed
if (this.bundle.name.includes(path.sep)) {
await mkdirp(path.dirname(this.bundle.name));
}
this.dest = fs.createWriteStream(this.bundle.name);
this.dest.write = promisify(this.dest.write.bind(this.dest));
this.dest.end = promisify(this.dest.end.bind(this.dest));
}

This would let us write the same string at the top of every package file type, and require no modification of plugins to support.

@DeMoorJasper
Copy link
Member

@outofambit yes feel free to work on this issue. It’ll be necessary at some point

Sent with GitHawk

@github-actions
Copy link

This issue has been automatically marked as stale because it has not had recent activity. It will be closed in 14 days if no further activity occurs.

@github-actions github-actions bot added the Stale Inactive issues label Jan 17, 2020
@github-actions github-actions bot closed this as completed Feb 2, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants