diff --git a/.github/workflows/CI.yml b/.github/workflows/CI.yml index ba363633fb51..c18b17f08c09 100644 --- a/.github/workflows/CI.yml +++ b/.github/workflows/CI.yml @@ -163,6 +163,7 @@ jobs: profile: minimal - name: Patch + shell: bash run: | echo '[patch.crates-io]' >> bindings/Cargo.toml ./scripts/cargo/patch-section.sh >> bindings/Cargo.toml @@ -703,6 +704,7 @@ jobs: ${{ !contains(github.event.head_commit.message, 'chore: ') }} runs-on: ${{ matrix.os }} strategy: + fail-fast: false matrix: os: - ubuntu-latest @@ -723,8 +725,10 @@ jobs: cache: "yarn" - name: Patch + shell: bash run: | echo '[patch.crates-io]' >> bindings/Cargo.toml + ./scripts/cargo/patch-section.sh ./scripts/cargo/patch-section.sh >> bindings/Cargo.toml cd bindings && cargo update @@ -784,6 +788,7 @@ jobs: run: curl https://rustwasm.github.io/wasm-pack/installer/init.sh -sSf | sh - name: Patch + shell: bash run: | echo '[patch.crates-io]' >> bindings/Cargo.toml ./scripts/cargo/patch-section.sh >> bindings/Cargo.toml diff --git a/crates/swc_ecma_codegen/src/comments.rs b/crates/swc_ecma_codegen/src/comments.rs index cfbae4524627..8ab20dcfb7d7 100644 --- a/crates/swc_ecma_codegen/src/comments.rs +++ b/crates/swc_ecma_codegen/src/comments.rs @@ -12,17 +12,21 @@ macro_rules! write_comments { for cmt in cmts.iter() { match cmt.kind { CommentKind::Line => { - if $prefix_space { + if $prefix_space && !$e.cfg.minify { $e.wr.write_comment(" ")?; } + srcmap!($e, cmt, true); + $e.wr.write_comment("//")?; $e.wr.write_comment(&cmt.text)?; + srcmap!($e, cmt, false); + $e.wr.write_line()?; } CommentKind::Block => { - if $prefix_space { + if $prefix_space && !$e.cfg.minify { $e.wr.write_comment(" ")?; } @@ -39,7 +43,9 @@ macro_rules! write_comments { } $e.wr.write_comment("*/")?; - $e.wr.write_space()?; + if !$e.cfg.minify { + $e.wr.write_space()?; + } } } } diff --git a/crates/swc_html_minifier/tests/fixture/element/script-custom-type/input.html b/crates/swc_html_minifier/tests/fixture/element/script-custom-type/input.html new file mode 100644 index 000000000000..a496dde9fbe1 --- /dev/null +++ b/crates/swc_html_minifier/tests/fixture/element/script-custom-type/input.html @@ -0,0 +1,36 @@ + + + + + + Document + + + + + + + + + \ No newline at end of file diff --git a/crates/swc_html_minifier/tests/fixture/element/script-custom-type/output.min.html b/crates/swc_html_minifier/tests/fixture/element/script-custom-type/output.min.html new file mode 100644 index 000000000000..6cff95ddb7b7 --- /dev/null +++ b/crates/swc_html_minifier/tests/fixture/element/script-custom-type/output.min.html @@ -0,0 +1,21 @@ +Document \ No newline at end of file diff --git a/crates/swc_html_minifier/tests/fixture/element/script-options-2/output.min.html b/crates/swc_html_minifier/tests/fixture/element/script-options-2/output.min.html index 6d41c04d5b3d..53a43058c459 100644 --- a/crates/swc_html_minifier/tests/fixture/element/script-options-2/output.min.html +++ b/crates/swc_html_minifier/tests/fixture/element/script-options-2/output.min.html @@ -1,5 +1,5 @@ Document
Script:
- +
Module:
- \ No newline at end of file + \ No newline at end of file diff --git a/crates/swc_html_minifier/tests/fixture/element/script-options/input.html b/crates/swc_html_minifier/tests/fixture/element/script-options/input.html index f016d1f1ea27..cbf693352cab 100644 --- a/crates/swc_html_minifier/tests/fixture/element/script-options/input.html +++ b/crates/swc_html_minifier/tests/fixture/element/script-options/input.html @@ -13,5 +13,16 @@ // Keep comment console.log("test " + "😀" + " test"); + + \ No newline at end of file diff --git a/crates/swc_html_minifier/tests/fixture/element/script-options/output.min.html b/crates/swc_html_minifier/tests/fixture/element/script-options/output.min.html index ea04c8525427..49f040443a4c 100644 --- a/crates/swc_html_minifier/tests/fixture/element/script-options/output.min.html +++ b/crates/swc_html_minifier/tests/fixture/element/script-options/output.min.html @@ -1,2 +1,4 @@ -Document \ No newline at end of file +Document \ No newline at end of file diff --git a/node-swc/__tests__/minify_test.mjs b/node-swc/__tests__/minify_test.mjs index a71375e3c36b..f090a2d55455 100644 --- a/node-swc/__tests__/minify_test.mjs +++ b/node-swc/__tests__/minify_test.mjs @@ -191,7 +191,7 @@ describe("should remove comments", () => { ); }); - it("should preserve licnese", async () => { + it("should preserve license", async () => { const { code } = await swc.minify( ` (function(){ @@ -213,10 +213,10 @@ describe("should remove comments", () => { expect(code).toMatchInlineSnapshot(` "(function(){/** * @license - */ const o=Math.random()+\\"_\\"+Math.random();console.log(o)})();" + */const o=Math.random()+\\"_\\"+Math.random();console.log(o)})();" `); }); - it("should remove comment near to licnese", async () => { + it("should remove comment near to license", async () => { const { code } = await swc.minify( ` (function(){ @@ -241,7 +241,7 @@ describe("should remove comments", () => { expect(code).toMatchInlineSnapshot(` "(function(){/** * @license - */ const o=Math.random()+\\"_\\"+Math.random();console.log(o)})();" + */const o=Math.random()+\\"_\\"+Math.random();console.log(o)})();" `); }); }); diff --git a/scripts/cargo/patch-section.sh b/scripts/cargo/patch-section.sh index e7c4b865e5d8..6de3730001ff 100755 --- a/scripts/cargo/patch-section.sh +++ b/scripts/cargo/patch-section.sh @@ -5,11 +5,13 @@ set -eu SCRIPT_DIR=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd ) function toLine { - arr=(${1//\\\t/ }) + # >&2 echo "toLine: $@" + arr=(${1//,/ }) + # >&2 echo "arr: ${arr[0]} ${arr[1]}" dir="$(dirname ${arr[1]})" echo "${arr[0]} = { path = '$dir' }" } export -f toLine -$SCRIPT_DIR/list-crates.sh | jq '[.name, .manifest_path] | @tsv' | xargs -L 1 -I {} bash -c 'toLine "$@"' _ {} \ No newline at end of file +$SCRIPT_DIR/list-crates.sh | jq '[.name, .manifest_path] | @csv' -r | xargs -I {} bash -c 'toLine "$@"' _ {} \ No newline at end of file