@stylexjs/rollup-plugin 0.10.0-beta.2 → 0.10.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.
@@ -235,7 +235,7 @@ declare export class Binding {
235
235
  type _VisitorNodeKeys<S: object> = {
236
236
  +[K in keyof t._NodeMap]: ?VisitNode<S, t._NodeMap[K]>,
237
237
  };
238
- type _VistorAliases<S: object> = {
238
+ type _VisitorAliases<S: object> = {
239
239
  +[K in keyof t.Aliases]: ?VisitNode<S, t.Aliases[K]>,
240
240
  };
241
241
 
@@ -243,7 +243,7 @@ export type Visitor<S: object = object> = $ReadOnly<
243
243
  Partial<{
244
244
  ...VisitNodeObject<S, Node>,
245
245
  ..._VisitorNodeKeys<S>,
246
- ..._VistorAliases<S>,
246
+ ..._VisitorAliases<S>,
247
247
  }>,
248
248
  >;
249
249
 
@@ -307,8 +307,8 @@ declare export class NodePath<+T: Node = Node> {
307
307
  type: T extends null | void
308
308
  ? void
309
309
  : T extends Node
310
- ? T['type']
311
- : string | void;
310
+ ? T['type']
311
+ : string | void;
312
312
 
313
313
  typeAnnotation: { ... };
314
314
 
@@ -996,7 +996,7 @@ export type NodePathResult<T: Node | $ReadOnlyArray<Node>> =
996
996
  T extends $ReadOnlyArray<infer TNode>
997
997
  ? $ReadOnlyArray<NodePath<TNode>>
998
998
  : T extends null | void
999
- ? void
1000
- : T extends Node
1001
- ? NodePath<T>
1002
- : T;
999
+ ? void
1000
+ : T extends Node
1001
+ ? NodePath<T>
1002
+ : T;
package/lib/es/index.mjs CHANGED
@@ -7,7 +7,15 @@ import path from 'path';
7
7
  import { transform } from 'lightningcss';
8
8
  import browserslist from 'browserslist';
9
9
  import { browserslistToTargets } from 'lightningcss';
10
+ import crypto from 'crypto';
10
11
  const IS_DEV_ENV = process.env.NODE_ENV === 'development' || process.env.BABEL_ENV === 'development';
12
+ function replaceFileName(original, css) {
13
+ if (!original.includes('[hash]')) {
14
+ return original;
15
+ }
16
+ const hash = crypto.createHash('sha256').update(css).digest('hex').slice(0, 8);
17
+ return original.replace(/\[hash\]/g, hash);
18
+ }
11
19
  export default function stylexPlugin() {
12
20
  let {
13
21
  dev = IS_DEV_ENV,
@@ -40,12 +48,12 @@ export default function stylexPlugin() {
40
48
  } = transform({
41
49
  targets: browserslistToTargets(browserslist('>= 1%')),
42
50
  ...lightningcssOptions,
43
- filename: fileName,
51
+ filename: 'stylex.css',
44
52
  code: Buffer.from(collectedCSS)
45
53
  });
46
54
  const processedCSS = code.toString();
47
55
  this.emitFile({
48
- fileName,
56
+ fileName: replaceFileName(fileName, processedCSS),
49
57
  source: processedCSS,
50
58
  type: 'asset'
51
59
  });
package/lib/index.js CHANGED
@@ -12,8 +12,16 @@ var _pluginSyntaxTypescript = _interopRequireDefault(require("@babel/plugin-synt
12
12
  var _path = _interopRequireDefault(require("path"));
13
13
  var _lightningcss = require("lightningcss");
14
14
  var _browserslist = _interopRequireDefault(require("browserslist"));
15
+ var _crypto = _interopRequireDefault(require("crypto"));
15
16
  function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
16
17
  const IS_DEV_ENV = process.env.NODE_ENV === 'development' || process.env.BABEL_ENV === 'development';
18
+ function replaceFileName(original, css) {
19
+ if (!original.includes('[hash]')) {
20
+ return original;
21
+ }
22
+ const hash = _crypto.default.createHash('sha256').update(css).digest('hex').slice(0, 8);
23
+ return original.replace(/\[hash\]/g, hash);
24
+ }
17
25
  function stylexPlugin() {
18
26
  let {
19
27
  dev = IS_DEV_ENV,
@@ -46,12 +54,12 @@ function stylexPlugin() {
46
54
  } = (0, _lightningcss.transform)({
47
55
  targets: (0, _lightningcss.browserslistToTargets)((0, _browserslist.default)('>= 1%')),
48
56
  ...lightningcssOptions,
49
- filename: fileName,
57
+ filename: 'stylex.css',
50
58
  code: Buffer.from(collectedCSS)
51
59
  });
52
60
  const processedCSS = code.toString();
53
61
  this.emitFile({
54
- fileName,
62
+ fileName: replaceFileName(fileName, processedCSS),
55
63
  source: processedCSS,
56
64
  type: 'asset'
57
65
  });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@stylexjs/rollup-plugin",
3
- "version": "0.10.0-beta.2",
3
+ "version": "0.10.1",
4
4
  "description": "Rollup plugin for StyleX",
5
5
  "main": "./lib/index.js",
6
6
  "module": "./lib/es/index.mjs",
@@ -35,7 +35,7 @@
35
35
  "@babel/plugin-syntax-flow": "^7.25.7",
36
36
  "@babel/plugin-syntax-jsx": "^7.25.7",
37
37
  "@babel/plugin-syntax-typescript": "^7.25.7",
38
- "@stylexjs/babel-plugin": "0.10.0-beta.2",
38
+ "@stylexjs/babel-plugin": "0.10.1",
39
39
  "lightningcss": "^1.27.0"
40
40
  },
41
41
  "files": [