Skip to content

Commit

Permalink
chore(ci): Fix publish build on Windows (#4970)
Browse files Browse the repository at this point in the history
  • Loading branch information
Brooooooklyn committed Jun 14, 2022
1 parent c991848 commit db9f7a5
Show file tree
Hide file tree
Showing 56 changed files with 175 additions and 179 deletions.
4 changes: 3 additions & 1 deletion .github/workflows/publish-node.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ env:
APP_NAME: swc
MACOSX_DEPLOYMENT_TARGET: "10.13"
CARGO_INCREMENTAL: 0
CARGO_PROFILE_RELEASE_LTO: "fat"
CI: "1"

on:
Expand Down Expand Up @@ -39,6 +38,7 @@ jobs:
target: x86_64-pc-windows-msvc
- host: windows-latest
build: |
export CARGO_PROFILE_RELEASE_LTO=false
cargo build -p swc_cli --release --target i686-pc-windows-msvc
cp target/i686-pc-windows-msvc/release/swc .
yarn build --target i686-pc-windows-msvc --cargo-flags="--no-default-features" --features swc_v1
Expand All @@ -56,9 +56,11 @@ jobs:
strip swc.linux-x64-gnu.node
- host: ubuntu-latest
target: x86_64-unknown-linux-musl
# musl build is slow, let's disable the LTO
docker: ghcr.io/napi-rs/napi-rs/nodejs-rust:lts-alpine
build: >-
set -e &&
export CARGO_PROFILE_RELEASE_LTO=false &&
RUSTFLAGS='-C target-feature=+sse2 -Z new-llvm-pass-manager=no' cargo build -p swc_cli --release --features plugin &&
rm -rf target/release/.cargo-lock &&
cp target/release/swc . && chmod +x ./swc &&
Expand Down
2 changes: 2 additions & 0 deletions crates/ast_node/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -199,6 +199,7 @@ pub fn ast_node(
};

item.quote_with(smart_quote!(Vars { input, clone }, {
#[allow(clippy::derive_partial_eq_without_eq)]
#[derive(
::swc_common::FromVariant,
::swc_common::Spanned,
Expand Down Expand Up @@ -257,6 +258,7 @@ pub fn ast_node(

let mut quote =
item.quote_with(smart_quote!(Vars { input, serde_tag, serde_rename }, {
#[allow(clippy::derive_partial_eq_without_eq)]
#[derive(::swc_common::Spanned, Clone, Debug, PartialEq)]
#[derive(::serde::Serialize, ::serde::Deserialize)]
#[cfg_attr(
Expand Down
2 changes: 1 addition & 1 deletion crates/preset_env_base/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ impl BrowserData<Option<Version>> {
let browser = dist.name();
let browser = remap(browser);
let version = dist.version();
match &*browser {
match browser {
"and_qq" | "and_uc" | "baidu" | "bb" | "kaios" | "op_mini" => continue,

_ => {}
Expand Down
2 changes: 1 addition & 1 deletion crates/swc/src/config/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1527,7 +1527,7 @@ impl GlobalPassOption {
cm,
handler,
env::vars()
.filter(|(k, _)| env_list.contains(&*k))
.filter(|(k, _)| env_list.contains(k))
.map(|(k, v)| (k.into(), v.into())),
true,
);
Expand Down
10 changes: 3 additions & 7 deletions crates/swc_bundler/src/bundler/finalize.rs
Original file line number Diff line number Diff line change
Expand Up @@ -89,12 +89,8 @@ where
)
.into();
}
return format!(
"{}-{}",
path.file_stem().unwrap().to_string_lossy(),
hash,
)
.into();
format!("{}-{}", path.file_stem().unwrap().to_string_lossy(), hash,)
.into()
})
.expect("javascript file should have name");
new_name.pop();
Expand Down Expand Up @@ -403,7 +399,7 @@ where
.as_os_str()
.to_string_lossy();
let base = RelativePath::new(&*base);
let v = base.relative(&*v);
let v = base.relative(v);
let value = v.as_str();
return ImportDecl {
src: Str {
Expand Down
4 changes: 2 additions & 2 deletions crates/swc_common/src/comments.rs
Original file line number Diff line number Diff line change
Expand Up @@ -518,7 +518,7 @@ impl SingleThreadedComments {
F: FnOnce(&[Comment]) -> Ret,
{
if let Some(comments) = self.leading.borrow().get(&pos) {
op(&*comments)
op(comments)
} else {
op(&[])
}
Expand All @@ -529,7 +529,7 @@ impl SingleThreadedComments {
F: FnOnce(&[Comment]) -> Ret,
{
if let Some(comments) = self.trailing.borrow().get(&pos) {
op(&*comments)
op(comments)
} else {
op(&[])
}
Expand Down
18 changes: 9 additions & 9 deletions crates/swc_common/src/pos.rs
Original file line number Diff line number Diff line change
Expand Up @@ -93,17 +93,17 @@ where
S: ?Sized + Spanned,
{
fn span(&self) -> Span {
<S as Spanned>::span(&*self)
<S as Spanned>::span(self)
}

#[inline]
fn span_lo(&self) -> BytePos {
<S as Spanned>::span_lo(&*self)
<S as Spanned>::span_lo(self)
}

#[inline]
fn span_hi(&self) -> BytePos {
<S as Spanned>::span_hi(&*self)
<S as Spanned>::span_hi(self)
}
}

Expand All @@ -112,17 +112,17 @@ where
S: ?Sized + Spanned,
{
fn span(&self) -> Span {
<S as Spanned>::span(&*self)
<S as Spanned>::span(self)
}

#[inline]
fn span_lo(&self) -> BytePos {
<S as Spanned>::span_lo(&*self)
<S as Spanned>::span_lo(self)
}

#[inline]
fn span_hi(&self) -> BytePos {
<S as Spanned>::span_hi(&*self)
<S as Spanned>::span_hi(self)
}
}

Expand All @@ -131,17 +131,17 @@ where
S: ?Sized + Spanned,
{
fn span(&self) -> Span {
<S as Spanned>::span(&*self)
<S as Spanned>::span(self)
}

#[inline]
fn span_lo(&self) -> BytePos {
<S as Spanned>::span_lo(&*self)
<S as Spanned>::span_lo(self)
}

#[inline]
fn span_hi(&self) -> BytePos {
<S as Spanned>::span_hi(&*self)
<S as Spanned>::span_hi(self)
}
}

Expand Down
6 changes: 3 additions & 3 deletions crates/swc_common/tests/ast_serde.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,19 +2,19 @@ use serde_json::from_str;
use swc_common::ast_serde;

#[ast_serde]
#[derive(Debug, PartialEq)]
#[derive(Debug, PartialEq, Eq)]
pub enum Ambiguous {
#[tag("A")]
A(A),
#[tag("B")]
B(B),
}
#[ast_serde("B")]
#[derive(Debug, PartialEq)]
#[derive(Debug, PartialEq, Eq)]
pub struct A {}

#[ast_serde("B")]
#[derive(Debug, PartialEq)]
#[derive(Debug, PartialEq, Eq)]
pub struct B {}

#[test]
Expand Down
2 changes: 1 addition & 1 deletion crates/swc_common/tests/attr_interop.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ pub struct Class {
#[ast_node("Tuple")]
pub struct Tuple(#[span] HasSpan, usize, usize);

#[derive(Debug, Clone, PartialEq, Spanned, Serialize, Deserialize)]
#[derive(Debug, Clone, PartialEq, Eq, Spanned, Serialize, Deserialize)]
#[cfg_attr(
feature = "rkyv",
derive(rkyv::Archive, rkyv::Serialize, rkyv::Deserialize)
Expand Down
2 changes: 1 addition & 1 deletion crates/swc_css_codegen/src/emit.rs
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ where
#[inline]
fn emit(&mut self, node: &Option<T>) -> Result {
match node {
Some(node) => self.emit(&*node),
Some(node) => self.emit(node),
None => Ok(()),
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ impl FontFamilyNoDuplicateNames {
ComponentValue::Ident(Ident { value, span, .. }) => {
if let Some((mut identifier, last_span)) = last_identifier {
identifier.push(' ');
identifier.push_str(&*value);
identifier.push_str(value);
(fonts, Some((identifier, last_span.with_hi(span.hi()))))
} else {
(fonts, Some((value.to_string(), *span)))
Expand Down
4 changes: 2 additions & 2 deletions crates/swc_css_parser/src/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ use swc_common::{
};

/// Size is same as a size of a pointer.
#[derive(Debug, Clone, PartialEq)]
#[derive(Debug, Clone, PartialEq, Eq)]
pub struct Error {
inner: Box<(Span, ErrorKind)>,
}
Expand Down Expand Up @@ -68,7 +68,7 @@ impl Error {
}
}

#[derive(Debug, Clone, PartialEq)]
#[derive(Debug, Clone, PartialEq, Eq)]
#[non_exhaustive]
pub enum ErrorKind {
Eof,
Expand Down
3 changes: 1 addition & 2 deletions crates/swc_css_parser/src/parser/at_rule.rs
Original file line number Diff line number Diff line change
Expand Up @@ -631,9 +631,8 @@ where
block_contents_grammar: BlockContentsGrammar::NoGrammar,
..self.ctx
};
let block = self.with_ctx(ctx).parse_as::<SimpleBlock>()?;

block
self.with_ctx(ctx).parse_as::<SimpleBlock>()?
}
};

Expand Down
6 changes: 3 additions & 3 deletions crates/swc_css_prefixer/src/prefixer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -232,8 +232,8 @@ impl VisitMut for LinearGradientFunctionReplacerOnLegacyVariant<'_> {
})),
) => {
if let (Some(new_first_direction), Some(new_second_direction)) = (
get_old_direction(&*first_value),
get_old_direction(&*second_value),
get_old_direction(first_value),
get_old_direction(second_value),
) {
let new_value = vec![
ComponentValue::Ident(Ident {
Expand All @@ -252,7 +252,7 @@ impl VisitMut for LinearGradientFunctionReplacerOnLegacyVariant<'_> {
}
}
(Some(ComponentValue::Ident(Ident { value, span, .. })), Some(_)) => {
if let Some(new_direction) = get_old_direction(&*value) {
if let Some(new_direction) = get_old_direction(value) {
let new_value = vec![ComponentValue::Ident(Ident {
span: *span,
value: new_direction.into(),
Expand Down
4 changes: 2 additions & 2 deletions crates/swc_ecma_codegen/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ where

if let Some(ref shebang) = node.shebang {
punct!("#!");
self.wr.write_str_lit(DUMMY_SP, &*shebang)?;
self.wr.write_str_lit(DUMMY_SP, shebang)?;
self.wr.write_line()?;
}
for stmt in &node.body {
Expand All @@ -113,7 +113,7 @@ where

if let Some(ref shebang) = node.shebang {
punct!("#!");
self.wr.write_str_lit(DUMMY_SP, &*shebang)?;
self.wr.write_str_lit(DUMMY_SP, shebang)?;
self.wr.write_line()?;
}
for stmt in &node.body {
Expand Down
4 changes: 2 additions & 2 deletions crates/swc_ecma_lints/src/rules/no_alert.rs
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ impl NoAlert {

fn check(&self, call_span: Span, obj: &Option<JsWord>, prop: &JsWord) {
if let Some(obj) = obj {
let obj_name: &str = &*obj;
let obj_name: &str = obj;

if self.pass_call_on_global_this && obj_name == GLOBAL_THIS_PROP {
return;
Expand All @@ -100,7 +100,7 @@ impl NoAlert {
}
}

let fn_name: &str = &*prop;
let fn_name: &str = prop;

if FN_NAMES.contains(&fn_name) {
self.emit_report(call_span, fn_name);
Expand Down
2 changes: 1 addition & 1 deletion crates/swc_ecma_lints/src/rules/no_console.rs
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ impl Visit for NoConsole {
if let Expr::Ident(ident) = member.obj.as_ref() {
match &member.prop {
MemberProp::Ident(Ident { sym, .. }) => {
self.check(member.span, ident, &*sym);
self.check(member.span, ident, sym);
}
MemberProp::Computed(ComputedPropName { expr, .. }) => {
if let Expr::Lit(Lit::Str(Str { value, .. })) = expr.as_ref() {
Expand Down
2 changes: 1 addition & 1 deletion crates/swc_ecma_lints/src/rules/no_loop_func.rs
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ impl NoLoopFunc {
let mut names = self
.current_fn_unsafe_vars
.iter()
.map(|js_word| (&*js_word) as &str)
.map(|js_word| js_word as &str)
.collect::<Vec<&str>>();

let message = if names.len() == 1 {
Expand Down
2 changes: 1 addition & 1 deletion crates/swc_ecma_lints/src/rules/no_throw_literal.rs
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ impl NoThrowLiteral {
}

if let Expr::Ident(Ident { sym, .. }) = arg {
if &*sym == "undefined" {
if sym == "undefined" {
self.emit_report(throw_stmt.span, NO_THROW_UNDEFINED);
}
}
Expand Down
2 changes: 1 addition & 1 deletion crates/swc_ecma_lints/src/rules/prefer_regex_literals.rs
Original file line number Diff line number Diff line change
Expand Up @@ -213,7 +213,7 @@ impl Visit for PreferRegexLiterals {
}
MemberProp::Computed(comp) => {
if let Expr::Lit(Lit::Str(Str { value, .. })) = comp.expr.as_ref() {
self.check(&*value);
self.check(value);
}
}
_ => {}
Expand Down
8 changes: 4 additions & 4 deletions crates/swc_ecma_lints/src/rules/quotes.rs
Original file line number Diff line number Diff line change
Expand Up @@ -87,14 +87,14 @@ impl Quotes {

match (&self.prefer, &found_quote_type) {
(QuotesType::Double, QuotesType::Single) => {
if self.avoid_escape && self.is_mirroring_escape(&*value) {
if self.avoid_escape && self.is_mirroring_escape(value) {
return;
}

self.emit_report(*span);
}
(QuotesType::Single, QuotesType::Double) => {
if self.avoid_escape && self.is_mirroring_escape(&*value) {
if self.avoid_escape && self.is_mirroring_escape(value) {
return;
}

Expand All @@ -105,7 +105,7 @@ impl Quotes {
return;
}

if self.avoid_escape && self.is_mirroring_escape(&*value) {
if self.avoid_escape && self.is_mirroring_escape(value) {
return;
}

Expand Down Expand Up @@ -153,7 +153,7 @@ impl Visit for Quotes {

fn visit_expr_stmt(&mut self, expr_stmt: &ExprStmt) {
if let Expr::Lit(Lit::Str(Str { value, .. })) = expr_stmt.expr.as_ref() {
let value: &str = &*value;
let value: &str = value;

if DIRECTIVES.contains(&value) {
return;
Expand Down
2 changes: 1 addition & 1 deletion crates/swc_ecma_lints/src/rules/use_is_nan.rs
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ impl UseIsNan {
}
MemberProp::Computed(ComputedPropName { expr, .. }) => {
if let Expr::Lit(Lit::Str(Str { value, .. })) = expr.as_ref() {
if &*value == "NaN" {
if value == "NaN" {
self.emit_report(expr_span.unwrap_or(*span), label_msg);
}
}
Expand Down
2 changes: 1 addition & 1 deletion crates/swc_ecma_lints/src/rules/utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ impl QuotesType {

pub fn resolve_string_quote_type(lit_str: &Str) -> Option<QuotesType> {
lit_str.raw.as_ref().and_then(|raw| {
let byte = (&*raw).as_bytes()[0];
let byte = raw.as_bytes()[0];

match byte {
b'\'' => Some(QuotesType::Single),
Expand Down

1 comment on commit db9f7a5

@github-actions
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Benchmark

Benchmark suite Current: db9f7a5 Previous: 5c2a918 Ratio
es/full/minify/libraries/antd 1663227641 ns/iter (± 52117482) 1675582903 ns/iter (± 101926657) 0.99
es/full/minify/libraries/d3 424314646 ns/iter (± 8855939) 416728037 ns/iter (± 11228072) 1.02
es/full/minify/libraries/echarts 1790545232 ns/iter (± 84705966) 1722201248 ns/iter (± 100871812) 1.04
es/full/minify/libraries/jquery 94361406 ns/iter (± 2774214) 113867074 ns/iter (± 7830739) 0.83
es/full/minify/libraries/lodash 126398544 ns/iter (± 10301673) 138505711 ns/iter (± 3973583) 0.91
es/full/minify/libraries/moment 50657027 ns/iter (± 1165349) 52255304 ns/iter (± 1640076) 0.97
es/full/minify/libraries/react 17613172 ns/iter (± 425512) 18457293 ns/iter (± 862819) 0.95
es/full/minify/libraries/terser 586141434 ns/iter (± 14980546) 613613767 ns/iter (± 25908572) 0.96
es/full/minify/libraries/three 534960323 ns/iter (± 6192283) 537649383 ns/iter (± 20912549) 0.99
es/full/minify/libraries/typescript 3561040365 ns/iter (± 111000986) 3424783247 ns/iter (± 140702845) 1.04
es/full/minify/libraries/victory 839478439 ns/iter (± 47805612) 725455189 ns/iter (± 17116270) 1.16
es/full/minify/libraries/vue 146634901 ns/iter (± 11632843) 145443947 ns/iter (± 11137797) 1.01
es/full/codegen/es3 33210 ns/iter (± 5451) 32530 ns/iter (± 2081) 1.02
es/full/codegen/es5 32139 ns/iter (± 5008) 32845 ns/iter (± 4296) 0.98
es/full/codegen/es2015 32141 ns/iter (± 2212) 32991 ns/iter (± 4454) 0.97
es/full/codegen/es2016 31688 ns/iter (± 3351) 32939 ns/iter (± 1359) 0.96
es/full/codegen/es2017 32030 ns/iter (± 3799) 32523 ns/iter (± 1265) 0.98
es/full/codegen/es2018 31714 ns/iter (± 2505) 33098 ns/iter (± 2040) 0.96
es/full/codegen/es2019 32169 ns/iter (± 3088) 33038 ns/iter (± 4684) 0.97
es/full/codegen/es2020 32065 ns/iter (± 2310) 33007 ns/iter (± 2113) 0.97
es/full/all/es3 197998003 ns/iter (± 7021100) 198477303 ns/iter (± 7406998) 1.00
es/full/all/es5 186891110 ns/iter (± 11040353) 186389999 ns/iter (± 6879945) 1.00
es/full/all/es2015 149739736 ns/iter (± 7772135) 150760924 ns/iter (± 5781772) 0.99
es/full/all/es2016 150871858 ns/iter (± 6697896) 148983255 ns/iter (± 5610228) 1.01
es/full/all/es2017 147133427 ns/iter (± 5766240) 151368650 ns/iter (± 7577131) 0.97
es/full/all/es2018 156607692 ns/iter (± 10506533) 149920941 ns/iter (± 6221127) 1.04
es/full/all/es2019 150596085 ns/iter (± 78434503) 146254091 ns/iter (± 5286977) 1.03
es/full/all/es2020 147413363 ns/iter (± 9353374) 142037432 ns/iter (± 4884686) 1.04
es/full/parser 734037 ns/iter (± 38718) 721723 ns/iter (± 47465) 1.02
es/full/base/fixer 30611 ns/iter (± 2634) 29794 ns/iter (± 2475) 1.03
es/full/base/resolver_and_hygiene 140778 ns/iter (± 12228) 135823 ns/iter (± 7315) 1.04
serialization of ast node 210 ns/iter (± 11) 215 ns/iter (± 33) 0.98
serialization of serde 220 ns/iter (± 6) 227 ns/iter (± 12) 0.97

This comment was automatically generated by workflow using github-action-benchmark.

Please sign in to comment.