stylex-webpack 0.4.6 → 0.4.8

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/dist/index.js CHANGED
@@ -5,7 +5,7 @@ var path = require('node:path');
5
5
  var process = require('node:process');
6
6
  var identity = require('foxts/identity');
7
7
 
8
- var version = "0.4.6";
8
+ var version = "0.4.8";
9
9
 
10
10
  const PLUGIN_NAME = 'stylex';
11
11
  const VIRTUAL_ENTRYPOINT_CSS_PATH = require.resolve('./stylex.css');
@@ -159,31 +159,25 @@ class StyleXPlugin {
159
159
  }
160
160
  }
161
161
  }
162
+ if (this.loaderOption.nextjsMode && this.loaderOption.nextjsAppRouterMode && isNextJsCompilerName(compiler.name)) {
163
+ var _globalThis;
164
+ (_globalThis = globalThis).__stylex_nextjs_global_registry__ ?? (_globalThis.__stylex_nextjs_global_registry__ = new Map());
165
+ globalThis.__stylex_nextjs_global_registry__.set(compiler.name, this.stylexRules);
166
+ }
162
167
  });
163
168
  compilation.hooks.processAssets.tapPromise({
164
169
  name: PLUGIN_NAME,
165
170
  stage: Compilation.PROCESS_ASSETS_STAGE_PRE_PROCESS
166
171
  }, async (assets)=>{
167
- if (this.loaderOption.nextjsMode && this.loaderOption.nextjsAppRouterMode && isNextJsCompilerName(compiler.name)) {
168
- if (compiler.name === NEXTJS_COMPILER_NAMES.server || compiler.name === NEXTJS_COMPILER_NAMES.edgeServer) {
169
- var _globalThis;
170
- ((_globalThis = globalThis).__stylex_nextjs_global_registry__ ?? (_globalThis.__stylex_nextjs_global_registry__ = new Map())).set(compiler.name, this.stylexRules);
171
- // we don't need to do anything more in server/edge compiler, no CSS generation is needed
172
- return;
173
- }
174
- // eslint-disable-next-line @typescript-eslint/no-unnecessary-condition -- type safe
175
- if (compiler.name === NEXTJS_COMPILER_NAMES.client) {
176
- const globalRegistry = globalThis.__stylex_nextjs_global_registry__;
177
- if (globalRegistry != null) {
178
- // now we merge all collected rules from other compilers
179
- globalRegistry.forEach((rules)=>{
180
- rules.forEach((rule, resourcePath)=>{
181
- this.stylexRules.set(resourcePath, rule);
182
- });
172
+ if (this.loaderOption.nextjsMode && this.loaderOption.nextjsAppRouterMode && compiler.name === NEXTJS_COMPILER_NAMES.client) {
173
+ const globalRegistry = globalThis.__stylex_nextjs_global_registry__;
174
+ if (globalRegistry != null) {
175
+ // now we merge all collected rules from other compilers
176
+ globalRegistry.forEach((rules)=>{
177
+ rules.forEach((rule, resourcePath)=>{
178
+ this.stylexRules.set(resourcePath, rule);
183
179
  });
184
- }
185
- } else {
186
- compiler.name;
180
+ });
187
181
  }
188
182
  }
189
183
  const stylexCSS = getStyleXRules(this.stylexRules, this.useCSSLayers);
@@ -4,6 +4,7 @@ var core = require('@babel/core');
4
4
  var stylexBabelPlugin = require('@stylexjs/babel-plugin');
5
5
  var guard = require('foxts/guard');
6
6
 
7
+ const LOADER_TRANSFORMED_FLAG = '/* [stylex-webpack] stylex-loader transformed */';
7
8
  require.resolve('./stylex.css');
8
9
  const VIRTUAL_STYLEX_CSS_DUMMY_IMPORT_PATH = require.resolve('./stylex-virtual.css');
9
10
  const BUILD_INFO_STYLEX_KEY = '~stylex_webpack_stylex_rules';
@@ -15,6 +16,11 @@ function stringifyRequest(loaderContext, request) {
15
16
  const PLUGIN_NAME = 'stylex';
16
17
  async function stylexLoader(inputCode, inputSourceMap) {
17
18
  const callback = this.async();
19
+ // bail out early if already transformed
20
+ // for some reason, a module might be passed to stylex-loader more than once, happened with Next.js App Router
21
+ if (inputCode.includes(LOADER_TRANSFORMED_FLAG)) {
22
+ return callback(null, inputCode, inputSourceMap);
23
+ }
18
24
  const { stylexImports, stylexOption } = this.getOptions();
19
25
  // bail out early if the input doesn't contain stylex imports
20
26
  if (!stylexImports.some((importName)=>inputCode.includes(importName))) {
@@ -56,7 +62,7 @@ async function stylexLoader(inputCode, inputSourceMap) {
56
62
  stylex: JSON.stringify(metadata.stylex) // color: #fff is not url safe, let's get through JSON.stringify
57
63
  });
58
64
  const virtualCssRequest = stringifyRequest(this, `${VIRTUAL_STYLEX_CSS_DUMMY_IMPORT_PATH}?${urlParams.toString()}`);
59
- const postfix = `\nimport ${virtualCssRequest};`;
65
+ const postfix = `\nimport ${virtualCssRequest};\n${LOADER_TRANSFORMED_FLAG}`;
60
66
  return callback(null, code + postfix, map ?? undefined);
61
67
  } catch (error) {
62
68
  return callback(error);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "stylex-webpack",
3
- "version": "0.4.6",
3
+ "version": "0.4.8",
4
4
  "description": "The another Webpack Plugin for Facebook's StyleX",
5
5
  "homepage": "https://github.com/SukkaW/style9-webpack#readme",
6
6
  "repository": {
@@ -23,8 +23,8 @@
23
23
  "default": "./dist/index.js"
24
24
  },
25
25
  "./next": {
26
- "types": "./next/index.d.ts",
27
- "default": "./next/index.js"
26
+ "types": "./dist/next/index.d.ts",
27
+ "default": "./dist/next/index.js"
28
28
  },
29
29
  "./stylex.css": "./dist/stylex.css"
30
30
  },
@@ -53,49 +53,50 @@
53
53
  "@babel/plugin-syntax-jsx": "^7.27.1",
54
54
  "@babel/plugin-syntax-typescript": "^7.27.1",
55
55
  "@types/webpack": "^5.28.5",
56
- "foxts": "^5.0.0",
56
+ "foxts": "^5.0.4",
57
57
  "loader-utils": "^3.3.1"
58
58
  },
59
59
  "devDependencies": {
60
- "@eslint-sukka/node": "^8.0.2",
60
+ "@eslint-sukka/node": "^8.1.0",
61
61
  "@rollup/plugin-json": "^6.1.0",
62
62
  "@swc-node/register": "^1.11.1",
63
- "@swc/core": "^1.15.0",
63
+ "@swc/core": "^1.15.8",
64
64
  "@types/babel__core": "^7.20.5",
65
65
  "@types/loader-utils": "^3.0.0",
66
66
  "@types/mocha": "^10.0.10",
67
- "@types/node": "^22.19.0",
68
- "browserslist": "^4.27.0",
69
- "bumpp": "^10.3.1",
67
+ "@types/node": "^22.19.3",
68
+ "browserslist": "^4.28.1",
69
+ "bumpp": "^10.3.2",
70
70
  "css-loader": "^7.1.2",
71
- "eslint": "^9.39.1",
72
- "eslint-config-sukka": "^8.0.2",
73
- "eslint-formatter-sukka": "^8.0.2",
71
+ "eslint": "^9.39.2",
72
+ "eslint-config-sukka": "^8.1.0",
73
+ "eslint-formatter-sukka": "^8.1.0",
74
74
  "expect": "^30.2.0",
75
- "memfs": "^4.50.0",
75
+ "memfs": "^4.51.1",
76
76
  "mini-css-extract-plugin": "^2.9.4",
77
77
  "mocha": "^11.7.5",
78
78
  "mocha-expect-snapshot": "^8.0.0",
79
- "next": "^15.5.6",
79
+ "next": "^15.5.9",
80
80
  "postcss": "^8.5.6",
81
81
  "premove": "^4.0.0",
82
- "rollup": "^4.52.5",
82
+ "rollup": "^4.55.1",
83
83
  "rollup-plugin-copy": "^3.5.0",
84
- "rollup-plugin-dts": "^6.2.3",
84
+ "rollup-plugin-dts": "^6.3.0",
85
85
  "rollup-plugin-swc3": "^0.12.1",
86
86
  "swc-loader": "^0.2.6",
87
87
  "typescript": "^5.9.3",
88
- "webpack": "^5.102.1"
88
+ "webpack": "^5.104.1"
89
89
  },
90
90
  "peerDependencies": {
91
91
  "@stylexjs/babel-plugin": "*"
92
92
  },
93
- "packageManager": "pnpm@10.20.0",
93
+ "packageManager": "pnpm@10.27.0",
94
94
  "pnpm": {
95
95
  "overrides": {
96
96
  "eslint>chalk": "npm:picocolors@^1.1.1"
97
97
  },
98
98
  "onlyBuiltDependencies": [
99
+ "@swc/core",
99
100
  "oxc-resolver"
100
101
  ]
101
102
  }