@stylexjs/rollup-plugin 0.10.0-beta.2 → 0.10.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/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.0",
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.0",
39
39
  "lightningcss": "^1.27.0"
40
40
  },
41
41
  "files": [