Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add test for styled-components using real pnpm 8 #8

Merged
merged 1 commit into from
Dec 6, 2023
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
23 changes: 23 additions & 0 deletions .github/actions/pnpm/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
name: Pnpm

description: Install pnpm

runs:
using: composite
steps:
- name: Install pnpm
working-directory: fixtures/pnpm8
shell: bash
run: corepack enable

- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: 18
cache-dependency-path: ./fixtures/pnpm8/package.json
cache: pnpm

- name: pnpm install
working-directory: fixtures/pnpm8
shell: bash
run: pnpm install
4 changes: 2 additions & 2 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -179,6 +179,6 @@ jobs:
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v4
- name: Install Rust
uses: ./.github/actions/rustup
- uses: ./.github/actions/pnpm
- uses: ./.github/actions/rustup
- run: cargo test --quiet
3 changes: 3 additions & 0 deletions .github/workflows/codecov.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,9 @@ jobs:
- name: Checkout
uses: actions/checkout@v4

- name: Pnpm
uses: ./.github/actions/pnpm

- name: Install Rust Toolchain
uses: ./.github/actions/rustup
with:
Expand Down
1 change: 1 addition & 0 deletions fixtures/pnpm8/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
node_modules
12 changes: 12 additions & 0 deletions fixtures/pnpm8/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{
"name": "pnpm8",
"version": "1.0.0",
"private": true,
"engines": {
"node": ">=16.0.0"
},
"packageManager": "pnpm@8.10.5",
"devDependencies": {
"styled-components": "6.1.1"
}
}
145 changes: 145 additions & 0 deletions fixtures/pnpm8/pnpm-lock.yaml

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

26 changes: 24 additions & 2 deletions tests/resolve_test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,31 @@ fn dir() -> PathBuf {
}

#[test]
fn chinese_dir() {
fn chinese() {
let dir = dir();
let specifier = "./fixtures/misc/中文/中文.js";
let resolution = Resolver::new(ResolveOptions::default()).resolve(&dir, specifier);
assert_eq!(resolution.map(|r| r.into_path_buf()), Ok(dir.join("fixtures/misc/中文/中文.js")))
assert_eq!(resolution.map(|r| r.into_path_buf()), Ok(dir.join("fixtures/misc/中文/中文.js")));
}

#[test]
fn styled_components() {
let dir = dir();
let path = dir.join("fixtures/pnpm8");
let specifier = "styled-components";

// cjs
let options =
ResolveOptions { alias_fields: vec![vec!["browser".into()]], ..ResolveOptions::default() };
let resolution = Resolver::new(options).resolve(&path, specifier);
assert_eq!(resolution.map(|r| r.into_path_buf()), Ok(path.join("node_modules/.pnpm/styled-components@6.1.1_react-dom@18.2.0_react@18.2.0/node_modules/styled-components/dist/styled-components.browser.cjs.js")));

// esm
let options = ResolveOptions {
alias_fields: vec![vec!["browser".into()]],
main_fields: vec!["module".into()],
..ResolveOptions::default()
};
let resolution = Resolver::new(options).resolve(&path, specifier);
assert_eq!(resolution.map(|r| r.into_path_buf()), Ok(path.join("node_modules/.pnpm/styled-components@6.1.1_react-dom@18.2.0_react@18.2.0/node_modules/styled-components/dist/styled-components.browser.esm.js")));
}