@stylexjs/babel-plugin 0.17.3 → 0.17.4
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/index.browser.js +23 -16
- package/lib/index.js +23 -16
- package/lib/utils/ast-helpers.d.ts +1 -1
- package/lib/utils/ast-helpers.js.flow +1 -1
- package/package.json +4 -4
package/lib/index.browser.js
CHANGED
|
@@ -1396,36 +1396,43 @@ function getProgramStatement(path) {
|
|
|
1396
1396
|
return programPath;
|
|
1397
1397
|
}
|
|
1398
1398
|
function isVariableNamedExported(path) {
|
|
1399
|
-
const declaration = path.parentPath;
|
|
1400
1399
|
const idPath = path.get('id');
|
|
1401
|
-
if (!
|
|
1402
|
-
return false;
|
|
1403
|
-
}
|
|
1400
|
+
if (!idPath.isIdentifier()) return false;
|
|
1404
1401
|
const variableName = idPath.node.name;
|
|
1405
|
-
|
|
1406
|
-
|
|
1407
|
-
}
|
|
1402
|
+
const binding = path.scope.getBinding(variableName);
|
|
1403
|
+
if (!binding) return false;
|
|
1408
1404
|
const programPath = getProgramPath(path);
|
|
1409
1405
|
if (programPath == null) {
|
|
1410
1406
|
return false;
|
|
1411
1407
|
}
|
|
1412
|
-
let
|
|
1408
|
+
let exported = false;
|
|
1413
1409
|
programPath.traverse({
|
|
1414
1410
|
ExportNamedDeclaration(p) {
|
|
1415
1411
|
const node = p.node;
|
|
1416
|
-
if (node.source != null)
|
|
1417
|
-
|
|
1418
|
-
|
|
1419
|
-
|
|
1412
|
+
if (node.source != null) return;
|
|
1413
|
+
if (node.declaration) {
|
|
1414
|
+
if (node.declaration.type === 'VariableDeclaration' && node.declaration.declarations.some(d => d.id.type === 'Identifier' && p.scope.getBinding(d.id.name) === binding)) {
|
|
1415
|
+
exported = true;
|
|
1416
|
+
p.stop();
|
|
1417
|
+
}
|
|
1420
1418
|
return;
|
|
1421
1419
|
}
|
|
1422
|
-
|
|
1423
|
-
|
|
1420
|
+
for (const s of node.specifiers ?? []) {
|
|
1421
|
+
if (s.type !== 'ExportSpecifier') continue;
|
|
1422
|
+
if (s.local.type !== 'Identifier') continue;
|
|
1423
|
+
if (s.exported.type !== 'Identifier') continue;
|
|
1424
|
+
if (s.exportKind === 'type') continue;
|
|
1425
|
+
if (s.local.name !== s.exported.name) continue;
|
|
1426
|
+
const localBinding = p.scope.getBinding(s.local.name);
|
|
1427
|
+
if (localBinding === binding) {
|
|
1428
|
+
exported = true;
|
|
1429
|
+
p.stop();
|
|
1430
|
+
return;
|
|
1431
|
+
}
|
|
1424
1432
|
}
|
|
1425
|
-
result = result || node.specifiers.some(s => s.type === 'ExportSpecifier' && s.local.type === 'Identifier' && s.exported.type === 'Identifier' && s.local.name === variableName && s.exported.name === variableName);
|
|
1426
1433
|
}
|
|
1427
1434
|
});
|
|
1428
|
-
return
|
|
1435
|
+
return exported;
|
|
1429
1436
|
}
|
|
1430
1437
|
|
|
1431
1438
|
const defaultOptions = {
|
package/lib/index.js
CHANGED
|
@@ -284,36 +284,43 @@ function getProgramStatement(path) {
|
|
|
284
284
|
return programPath;
|
|
285
285
|
}
|
|
286
286
|
function isVariableNamedExported(path) {
|
|
287
|
-
const declaration = path.parentPath;
|
|
288
287
|
const idPath = path.get('id');
|
|
289
|
-
if (!
|
|
290
|
-
return false;
|
|
291
|
-
}
|
|
288
|
+
if (!idPath.isIdentifier()) return false;
|
|
292
289
|
const variableName = idPath.node.name;
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
}
|
|
290
|
+
const binding = path.scope.getBinding(variableName);
|
|
291
|
+
if (!binding) return false;
|
|
296
292
|
const programPath = getProgramPath(path);
|
|
297
293
|
if (programPath == null) {
|
|
298
294
|
return false;
|
|
299
295
|
}
|
|
300
|
-
let
|
|
296
|
+
let exported = false;
|
|
301
297
|
programPath.traverse({
|
|
302
298
|
ExportNamedDeclaration(p) {
|
|
303
299
|
const node = p.node;
|
|
304
|
-
if (node.source != null)
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
300
|
+
if (node.source != null) return;
|
|
301
|
+
if (node.declaration) {
|
|
302
|
+
if (node.declaration.type === 'VariableDeclaration' && node.declaration.declarations.some(d => d.id.type === 'Identifier' && p.scope.getBinding(d.id.name) === binding)) {
|
|
303
|
+
exported = true;
|
|
304
|
+
p.stop();
|
|
305
|
+
}
|
|
308
306
|
return;
|
|
309
307
|
}
|
|
310
|
-
|
|
311
|
-
|
|
308
|
+
for (const s of node.specifiers ?? []) {
|
|
309
|
+
if (s.type !== 'ExportSpecifier') continue;
|
|
310
|
+
if (s.local.type !== 'Identifier') continue;
|
|
311
|
+
if (s.exported.type !== 'Identifier') continue;
|
|
312
|
+
if (s.exportKind === 'type') continue;
|
|
313
|
+
if (s.local.name !== s.exported.name) continue;
|
|
314
|
+
const localBinding = p.scope.getBinding(s.local.name);
|
|
315
|
+
if (localBinding === binding) {
|
|
316
|
+
exported = true;
|
|
317
|
+
p.stop();
|
|
318
|
+
return;
|
|
319
|
+
}
|
|
312
320
|
}
|
|
313
|
-
result = result || node.specifiers.some(s => s.type === 'ExportSpecifier' && s.local.type === 'Identifier' && s.exported.type === 'Identifier' && s.local.name === variableName && s.exported.name === variableName);
|
|
314
321
|
}
|
|
315
322
|
});
|
|
316
|
-
return
|
|
323
|
+
return exported;
|
|
317
324
|
}
|
|
318
325
|
|
|
319
326
|
const defaultOptions = {
|
|
@@ -41,7 +41,7 @@ export declare function getProgramStatement(path: NodePath): NodePath;
|
|
|
41
41
|
* - Direct named exports: `export const x = ...`
|
|
42
42
|
* - Locally declared named exports: `const x = ...; export { x }`
|
|
43
43
|
*
|
|
44
|
-
* Default exports and re-exports from other files (e.g., `export { x } from './other'`) are NOT allowed.
|
|
44
|
+
* Default exports, aliasing and re-exports from other files (e.g., `export { x } from './other'`) are NOT allowed.
|
|
45
45
|
*/
|
|
46
46
|
export declare function isVariableNamedExported(
|
|
47
47
|
path: NodePath<t.VariableDeclarator>,
|
|
@@ -49,7 +49,7 @@ declare export function getProgramStatement(path: NodePath<>): NodePath<>;
|
|
|
49
49
|
* - Direct named exports: `export const x = ...`
|
|
50
50
|
* - Locally declared named exports: `const x = ...; export { x }`
|
|
51
51
|
*
|
|
52
|
-
* Default exports and re-exports from other files (e.g., `export { x } from './other'`) are NOT allowed.
|
|
52
|
+
* Default exports, aliasing and re-exports from other files (e.g., `export { x } from './other'`) are NOT allowed.
|
|
53
53
|
*/
|
|
54
54
|
declare export function isVariableNamedExported(
|
|
55
55
|
path: NodePath<t.VariableDeclarator>,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@stylexjs/babel-plugin",
|
|
3
|
-
"version": "0.17.
|
|
3
|
+
"version": "0.17.4",
|
|
4
4
|
"description": "StyleX babel plugin.",
|
|
5
5
|
"main": "lib/index.js",
|
|
6
6
|
"browser": "lib/index.browser.js",
|
|
@@ -23,8 +23,8 @@
|
|
|
23
23
|
"@babel/traverse": "^7.26.8",
|
|
24
24
|
"@babel/types": "^7.26.8",
|
|
25
25
|
"@dual-bundle/import-meta-resolve": "^4.1.0",
|
|
26
|
-
"@stylexjs/shared": "0.17.
|
|
27
|
-
"@stylexjs/stylex": "0.17.
|
|
26
|
+
"@stylexjs/shared": "0.17.4",
|
|
27
|
+
"@stylexjs/stylex": "0.17.4",
|
|
28
28
|
"postcss-value-parser": "^4.1.0"
|
|
29
29
|
},
|
|
30
30
|
"devDependencies": {
|
|
@@ -37,7 +37,7 @@
|
|
|
37
37
|
"babel-plugin-syntax-hermes-parser": "^0.32.1",
|
|
38
38
|
"path-browserify": "^1.0.1",
|
|
39
39
|
"rollup": "^4.24.0",
|
|
40
|
-
"scripts": "0.17.
|
|
40
|
+
"scripts": "0.17.4"
|
|
41
41
|
},
|
|
42
42
|
"files": [
|
|
43
43
|
"flow_modules/*",
|