This repository has been archived by the owner on Dec 5, 2019. It is now read-only.
-
-
Notifications
You must be signed in to change notification settings - Fork 181
fix(index): don't remove legal comments by default (options.extractComments
)
#250
Merged
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
117 changes: 70 additions & 47 deletions
117
test/__snapshots__/extract-comments-options.test.js.snap
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,107 +1,130 @@ | ||
// Jest Snapshot v1, https://goo.gl/fbAQLP | ||
|
||
exports[`errors 1`] = `Array []`; | ||
exports[`"options.extractComments" is "boolean" - "true": errors 1`] = `Array []`; | ||
|
||
exports[`errors 2`] = `Array []`; | ||
exports[`"options.extractComments" is "boolean" - "true": test.js 1`] = `"var foo=1;"`; | ||
|
||
exports[`errors 3`] = `Array []`; | ||
|
||
exports[`errors 4`] = `Array []`; | ||
|
||
exports[`errors 5`] = `Array []`; | ||
|
||
exports[`nested/nested/test1.js 1`] = ` | ||
exports[`"options.extractComments" is "boolean" - "true": test1.js 1`] = ` | ||
"/*! For license information please see test1.js.LICENSE */ | ||
var foo=1;" | ||
`; | ||
|
||
exports[`nested/nested/test1.js.LICENSE 1`] = ` | ||
"/* Comment */ | ||
exports[`"options.extractComments" is "boolean" - "true": test1.js.LICENSE 1`] = ` | ||
"/*! Legal Comment */ | ||
" | ||
`; | ||
|
||
exports[`nested/test.js 1`] = ` | ||
exports[`"options.extractComments" is "boolean" - "true": warnings 1`] = `Array []`; | ||
|
||
exports[`"options.extractComments" is "function": errors 1`] = `Array []`; | ||
|
||
exports[`"options.extractComments" is "function": test.js 1`] = ` | ||
"/*! For license information please see test.js.LICENSE */ | ||
var foo=1;" | ||
`; | ||
|
||
exports[`nested/test1.js.LICENSE 1`] = ` | ||
exports[`"options.extractComments" is "function": test.js.LICENSE 1`] = ` | ||
"// Comment | ||
" | ||
`; | ||
|
||
exports[`test.js 1`] = `"var foo=1;"`; | ||
|
||
exports[`test.js 2`] = `"var foo=1;"`; | ||
|
||
exports[`test.js 3`] = ` | ||
"/*! For license information please see test.js.LICENSE */ | ||
exports[`"options.extractComments" is "function": test1.js 1`] = ` | ||
"/*! For license information please see test1.js.LICENSE */ | ||
var foo=1;" | ||
`; | ||
|
||
exports[`test.js 4`] = ` | ||
"/*! For license information please see test.js.LICENSE */ | ||
var foo=1;" | ||
exports[`"options.extractComments" is "function": test1.js.LICENSE 1`] = ` | ||
"/* Comment */ | ||
" | ||
`; | ||
|
||
exports[`test.js 5`] = ` | ||
"/*! For license information please see test1.js.LICENSE */ | ||
var foo=1;" | ||
`; | ||
exports[`"options.extractComments" is "function": warnings 1`] = `Array []`; | ||
|
||
exports[`"options.extractComments" is "object": errors 1`] = `Array []`; | ||
|
||
exports[`test.js 6`] = ` | ||
exports[`"options.extractComments" is "object": test.js 1`] = ` | ||
"/*! License information can be found in test.license.js */ | ||
var foo=1;" | ||
`; | ||
|
||
exports[`test.js.LICENSE 1`] = ` | ||
exports[`"options.extractComments" is "object": test.license.js 1`] = ` | ||
"// Comment | ||
" | ||
`; | ||
|
||
exports[`test.js.LICENSE 2`] = ` | ||
"// Comment | ||
" | ||
exports[`"options.extractComments" is "object": warnings 1`] = `Array []`; | ||
|
||
exports[`"options.extractComments" is "regex": errors 1`] = `Array []`; | ||
|
||
exports[`"options.extractComments" is "regex": test.js 1`] = `"var foo=1;"`; | ||
|
||
exports[`"options.extractComments" is "regex": test1.js 1`] = ` | ||
"/*! For license information please see test1.js.LICENSE */ | ||
var foo=1;" | ||
`; | ||
|
||
exports[`test.license.js 1`] = ` | ||
"// Comment | ||
exports[`"options.extractComments" is "regex": test1.js.LICENSE 1`] = ` | ||
"// foo | ||
" | ||
`; | ||
|
||
exports[`test1.js 1`] = `"var foo=1;"`; | ||
exports[`"options.extractComments" is "regex": warnings 1`] = `Array []`; | ||
|
||
exports[`test1.js 2`] = ` | ||
exports[`"options.extractComments" is "string" - "all" and license file should be relative source file: errors 1`] = `Array []`; | ||
|
||
exports[`"options.extractComments" is "string" - "all" and license file should be relative source file: nested/nested/test1.js 1`] = ` | ||
"/*! For license information please see test1.js.LICENSE */ | ||
var foo=1;" | ||
`; | ||
|
||
exports[`test1.js 3`] = ` | ||
"/*! For license information please see test1.js.LICENSE */ | ||
exports[`"options.extractComments" is "string" - "all" and license file should be relative source file: nested/nested/test1.js.LICENSE 1`] = ` | ||
"/* Comment */ | ||
" | ||
`; | ||
|
||
exports[`"options.extractComments" is "string" - "all" and license file should be relative source file: nested/test.js 1`] = ` | ||
"/*! For license information please see test.js.LICENSE */ | ||
var foo=1;" | ||
`; | ||
|
||
exports[`test1.js.LICENSE 1`] = ` | ||
"// foo | ||
exports[`"options.extractComments" is "string" - "all" and license file should be relative source file: nested/test.js.LICENSE 1`] = ` | ||
"// Comment | ||
" | ||
`; | ||
|
||
exports[`test1.js.LICENSE 2`] = ` | ||
"/* Comment */ | ||
exports[`"options.extractComments" is "string" - "all" and license file should be relative source file: warnings 1`] = `Array []`; | ||
|
||
exports[`"options.extractComments" is "string": errors 1`] = `Array []`; | ||
|
||
exports[`"options.extractComments" is "string": test.js 1`] = ` | ||
"/*! For license information please see test.js.LICENSE */ | ||
var foo=1;" | ||
`; | ||
|
||
exports[`"options.extractComments" is "string": test.js.LICENSE 1`] = ` | ||
"// Comment | ||
" | ||
`; | ||
|
||
exports[`test1.js.LICENSE 3`] = ` | ||
exports[`"options.extractComments" is "string": test1.js 1`] = ` | ||
"/*! For license information please see test1.js.LICENSE */ | ||
var foo=1;" | ||
`; | ||
|
||
exports[`"options.extractComments" is "string": test1.js.LICENSE 1`] = ` | ||
"/* Comment */ | ||
" | ||
`; | ||
|
||
exports[`warnings 1`] = `Array []`; | ||
exports[`"options.extractComments" is "string": warnings 1`] = `Array []`; | ||
|
||
exports[`warnings 2`] = `Array []`; | ||
exports[`"options.extractComments" is not specify: errors 1`] = `Array []`; | ||
|
||
exports[`warnings 3`] = `Array []`; | ||
exports[`"options.extractComments" is not specify: test.js 1`] = `"var foo=1;"`; | ||
|
||
exports[`warnings 4`] = `Array []`; | ||
exports[`"options.extractComments" is not specify: test1.js 1`] = ` | ||
"/*! Legal Comment */ | ||
var foo=1;" | ||
`; | ||
|
||
exports[`warnings 5`] = `Array []`; | ||
exports[`"options.extractComments" is not specify: warnings 1`] = `Array []`; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Shouldn't this be just the
{RegExp}
to always preserve this comments ? Why is theextractComments
check needed here ?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@michael-ciniawsky When we use
extractComments
we should remove their from source code. If you passextractComments: true
andcomments: /^\**!|@preserve|@license|@cc_on/
output will be contain legal comments in source file and generatename.js.LICENSE
fileThere was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Isn't
extractComments
not only responsible for only extracting what's preseverd viauglifyOptions.output.comments
?Why is are these options 'decoupled' ? 🙃
Anyways if that's more complicated atm and this PR now leaves the default preserved comments in the source aswell as
options.extractComments
also preserves the same default comments (with it's own logic) when extracting them into a separate file, then let's do it :)There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@michael-ciniawsky
extractComments
does not responsible uglify comments, they are separatly. If think about your logic. But sometimes people leave comment in source code and generate license file to allow difference type of distribution.