Skip to content

Commit a065139

Browse files
authored
feat: make license banner comment more concise (#12960)
* feat: make license banner comment more concise * fix
1 parent 91c4e86 commit a065139

File tree

7 files changed

+7
-11
lines changed

7 files changed

+7
-11
lines changed

crates/rspack_plugin_swc_js_minimizer/src/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -226,7 +226,7 @@ async fn process_assets(&self, compilation: &mut Compilation) -> Result<()> {
226226
let dir = Path::new(filename).parent().expect("should has parent");
227227
let raw = Path::new(&comments_filename).strip_prefix(dir).expect("should has common prefix").to_string_lossy();
228228
let relative = raw.cow_replace('\\', "/");
229-
Some(format!("/*! For license information please see {relative} */"))
229+
Some(format!("/*! LICENSE: {relative} */"))
230230
},
231231
OptionWrapper::Disabled => None,
232232
OptionWrapper::Custom(value) => Some(format!("/*! {value} */"))

tests/rspack-test/configCases/plugins/rspack-issue-5068-1/index.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,6 @@ const fs = require("fs");
2929
// @lic
3030

3131
it("should not contain banner", () => {
32-
const banner = fs.readFileSync(__filename, "utf-8").startsWith(`/*! For license information please see bundle0.js.LICENSE.txt */`);
32+
const banner = fs.readFileSync(__filename, "utf-8").startsWith(`/*! LICENSE: bundle0.js.LICENSE.txt */`);
3333
expect(banner).toBeFalsy();
3434
});

tests/rspack-test/configCases/plugins/swc-js-minifier/index.js

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,7 @@ it("should remove extracted comments and insert a banner", function () {
77
expect(source).not.toMatch("comment should be stripped extract-test.2");
88
expect(source).not.toMatch("comment should be extracted extract-test.3");
99
expect(source).not.toMatch("comment should be stripped extract-test.4");
10-
expect(source).toMatch(
11-
"/*! For license information please see extract.js.LICENSE.txt */"
12-
);
10+
expect(source).toMatch("/*! LICENSE: extract.js.LICENSE.txt */");
1311
});
1412

1513
it("should not generated comment banner when there no comments", function () {

tests/rspack-test/configCases/plugins/terser-plugin/index.js

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -44,9 +44,7 @@ it("should remove extracted comments and insert a banner", function() {
4444
expect(source).not.toMatch("comment should be stripped extract-test.2");
4545
expect(source).not.toMatch("comment should be extracted extract-test.3");
4646
expect(source).not.toMatch("comment should be stripped extract-test.4");
47-
expect(source).toMatch(
48-
"/*! For license information please see extract.js.LICENSE.txt */"
49-
);
47+
expect(source).toMatch("/*! For license information please see extract.js.LICENSE.txt */");
5048
});
5149

5250
it("should pass mangle options", function() {

tests/rspack-test/configCases/process-assets/html-plugin/index.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ it("should result in the correct HTML", () => {
1212
expect(content).toMatch(/<\/script> <script/);
1313

1414
// check inlined js is minimized
15-
expect(content).toMatch(/For license information please see inline-/);
15+
expect(content).toMatch(/LICENSE: inline-/);
1616

1717
// contains references to normal-[contenthash].js
1818
expect(content).toMatch(/normal-.{20}\.js/);

website/docs/en/plugins/rspack/swc-js-minimizer-rspack-plugin.mdx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -132,7 +132,7 @@ new rspack.SwcJsMinimizerRspackPlugin({
132132
// add comments that match the condition will be extracted
133133
condition: /@preserve|@lic|@cc_on|^\**!/,
134134
// add banner to the top of the `*.LICENSE.txt` file
135-
// If `true`, use the default banner `/*! For license information please see {relative} */`
135+
// If `true`, use the default banner `/*! LICENSE: {relative} */`
136136
// If `false`, no banner will be added
137137
// If `string`, use the given banner
138138
banner: true,

website/docs/zh/plugins/rspack/swc-js-minimizer-rspack-plugin.mdx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -132,7 +132,7 @@ new rspack.SwcJsMinimizerRspackPlugin({
132132
// 将匹配的注释提取到单独的文件中
133133
condition: /@preserve|@lic|@cc_on|^\**!/,
134134
// 在 `*.LICENSE.txt` 文件顶部的横幅
135-
// 如果为 `true`,则使用默认的横幅 `/*! For license information please see {relative} */`
135+
// 如果为 `true`,则使用默认的横幅 `/*! LICENSE: {relative} */`
136136
// 如果为 `false`,则不添加横幅
137137
// 如果为 `string`,则使用给定的横幅
138138
banner: true,

0 commit comments

Comments
 (0)