@swc/plugin-formatjs 9.3.0 → 9.5.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -1,5 +1,18 @@
1
1
  # @swc/plugin-formatjs
2
2
 
3
+ ## 9.5.0
4
+
5
+ ### Minor Changes
6
+
7
+ - 870774a: build: Update swc_core to v56
8
+
9
+ ## 9.4.0
10
+
11
+ ### Minor Changes
12
+
13
+ - 15f32da: fix(formatjs): Variable evaluate concatenation
14
+ - 66f5258: build: Update swc_core to v55.x.x
15
+
3
16
  ## 9.3.0
4
17
 
5
18
  ### Minor Changes
package/README.md CHANGED
@@ -95,6 +95,19 @@ Will extract the metadata: `{project: "web", locale: "en", region: "us"}` that g
95
95
 
96
96
  # @swc/plugin-formatjs
97
97
 
98
+ ## 9.5.0
99
+
100
+ ### Minor Changes
101
+
102
+ - 870774a: build: Update swc_core to v56
103
+
104
+ ## 9.4.0
105
+
106
+ ### Minor Changes
107
+
108
+ - 15f32da: fix(formatjs): Variable evaluate concatenation
109
+ - 66f5258: build: Update swc_core to v55.x.x
110
+
98
111
  ## 9.3.0
99
112
 
100
113
  ### Minor Changes
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@swc/plugin-formatjs",
3
- "version": "9.3.0",
3
+ "version": "9.5.0",
4
4
  "publishConfig": {
5
5
  "access": "public",
6
6
  "provenance": true
@@ -24,8 +24,8 @@
24
24
  "@swc/counter": "^0.1.3"
25
25
  },
26
26
  "scripts": {
27
- "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 .",
28
- "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 .",
27
+ "build": "cargo build --release -p swc_plugin_formatjs --target wasm32-wasip1 && cp ../../target/wasm32-wasip1/release/swc_plugin_formatjs.wasm .",
28
+ "build:debug": "cargo build -p swc_plugin_formatjs --target wasm32-wasip1 && cp ../../target/wasm32-wasip1/debug/swc_plugin_formatjs.wasm .",
29
29
  "test": "pnpm run build:debug && vitest run --testTimeout=0"
30
30
  }
31
31
  }
package/src/lib.rs CHANGED
@@ -5,6 +5,7 @@ use swc_core::{
5
5
  proxies::TransformPluginProgramMetadata,
6
6
  },
7
7
  };
8
+ use swc_ecma_minifier::{eval::Evaluator, marks::Marks};
8
9
  use swc_formatjs_transform::{create_formatjs_visitor, FormatJSPluginOptions};
9
10
 
10
11
  #[plugin_transform]
@@ -23,14 +24,24 @@ pub fn process(mut program: Program, metadata: TransformPluginProgramMetadata) -
23
24
  Default::default()
24
25
  };
25
26
 
26
- let mut visitor = create_formatjs_visitor(
27
- std::sync::Arc::new(metadata.source_map),
28
- metadata.comments.as_ref(),
29
- plugin_options,
30
- filename,
31
- );
27
+ if let Some(module) = program.as_module() {
28
+ let evaluator = &mut Evaluator::new(
29
+ module.clone(),
30
+ Marks {
31
+ unresolved_mark: metadata.unresolved_mark,
32
+ ..Marks::new()
33
+ },
34
+ );
35
+ let mut visitor = create_formatjs_visitor(
36
+ std::sync::Arc::new(metadata.source_map),
37
+ metadata.comments.as_ref(),
38
+ plugin_options,
39
+ filename,
40
+ evaluator,
41
+ );
32
42
 
33
- program.visit_mut_with(&mut visitor);
43
+ program.visit_mut_with(&mut visitor);
44
+ }
34
45
 
35
46
  program
36
47
  }
Binary file