stylex-webpack 0.2.0 → 0.2.1-beta.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.
Files changed (2) hide show
  1. package/dist/index.js +15 -0
  2. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -98,6 +98,21 @@ class StyleXPlugin {
98
98
  if (stylexChunk == null) {
99
99
  return;
100
100
  }
101
+ // Collect stylex rules from module instead of self maintained map
102
+ if (this.loaderOption.nextjsMode) {
103
+ const cssModulesInStylexChunk = compilation.chunkGraph.getChunkModulesIterableBySourceType(stylexChunk, 'css/mini-extract');
104
+ // we only re-collect stylex rules if we can found css in the stylex chunk
105
+ if (cssModulesInStylexChunk) {
106
+ this.stylexRules = new Map();
107
+ for (const cssModule of cssModulesInStylexChunk){
108
+ const stringifiedStylexRule = cssModule._identifier.split('!').pop()?.split('?').pop();
109
+ if (!stringifiedStylexRule) {
110
+ continue;
111
+ }
112
+ this.stylexRules.set(cssModule.identifier(), JSON.parse(stringifiedStylexRule));
113
+ }
114
+ }
115
+ }
101
116
  // Let's find the css file that belongs to the stylex chunk
102
117
  const cssAssetDetails = Object.entries(assets).find(([assetName])=>stylexChunk.files.has(assetName));
103
118
  if (!cssAssetDetails) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "stylex-webpack",
3
- "version": "0.2.0",
3
+ "version": "0.2.1-beta.0",
4
4
  "description": "The another Webpack Plugin for Facebook's StyleX",
5
5
  "homepage": "https://github.com/SukkaW/style9-webpack#readme",
6
6
  "repository": {