Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions .cargo/config.toml
Original file line number Diff line number Diff line change
Expand Up @@ -27,3 +27,10 @@ rustflags = ["-C", "target-feature=-crt-static", "-C", "link-arg=-lgcc"]

[target.armv7-unknown-linux-gnueabihf]
linker = "arm-linux-gnueabihf-gcc"

# We have not adapt this cfg for swc_ecma_minifier, which styled_jsx depends on.
# So we have to manually enable it for all crates except styled jsx.
# [target.'cfg(target_arch = "wasm32")']
# rustflags = [
# "--cfg=swc_ast_unknown"
# ]
20 changes: 20 additions & 0 deletions .github/workflows/CI.yml
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,25 @@ jobs:
run: |
pnpm test

cargo-check:
name: "Check (swc_ast_unknown)"
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
with:
submodules: true

- uses: Swatinem/rust-cache@v2
with:
shared-key: "cargo-check"
cache-on-failure: true

- name: Run cargo check
env:
RUSTFLAGS: "--cfg swc_ast_unknown"
run: |
cargo check --workspace --exclude swc_plugin_styled_jsx --exclude styled_jsx

cargo-test:
strategy:
fail-fast: false
Expand Down Expand Up @@ -128,6 +147,7 @@ jobs:
done:
needs:
- npm-test
- cargo-check
- cargo-test
if: >-
${{ always() }}
Expand Down
46 changes: 19 additions & 27 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions contrib/mut-cjs-exports/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -28,3 +28,6 @@ swc_core = { workspace = true, features = [
[dev-dependencies]
swc_core = { workspace = true, features = ["testing_transform", "ecma_parser"] }
testing = { workspace = true }

[lints.rust]
unexpected_cfgs = { level = "warn", check-cfg = ['cfg(swc_ast_unknown)'] }
4 changes: 2 additions & 2 deletions contrib/mut-cjs-exports/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@
"commonjs"
],
"scripts": {
"build": "cargo build --release --target wasm32-unknown-unknown && cp ../../target/wasm32-unknown-unknown/release/swc_mut_cjs_exports.wasm .",
"build:debug": "cargo build --target wasm32-unknown-unknown && cp ../../target/wasm32-unknown-unknown/debug/swc_mut_cjs_exports.wasm ./swc_mut_cjs_exports_debug.wasm",
"build": "RUSTFLAGS='--cfg swc_ast_unknown' cargo build --release --target wasm32-unknown-unknown && cp ../../target/wasm32-unknown-unknown/release/swc_mut_cjs_exports.wasm .",
"build:debug": "RUSTFLAGS='--cfg swc_ast_unknown' cargo build --target wasm32-unknown-unknown && cp ../../target/wasm32-unknown-unknown/debug/swc_mut_cjs_exports.wasm ./swc_mut_cjs_exports_debug.wasm",
"test": "pnpm run build:debug && jest",
"prepack": "pnpm run build"
},
Expand Down
11 changes: 11 additions & 0 deletions contrib/mut-cjs-exports/src/local_export_strip.rs
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,8 @@ impl VisitMut for LocalExportStrip {
_ => list.push(module_decl.into()),
};
}
#[cfg(swc_ast_unknown)]
_ => panic!("unknown node"),
};
}

Expand Down Expand Up @@ -186,6 +188,8 @@ impl VisitMut for LocalExportStrip {
ModuleExportName::Str(_) => {
unreachable!(r#"`export {{ "foo" }}` without src is invalid"#)
}
#[cfg(swc_ast_unknown)]
_ => panic!("unknown node"),
};

if let Some(exported) = exported {
Expand All @@ -198,14 +202,19 @@ impl VisitMut for LocalExportStrip {
},
span,
),
#[cfg(swc_ast_unknown)]
_ => panic!("unknown node"),
};

(export_name, ExportItem::new(export_name_span, orig))
} else {
(orig.sym.clone(), ExportItem::new(orig.span, orig))
}
}
#[cfg(swc_ast_unknown)]
_ => panic!("unknown node"),
}))

}

/// ```javascript
Expand Down Expand Up @@ -236,6 +245,8 @@ impl VisitMut for LocalExportStrip {
}
}
DefaultDecl::TsInterfaceDecl(_) => {}
#[cfg(swc_ast_unknown)]
_ => panic!("unknown node"),
}
}

Expand Down
4 changes: 4 additions & 0 deletions contrib/mut-cjs-exports/src/utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,8 @@ pub(crate) fn key_from_export_name(n: &ModuleExportName) -> (Atom, Span) {
},
s.span,
),
#[cfg(swc_ast_unknown)]
_ => panic!("unknown node"),
}
}

Expand All @@ -143,6 +145,8 @@ pub(crate) fn local_ident_from_export_name(n: ModuleExportName) -> Ident {
Some(s) => s.clone(),
None => panic!("non-utf8 export name: {:?}", s.value),
},
#[cfg(swc_ast_unknown)]
_ => panic!("unknown node"),
};

match Ident::verify_symbol(&name) {
Expand Down
4 changes: 2 additions & 2 deletions packages/emotion/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@
"main": "swc_plugin_emotion.wasm",
"scripts": {
"prepack": "pnpm run build",
"build": "cargo build --release -p swc_plugin_emotion --target wasm32-wasip1 && cp ../../target/wasm32-wasip1/release/swc_plugin_emotion.wasm .",
"build:debug": "cargo build -p swc_plugin_emotion --target wasm32-wasip1 && cp ../../target/wasm32-wasip1/debug/swc_plugin_emotion.wasm .",
"build": "RUSTFLAGS='--cfg swc_ast_unknown' cargo build --release -p swc_plugin_emotion --target wasm32-wasip1 && cp ../../target/wasm32-wasip1/release/swc_plugin_emotion.wasm .",
"build:debug": "RUSTFLAGS='--cfg swc_ast_unknown' cargo build -p swc_plugin_emotion --target wasm32-wasip1 && cp ../../target/wasm32-wasip1/debug/swc_plugin_emotion.wasm .",
"test": "pnpm run build:debug && vitest run --testTimeout=0"
},
"homepage": "https://swc.rs",
Expand Down
3 changes: 3 additions & 0 deletions packages/emotion/transform/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -38,3 +38,6 @@ swc_ecma_parser = { workspace = true }
swc_ecma_transforms_react = { workspace = true }
swc_ecma_transforms_testing = { workspace = true }
testing = { workspace = true }

[lints.rust]
unexpected_cfgs = { level = "warn", check-cfg = ['cfg(swc_ast_unknown)'] }
4 changes: 4 additions & 0 deletions packages/emotion/transform/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -291,6 +291,8 @@ impl<'a, C: Comments> EmotionTransformer<'a, C> {
ModuleExportName::Str(v) => {
v.value.as_str() == Some(exported.name.as_str())
}
#[cfg(swc_ast_unknown)]
_ => panic!("unknown node"),
},
_ => named.local.as_ref() == exported.name,
};
Expand All @@ -312,6 +314,8 @@ impl<'a, C: Comments> EmotionTransformer<'a, C> {
self.import_packages
.insert(namespace.local.to_id(), PackageMeta::Namespace(c.clone()));
}
#[cfg(swc_ast_unknown)]
_ => panic!("unknown node"),
}
}
}
Expand Down
4 changes: 2 additions & 2 deletions packages/formatjs/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@
"main": "swc_plugin_formatjs.wasm",
"scripts": {
"prepack": "pnpm run build",
"build": "cargo build --release -p swc_plugin_formatjs --target wasm32-wasip1 && cp ../../target/wasm32-wasip1/release/swc_plugin_formatjs.wasm .",
"build:debug": "cargo build -p swc_plugin_formatjs --target wasm32-wasip1 && cp ../../target/wasm32-wasip1/debug/swc_plugin_formatjs.wasm .",
"build": "RUSTFLAGS='--cfg swc_ast_unknown' cargo build --release -p swc_plugin_formatjs --target wasm32-wasip1 && cp ../../target/wasm32-wasip1/release/swc_plugin_formatjs.wasm .",
"build:debug": "RUSTFLAGS='--cfg swc_ast_unknown' cargo build -p swc_plugin_formatjs --target wasm32-wasip1 && cp ../../target/wasm32-wasip1/debug/swc_plugin_formatjs.wasm .",
"test": "pnpm run build:debug && vitest run --testTimeout=0"
},
"homepage": "https://swc.rs",
Expand Down
3 changes: 3 additions & 0 deletions packages/formatjs/transform/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -32,3 +32,6 @@ swc_icu_messageformat_parser = { features = [

[dev-dependencies]
pretty_assertions = { workspace = true }

[lints.rust]
unexpected_cfgs = { level = "warn", check-cfg = ['cfg(swc_ast_unknown)'] }
2 changes: 2 additions & 0 deletions packages/formatjs/transform/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,8 @@ fn get_message_descriptor_key_from_jsx(name: &JSXAttrName) -> &str {
match name {
JSXAttrName::Ident(name)
| JSXAttrName::JSXNamespacedName(JSXNamespacedName { name, .. }) => &name.sym,
#[cfg(swc_ast_unknown)]
_ => panic!("unknown node"),
}

// NOTE: Do not support evaluatePath()
Expand Down
4 changes: 2 additions & 2 deletions packages/jest/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@
"main": "swc_plugin_jest.wasm",
"scripts": {
"prepack": "pnpm run build",
"build": "cargo build --release -p swc_plugin_jest --target wasm32-wasip1 && cp ../../target/wasm32-wasip1/release/swc_plugin_jest.wasm .",
"build:debug": "cargo build -p swc_plugin_jest --target wasm32-wasip1 && cp ../../target/wasm32-wasip1/debug/swc_plugin_jest.wasm .",
"build": "RUSTFLAGS='--cfg swc_ast_unknown' cargo build --release -p swc_plugin_jest --target wasm32-wasip1 && cp ../../target/wasm32-wasip1/release/swc_plugin_jest.wasm .",
"build:debug": "RUSTFLAGS='--cfg swc_ast_unknown' cargo build -p swc_plugin_jest --target wasm32-wasip1 && cp ../../target/wasm32-wasip1/debug/swc_plugin_jest.wasm .",
"test": "pnpm run build:debug && vitest run --testTimeout=0"
},
"homepage": "https://swc.rs",
Expand Down
4 changes: 2 additions & 2 deletions packages/loadable-components/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@
"main": "swc_plugin_loadable_components.wasm",
"scripts": {
"prepack": "pnpm run build",
"build": "cargo build --release -p swc_plugin_loadable_components --target wasm32-wasip1 && cp ../../target/wasm32-wasip1/release/swc_plugin_loadable_components.wasm .",
"build:debug": "cargo build -p swc_plugin_loadable_components --target wasm32-wasip1 && cp ../../target/wasm32-wasip1/debug/swc_plugin_loadable_components.wasm .",
"build": "RUSTFLAGS='--cfg swc_ast_unknown' cargo build --release -p swc_plugin_loadable_components --target wasm32-wasip1 && cp ../../target/wasm32-wasip1/release/swc_plugin_loadable_components.wasm .",
"build:debug": "RUSTFLAGS='--cfg swc_ast_unknown' cargo build -p swc_plugin_loadable_components --target wasm32-wasip1 && cp ../../target/wasm32-wasip1/debug/swc_plugin_loadable_components.wasm .",
"test": "pnpm run build:debug && vitest run --testTimeout=0"
},
"homepage": "https://swc.rs",
Expand Down
2 changes: 1 addition & 1 deletion packages/noop/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
"description": "Noop SWC plugin, for debugging",
"main": "swc_plugin_noop.wasm",
"scripts": {
"prepack": "cargo build --release -p swc_plugin_noop --target wasm32-wasip1 && cp ../../target/wasm32-wasip1/release/swc_plugin_noop.wasm ."
"prepack": "RUSTFLAGS='--cfg swc_ast_unknown' cargo build --release -p swc_plugin_noop --target wasm32-wasip1 && cp ../../target/wasm32-wasip1/release/swc_plugin_noop.wasm ."
},
"homepage": "https://swc.rs",
"repository": {
Expand Down
4 changes: 2 additions & 2 deletions packages/prefresh/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@
"main": "swc_plugin_prefresh.wasm",
"scripts": {
"prepack": "pnpm run build",
"build": "cargo build --release -p swc_plugin_prefresh --target wasm32-wasip1 && cp ../../target/wasm32-wasip1/release/swc_plugin_prefresh.wasm .",
"build:debug": "cargo build -p swc_plugin_prefresh --target wasm32-wasip1 && cp ../../target/wasm32-wasip1/debug/swc_plugin_prefresh.wasm .",
"build": "RUSTFLAGS='--cfg swc_ast_unknown' cargo build --release -p swc_plugin_prefresh --target wasm32-wasip1 && cp ../../target/wasm32-wasip1/release/swc_plugin_prefresh.wasm .",
"build:debug": "RUSTFLAGS='--cfg swc_ast_unknown' cargo build -p swc_plugin_prefresh --target wasm32-wasip1 && cp ../../target/wasm32-wasip1/debug/swc_plugin_prefresh.wasm .",
"test": "pnpm run build:debug && vitest run --testTimeout=0"
},
"homepage": "https://swc.rs",
Expand Down
3 changes: 3 additions & 0 deletions packages/prefresh/transform/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -25,3 +25,6 @@ swc_ecma_parser = { workspace = true }
swc_ecma_transforms_base = { workspace = true }
swc_ecma_transforms_testing = { workspace = true }
testing = { workspace = true }

[lints.rust]
unexpected_cfgs = { level = "warn", check-cfg = ['cfg(swc_ast_unknown)'] }
4 changes: 4 additions & 0 deletions packages/prefresh/transform/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,8 @@ impl VisitMut for PrefreshPlugin {
let name = match imported {
ModuleExportName::Ident(ident) => &ident.sym,
ModuleExportName::Str(s) => &s.value.to_atom_lossy(),
#[cfg(swc_ast_unknown)]
_ => panic!("unknown node"),
};
if name == "createContext" {
self.local.insert(spec.local.to_id());
Expand All @@ -116,6 +118,8 @@ impl VisitMut for PrefreshPlugin {
ImportSpecifier::Namespace(spec) => {
self.lib_local.insert(spec.local.to_id());
}
#[cfg(swc_ast_unknown)]
_ => panic!("unknown node"),
}
}
}
Expand Down
4 changes: 2 additions & 2 deletions packages/react-remove-properties/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@
"main": "swc_plugin_react_remove_properties.wasm",
"scripts": {
"prepack": "pnpm run build",
"build": "cargo build --release -p swc_plugin_react_remove_properties --target wasm32-wasip1 && cp ../../target/wasm32-wasip1/release/swc_plugin_react_remove_properties.wasm .",
"build:debug": "cargo build -p swc_plugin_react_remove_properties --target wasm32-wasip1 && cp ../../target/wasm32-wasip1/debug/swc_plugin_react_remove_properties.wasm .",
"build": "RUSTFLAGS='--cfg swc_ast_unknown' cargo build --release -p swc_plugin_react_remove_properties --target wasm32-wasip1 && cp ../../target/wasm32-wasip1/release/swc_plugin_react_remove_properties.wasm .",
"build:debug": "RUSTFLAGS='--cfg swc_ast_unknown' cargo build -p swc_plugin_react_remove_properties --target wasm32-wasip1 && cp ../../target/wasm32-wasip1/debug/swc_plugin_react_remove_properties.wasm .",
"test": "pnpm run build:debug && vitest run --testTimeout=0"
},
"homepage": "https://swc.rs",
Expand Down
4 changes: 2 additions & 2 deletions packages/relay/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@
"types": "./types.d.ts",
"scripts": {
"prepack": "pnpm run build",
"build": "cargo build --release -p swc_plugin_relay --target wasm32-wasip1 && cp ../../target/wasm32-wasip1/release/swc_plugin_relay.wasm .",
"build:debug": "cargo build -p swc_plugin_relay --target wasm32-wasip1 && cp ../../target/wasm32-wasip1/debug/swc_plugin_relay.wasm .",
"build": "RUSTFLAGS='--cfg swc_ast_unknown' cargo build --release -p swc_plugin_relay --target wasm32-wasip1 && cp ../../target/wasm32-wasip1/release/swc_plugin_relay.wasm .",
"build:debug": "RUSTFLAGS='--cfg swc_ast_unknown' cargo build -p swc_plugin_relay --target wasm32-wasip1 && cp ../../target/wasm32-wasip1/debug/swc_plugin_relay.wasm .",
"test": "pnpm run build:debug && vitest run --testTimeout=0"
},
"homepage": "https://swc.rs",
Expand Down
4 changes: 2 additions & 2 deletions packages/remove-console/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@
"main": "swc_plugin_remove_console.wasm",
"scripts": {
"prepack": "pnpm run build",
"build": "cargo build --release -p swc_plugin_remove_console --target wasm32-wasip1 && cp ../../target/wasm32-wasip1/release/swc_plugin_remove_console.wasm .",
"build:debug": "cargo build -p swc_plugin_remove_console --target wasm32-wasip1 && cp ../../target/wasm32-wasip1/debug/swc_plugin_remove_console.wasm .",
"build": "RUSTFLAGS='--cfg swc_ast_unknown' cargo build --release -p swc_plugin_remove_console --target wasm32-wasip1 && cp ../../target/wasm32-wasip1/release/swc_plugin_remove_console.wasm .",
"build:debug": "RUSTFLAGS='--cfg swc_ast_unknown' cargo build -p swc_plugin_remove_console --target wasm32-wasip1 && cp ../../target/wasm32-wasip1/debug/swc_plugin_remove_console.wasm .",
"test": "pnpm run build:debug && vitest run --testTimeout=0"
},
"homepage": "https://swc.rs",
Expand Down
Loading
Loading