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

refactor(relay): Make transform take Arc<Config> #321

Merged
merged 5 commits into from
Jul 2, 2024
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
2 changes: 1 addition & 1 deletion Cargo.lock

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

6 changes: 6 additions & 0 deletions packages/relay/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
# @swc/plugin-relay

## 2.0.11

### Patch Changes

- 7984823: Use Arc<Config> instead of Config

## 2.0.10

### Patch Changes
Expand Down
6 changes: 6 additions & 0 deletions packages/relay/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,12 @@ In this example typescript graphql files will output transpiled import path of `

# @swc/plugin-relay

## 2.0.11

### Patch Changes

- 7984823: Use Arc<Config> instead of Config

## 2.0.10

### Patch Changes
Expand Down
2 changes: 1 addition & 1 deletion packages/relay/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@swc/plugin-relay",
"version": "2.0.10",
"version": "2.0.11",
"description": "SWC plugin for relay",
"main": "swc_plugin_relay.wasm",
"types": "./types.d.ts",
Expand Down
2 changes: 1 addition & 1 deletion packages/relay/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ fn relay_plugin_transform(program: Program, metadata: TransformPluginProgramMeta
};

let mut relay = relay(
config,
config.into(),
filename,
root_dir,
None,
Expand Down
2 changes: 1 addition & 1 deletion packages/relay/transform/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ homepage = { workspace = true }
license = { workspace = true }
repository = { workspace = true }
rust-version = { workspace = true }
version = "0.44.18"
version = "0.44.19"


# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
Expand Down
9 changes: 6 additions & 3 deletions packages/relay/transform/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,10 @@

//! TODO: Once refactoring next-swc is done, remove duplicated codes and import
//! packages directly
use std::path::{Path, PathBuf};
use std::{
path::{Path, PathBuf},
sync::Arc,
};

use once_cell::sync::Lazy;
use regex::Regex;
Expand Down Expand Up @@ -102,7 +105,7 @@ struct Relay {
root_dir: PathBuf,
pages_dir: Option<PathBuf>,
file_name: FileName,
config: Config,
config: Arc<Config>,
imports: Vec<RelayImport>,
unresolved_mark: Option<Mark>,
}
Expand Down Expand Up @@ -330,7 +333,7 @@ impl Relay {
}

pub fn relay(
config: Config,
config: Arc<Config>,
file_name: FileName,
root_dir: PathBuf,
pages_dir: Option<PathBuf>,
Expand Down
15 changes: 10 additions & 5 deletions packages/relay/transform/tests/fixture.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,8 @@ fn fixture(input: PathBuf) {
language: RelayLanguageConfig::TypeScript,
eager_es_modules: false,
output_file_extension: OutputFileExtension::Undefined,
},
}
.into(),
FileName::Real("file.js".parse().unwrap()),
Default::default(),
None,
Expand All @@ -45,7 +46,8 @@ fn fixture_es_modules(input: PathBuf) {
language: RelayLanguageConfig::TypeScript,
eager_es_modules: true,
output_file_extension: OutputFileExtension::Undefined,
},
}
.into(),
FileName::Real("file.js".parse().unwrap()),
Default::default(),
None,
Expand All @@ -72,7 +74,8 @@ fn fixture_output_file_extension_javascript(input: PathBuf) {
language: RelayLanguageConfig::TypeScript,
eager_es_modules: true,
output_file_extension: OutputFileExtension::JavaScript,
},
}
.into(),
FileName::Real("file.js".parse().unwrap()),
Default::default(),
None,
Expand All @@ -99,7 +102,8 @@ fn fixture_output_file_extension_typescript(input: PathBuf) {
language: RelayLanguageConfig::JavaScript,
eager_es_modules: true,
output_file_extension: OutputFileExtension::TypeScript,
},
}
.into(),
FileName::Real("file.js".parse().unwrap()),
Default::default(),
None,
Expand Down Expand Up @@ -146,7 +150,8 @@ fn fixture_multi_projects(input: PathBuf) {
language: RelayLanguageConfig::JavaScript,
eager_es_modules: true,
output_file_extension: OutputFileExtension::TypeScript,
},
}
.into(),
FileName::Real(input.clone()),
Default::default(),
None,
Expand Down
Loading