Skip to content
Open
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
47 changes: 31 additions & 16 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,12 @@ permissions:

jobs:
test:
runs-on: ubuntu-latest
name: test (${{ matrix.os }})
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
os: [ubuntu-latest, macos-latest, windows-latest]
env:
CARGO_TERM_COLOR: always
RUST_BACKTRACE: full
Expand All @@ -20,11 +25,18 @@ jobs:
- uses: actions/checkout@v3
- uses: dtolnay/rust-toolchain@stable
- uses: Swatinem/rust-cache@v2
- run: cargo fmt
- run: cargo fmt --check
# clippy warn too much, temporary disable
# - run: cargo clippy --all-targets
- run: cargo test --all-features

test-js:
runs-on: ubuntu-latest
name: test-js (${{ matrix.os }})
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
os: [ubuntu-latest, macos-latest, windows-latest]
steps:
- uses: actions/checkout@v3
- uses: actions/setup-node@v3
Expand All @@ -38,26 +50,29 @@ jobs:
- run: yarn tsc

test-wasm:
runs-on: ubuntu-latest
name: test-wasm (${{ matrix.os }})
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
os: [ubuntu-latest, macos-latest, windows-latest]
steps:
- uses: actions/checkout@v3
- uses: actions/setup-node@v3
with:
node-version: 18
- uses: bahmutov/npm-install@v1.8.32
- uses: dtolnay/rust-toolchain@stable
with:
targets: wasm32-unknown-unknown
- name: Setup rust target
run: rustup target add wasm32-unknown-unknown
- uses: Swatinem/rust-cache@v2
- name: Install wasm-opt
run: |
curl -L -O https://github.com/WebAssembly/binaryen/releases/download/version_111/binaryen-version_111-x86_64-linux.tar.gz
tar -xf binaryen-version_111-x86_64-linux.tar.gz
uses: phi-ag/setup-binaryen@v1
with:
version: "111"
- name: Build wasm
run: |
export PATH="$PATH:./binaryen-version_111/bin"
yarn wasm:build-release
- run: TEST_WASM=node yarn test
- run: TEST_WASM=browser yarn test
run: yarn wasm:build-release
- run: yarn test
env:
TEST_WASM: node
- run: yarn test
env:
TEST_WASM: browser
2 changes: 1 addition & 1 deletion node/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ fn init(mut exports: JsObject) -> napi::Result<()> {
#[no_mangle]
pub fn register_module() {
unsafe fn register(raw_env: napi::sys::napi_env, raw_exports: napi::sys::napi_value) -> napi::Result<()> {
use napi::{Env, JsObject, NapiValue};
use napi::{JsObject, NapiValue};

let exports = JsObject::from_raw_unchecked(raw_env, raw_exports);
init(exports)
Expand Down
4 changes: 2 additions & 2 deletions node/test/bundle.test.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ test('resolver', async () => {
'hello/world.css': `
.baz { color: blue; }
`.trim(),
}));
}).map(([file, contents]) => [path.normalize(file), contents]));

const { code: buffer } = await bundleAsync({
filename: 'foo.css',
Expand Down Expand Up @@ -95,7 +95,7 @@ test('only custom read', async () => {
'bar.css': `
.baz { color: blue; }
`.trim(),
}));
}).map(([file, contents]) => [path.normalize(file), contents]));

const { code: buffer } = await bundleAsync({
filename: 'foo.css',
Expand Down
1 change: 1 addition & 0 deletions rust-toolchain.toml
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
[toolchain]
channel = "1.92.0"
components = ["rustfmt", "clippy"]
targets = ["wasm32-unknown-unknown"]
5 changes: 1 addition & 4 deletions src/bundler.rs
Original file line number Diff line number Diff line change
Expand Up @@ -106,10 +106,7 @@ pub enum ResolveResult {
/// An external URL.
External(String),
/// A file path.
#[cfg_attr(
any(feature = "serde", feature = "nodejs"),
serde(untagged)
)]
#[cfg_attr(any(feature = "serde", feature = "nodejs"), serde(untagged))]
File(PathBuf),
}

Expand Down
6 changes: 1 addition & 5 deletions src/selector.rs
Original file line number Diff line number Diff line change
Expand Up @@ -100,10 +100,7 @@ impl<'a, 'i> parcel_selectors::parser::Parser<'i> for SelectorParser<'a, 'i> {
name: CowRcStr<'i>,
) -> Result<PseudoClass<'i>, ParseError<'i, Self::Error>> {
use PseudoClass::*;
let scroll_navigation_controls = self
.options
.flags
.contains(ParserFlags::SCROLL_NAVIGATION_CONTROLS);
let scroll_navigation_controls = self.options.flags.contains(ParserFlags::SCROLL_NAVIGATION_CONTROLS);
let pseudo_class = match_ignore_ascii_case! { &name,
// https://drafts.csswg.org/selectors-4/#useraction-pseudos
"hover" => Hover,
Expand Down Expand Up @@ -501,7 +498,6 @@ pub enum PseudoClass<'i> {
/// The [:target-after](https://drafts.csswg.org/css-overflow-5/#selectordef-target-after) pseudo class.
TargetAfter,
/// The [:target-within](https://drafts.csswg.org/selectors-4/#the-target-within-pseudo) pseudo class.

TargetWithin,
/// The [:visited](https://drafts.csswg.org/selectors-4/#visited-pseudo) pseudo class.
Visited,
Expand Down
Loading