-
Notifications
You must be signed in to change notification settings - Fork 21
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
/** vs /*! multiline comment style #308
Comments
Hi @revelt, This plugin use module.exports = {
plugins: [
license({
banner: `/*! Copyright <%= moment().format('YYYY') %> */`,
}),
],
} Otherwise, it will add generate a comment block using |
I had a think about this, I'd say option is the most flexible way. Plus, if we implement a dedicated option, you could strip all existing comment blocks from the banner and this way convert the style if any was present. This would allow us to support cases:
What if we hungrily chomped any kinds of opening comment blocks from the beginning of the banner (considering those might be stacked with whitespace in between), then, same way chomp tail of the banner. Then, wrap with preferred style What do you think? Thanks for looking into this. |
PS. I raised an issue in 3rd-Eden/commenting#8 to allow |
I think, this can already be done with current version of const commenting = require('commenting');
const header = commenting(text.trim(), {
extension: '.js',
style: new commenting.Style(' *','/*!', ' */'),
}); The only question is: what do you suggest as option name (and I will be happy to implement that, or if you like, you can submit a PR)? :) |
HM, that's a pickle. I did look around, I can't find a formal name how they're called. Maybe option could be something like |
Hi all, may I suggest that the user can define a commenting style in the banner object to extend the functionality of what we have now, or specify not using a style. license({
banner: {
file: path.join(__dirname, 'HEAD'),
commentingStyle: ['body', 'start', 'end'], // user defined style
noCommenting: true, // no style used, prepend text as is
}), Where Background: I prepend a Greasemonkey Meta Block. My use case works well with a banner file as a lodash template to insert version number script title, url links and so forth and already has If you like my proposal I could do some tests and if I'm happy with the results submit a PR for discussion. |
^ very logical |
@revelt @subz390 I was not a big fan of having two options for more or less the same thing and I was not a big fan of giving an option to define the comment style like this. So, I added an option to specify the comment style using name linking to "pre-defined" style: license({
banner: {
file: path.join(__dirname, 'HEAD'),
commentStyle: 'regular', // the default, other options may be: `ignored', `slash` or `none`
}), What this option mean:
What do you think? Is that ok for you? Would you like to suggest an improvement? |
Thank you, I'm happy 👍 |
Your suggestion gets my +1 vote, thank you 👍 |
I'm quite excited, updated my rollup configs already, waiting for release... |
@mjeanroy how do we customise the comment style if license({
banner: licenseStr,
commentStyle: "ignored"
}) I could stick the license string into a plain object and put license({
banner: {
?: licenseStr,
commentStyle: "ignored"
},
}) thank you for help. |
Just got around to updating my |
Very popular npm packages and projects use a different comment style, one which starts with
/*!
, with exclamation mark.I wonder, why are we using
/**
instead of/*!
and should we switch to the latter?As far as I see
/*!
are used to prevent JS minifiers from stripping the block and many famous projects are using exactly this way. For example, Vue: https://unpkg.com/vueThe text was updated successfully, but these errors were encountered: