@stylexswc/jest 0.11.1 → 0.11.2-rc.1

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/README.md CHANGED
@@ -54,9 +54,72 @@ module.exports = {
54
54
  - Type: `Partial<StyleXOptions>`
55
55
  - Optional
56
56
  - Description: StyleX compiler options that will be passed to the transformer.
57
- See
58
- [StyleX configuration docs](https://stylexjs.com/docs/api/configuration/babel-plugin/)
59
- for details.
57
+ For standard StyleX options, see the [official StyleX documentation](https://stylexjs.com/docs/api/configuration/babel-plugin/).
58
+
59
+ > [!NOTE]
60
+ > **New Features:** The `include` and `exclude` options are exclusive to this NAPI-RS compiler implementation and are not available in the official StyleX Babel plugin.
61
+
62
+ #### `rsOptions.include`
63
+
64
+ - Type: `(string | RegExp)[]`
65
+ - Optional
66
+ - Description: **RS-compiler Only** An array of glob patterns or regular expressions to include specific files for StyleX transformation.
67
+ When specified, only files matching at least one of these patterns will be transformed.
68
+ Patterns are matched against paths relative to the current working directory.
69
+ Supports regex lookahead/lookbehind for advanced filtering.
70
+
71
+ #### `rsOptions.exclude`
72
+
73
+ - Type: `(string | RegExp)[]`
74
+ - Optional
75
+ - Description: **RS-compiler Only** An array of glob patterns or regular expressions to exclude specific files from StyleX transformation.
76
+ Files matching any of these patterns will not be transformed, even if they match an `include` pattern.
77
+ Patterns are matched against paths relative to the current working directory.
78
+ Supports regex lookahead/lookbehind for advanced filtering.
79
+
80
+ ### Path Filtering Examples
81
+
82
+ **Include only specific directories:**
83
+
84
+ ```javascript
85
+ {
86
+ rsOptions: {
87
+ include: ['src/**/*.{ts,tsx}', 'app/**/*.{ts,tsx}'],
88
+ },
89
+ }
90
+ ```
91
+
92
+ **Exclude test files:**
93
+
94
+ ```javascript
95
+ {
96
+ rsOptions: {
97
+ exclude: ['**/*.test.*', '**/*.spec.*', '**/__tests__/**'],
98
+ },
99
+ }
100
+ ```
101
+
102
+ **Using RegExp with lookahead/lookbehind - exclude node_modules except specific packages:**
103
+
104
+ ```javascript
105
+ {
106
+ rsOptions: {
107
+ // Exclude all node_modules except @stylexjs/open-props
108
+ exclude: [/node_modules(?!\/@stylexjs\/open-props)/],
109
+ },
110
+ }
111
+ ```
112
+
113
+ **Combined include and exclude:**
114
+
115
+ ```javascript
116
+ {
117
+ rsOptions: {
118
+ include: ['src/**/*.{ts,tsx}'],
119
+ exclude: ['**/*.test.*', '**/*.stories.*'],
120
+ },
121
+ }
122
+ ```
60
123
 
61
124
  ## Example
62
125
 
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,wBAAwB,CAAC;AAC5D,OAAO,KAAK,EAAE,kBAAkB,EAAE,eAAe,EAAE,MAAM,iBAAiB,CAAC;AAC3E,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AAE1C,KAAK,iBAAiB,GAAG,MAAM,CAAC,iBAAiB,CAAC,CAAC,CAAC,CAAC;AAErD,MAAM,WAAW,qBAAsB,SAAQ,iBAAiB;IAC9D,SAAS,CAAC,EAAE,aAAa,CAAC;CAC3B;;;;AA6CD,wBAAqC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,wBAAwB,CAAC;AAC5D,OAAO,KAAK,EAAE,kBAAkB,EAAE,eAAe,EAAE,MAAM,iBAAiB,CAAC;AAC3E,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AAE1C,KAAK,iBAAiB,GAAG,MAAM,CAAC,iBAAiB,CAAC,CAAC,CAAC,CAAC;AAErD,MAAM,WAAW,qBAAsB,SAAQ,iBAAiB;IAC9D,SAAS,CAAC,EAAE,aAAa,CAAC;CAC3B;;;;AAqDD,wBAAqC"}
package/dist/index.js CHANGED
@@ -3,7 +3,17 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  const rs_compiler_1 = require("@stylexswc/rs-compiler");
4
4
  const crypto_1 = require("crypto");
5
5
  const process = function process(sourceText, sourcePath, options) {
6
- const { code } = (0, rs_compiler_1.transform)(sourcePath, sourceText, (0, rs_compiler_1.normalizeRsOptions)(options.transformerConfig.rsOptions ?? {}));
6
+ const rsOptions = options.transformerConfig.rsOptions ?? {};
7
+ // Check if file should be transformed based on include/exclude patterns
8
+ const shouldTransform = (0, rs_compiler_1.shouldTransformFile)(sourcePath, rsOptions.include, rsOptions.exclude);
9
+ if (!shouldTransform) {
10
+ return { code: sourceText };
11
+ }
12
+ else {
13
+ rsOptions.include = undefined;
14
+ rsOptions.exclude = undefined;
15
+ }
16
+ const { code } = (0, rs_compiler_1.transform)(sourcePath, sourceText, (0, rs_compiler_1.normalizeRsOptions)(rsOptions));
7
17
  return { code };
8
18
  };
9
19
  const processAsync = async function processAsync(sourceText, sourcePath, options) {
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@stylexswc/jest",
3
3
  "description": "Jest transformer for Stylex SWC",
4
- "version": "0.11.1",
4
+ "version": "0.11.2-rc.1",
5
5
  "private": false,
6
6
  "license": "MIT",
7
7
  "sideEffects": false,
@@ -18,14 +18,14 @@
18
18
  }
19
19
  },
20
20
  "dependencies": {
21
- "@stylexswc/rs-compiler": "0.11.1"
21
+ "@stylexswc/rs-compiler": "0.11.2-rc.1"
22
22
  },
23
23
  "devDependencies": {
24
- "@babel/types": "^7.28.2",
24
+ "@babel/types": "^7.28.4",
25
25
  "@jest/transform": "^30.0.5",
26
26
  "@jest/types": "^29.5.14",
27
- "@stylexswc/eslint-config": "0.11.1",
28
- "@stylexswc/typescript-config": "0.11.1"
27
+ "@stylexswc/eslint-config": "0.11.2-rc.1",
28
+ "@stylexswc/typescript-config": "0.11.2-rc.1"
29
29
  },
30
30
  "keywords": [
31
31
  "jest",
@@ -44,6 +44,6 @@
44
44
  "precommit": "lint-staged",
45
45
  "prepush": "lint-prepush",
46
46
  "test": "echo \"Error: no test specified\" && exit 0",
47
- "typecheck": "scripty"
47
+ "typecheck": "scripty --ts"
48
48
  }
49
49
  }