@bamboocss/extractor 1.16.0 → 1.16.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.
- package/dist/index.cjs +47 -23
- package/dist/index.mjs +47 -23
- package/package.json +2 -2
package/dist/index.cjs
CHANGED
|
@@ -1379,6 +1379,34 @@ const runtimeProfiles = [
|
|
|
1379
1379
|
getPropNodes: getArgsAt(1)
|
|
1380
1380
|
}
|
|
1381
1381
|
];
|
|
1382
|
+
/**
|
|
1383
|
+
* The declaration `identifier` binds to, found by walking its enclosing scopes outward.
|
|
1384
|
+
*
|
|
1385
|
+
* Deliberately not `identifier.getDefinitions()`. That is a language-service query, and
|
|
1386
|
+
* the first one forces `synchronizeHostData` -> `createProgram`, which resolves, parses
|
|
1387
|
+
* and binds the whole transitive `.d.ts` closure of the project — in a 5-file sandbox
|
|
1388
|
+
* that is 161 files and 5.1MB, most of it `node_modules`, and it grows with the
|
|
1389
|
+
* dependency graph rather than with the user's source. The extractor is built to avoid
|
|
1390
|
+
* exactly that: `createTsProject` sets `skipAddingFilesFromTsConfig`,
|
|
1391
|
+
* `skipFileDependencyResolution` and `skipLoadingLibFiles`, and `getModuleSpecifierSourceFile`
|
|
1392
|
+
* carries the same note. Inside a bundler the program is built alongside the module graph
|
|
1393
|
+
* in one heap, so the cost lands as a slow build and then an OOM.
|
|
1394
|
+
*
|
|
1395
|
+
* A lexical walk is enough because this only ever runs for a callee that is declared in
|
|
1396
|
+
* this file: `resolveCallee` matches against the import map first, and `collectImports`
|
|
1397
|
+
* covers every import form. Innermost scope wins, which is how the binding resolves
|
|
1398
|
+
* anyway, and a scope can hold only one declaration of a given name.
|
|
1399
|
+
*/
|
|
1400
|
+
const findLocalDeclaration = (identifier) => {
|
|
1401
|
+
const name = identifier.getText();
|
|
1402
|
+
for (let scope = identifier.getParent(); scope; scope = scope.getParent()) {
|
|
1403
|
+
if (!ts_morph.Node.isStatemented(scope)) continue;
|
|
1404
|
+
const variable = scope.getVariableDeclaration(name);
|
|
1405
|
+
if (variable) return variable;
|
|
1406
|
+
const fn = scope.getFunction(name);
|
|
1407
|
+
if (fn) return fn;
|
|
1408
|
+
}
|
|
1409
|
+
};
|
|
1382
1410
|
const createCompiledJsxContext = (sourceFile) => {
|
|
1383
1411
|
const imports = collectImports(sourceFile);
|
|
1384
1412
|
const normalizeCallee = (node) => {
|
|
@@ -1405,30 +1433,26 @@ const createCompiledJsxContext = (sourceFile) => {
|
|
|
1405
1433
|
if (ts_morph.Node.isConditionalExpression(expression)) return resolveLocalAlias(expression.getWhenTrue()) ?? resolveLocalAlias(expression.getWhenFalse());
|
|
1406
1434
|
if (ts_morph.Node.isBinaryExpression(expression) && expression.getOperatorToken().getKind() === ts_morph.SyntaxKind.CommaToken) return resolveLocalAlias(expression.getRight());
|
|
1407
1435
|
};
|
|
1408
|
-
|
|
1409
|
-
|
|
1410
|
-
|
|
1411
|
-
|
|
1412
|
-
|
|
1413
|
-
|
|
1414
|
-
|
|
1415
|
-
|
|
1416
|
-
|
|
1417
|
-
|
|
1418
|
-
|
|
1419
|
-
return resolved;
|
|
1420
|
-
}
|
|
1421
|
-
if (ts_morph.Node.isVariableDeclaration(declaration)) {
|
|
1422
|
-
const directImport = resolveBundledHelperImport(declaration.getName(), declaration.getInitializer());
|
|
1423
|
-
const aliasImport = directImport ? {
|
|
1424
|
-
mod: directImport.mod,
|
|
1425
|
-
importedName: directImport.importedName
|
|
1426
|
-
} : resolveLocalAlias(declaration.getInitializer());
|
|
1427
|
-
if (!aliasImport) continue;
|
|
1428
|
-
localDefinitionCache.set(name, aliasImport);
|
|
1429
|
-
return aliasImport;
|
|
1430
|
-
}
|
|
1436
|
+
const declaration = findLocalDeclaration(identifier);
|
|
1437
|
+
if (!declaration) return;
|
|
1438
|
+
if (ts_morph.Node.isFunctionDeclaration(declaration)) {
|
|
1439
|
+
const imported = resolveBundledHelperImport(declaration.getName() ?? name, declaration);
|
|
1440
|
+
if (!imported) return;
|
|
1441
|
+
const resolved = {
|
|
1442
|
+
mod: imported.mod,
|
|
1443
|
+
importedName: imported.importedName
|
|
1444
|
+
};
|
|
1445
|
+
localDefinitionCache.set(name, resolved);
|
|
1446
|
+
return resolved;
|
|
1431
1447
|
}
|
|
1448
|
+
const directImport = resolveBundledHelperImport(declaration.getName(), declaration.getInitializer());
|
|
1449
|
+
const aliasImport = directImport ? {
|
|
1450
|
+
mod: directImport.mod,
|
|
1451
|
+
importedName: directImport.importedName
|
|
1452
|
+
} : resolveLocalAlias(declaration.getInitializer());
|
|
1453
|
+
if (!aliasImport) return;
|
|
1454
|
+
localDefinitionCache.set(name, aliasImport);
|
|
1455
|
+
return aliasImport;
|
|
1432
1456
|
};
|
|
1433
1457
|
const resolveCallee = (node) => {
|
|
1434
1458
|
const expression = normalizeCallee(node);
|
package/dist/index.mjs
CHANGED
|
@@ -1378,6 +1378,34 @@ const runtimeProfiles = [
|
|
|
1378
1378
|
getPropNodes: getArgsAt(1)
|
|
1379
1379
|
}
|
|
1380
1380
|
];
|
|
1381
|
+
/**
|
|
1382
|
+
* The declaration `identifier` binds to, found by walking its enclosing scopes outward.
|
|
1383
|
+
*
|
|
1384
|
+
* Deliberately not `identifier.getDefinitions()`. That is a language-service query, and
|
|
1385
|
+
* the first one forces `synchronizeHostData` -> `createProgram`, which resolves, parses
|
|
1386
|
+
* and binds the whole transitive `.d.ts` closure of the project — in a 5-file sandbox
|
|
1387
|
+
* that is 161 files and 5.1MB, most of it `node_modules`, and it grows with the
|
|
1388
|
+
* dependency graph rather than with the user's source. The extractor is built to avoid
|
|
1389
|
+
* exactly that: `createTsProject` sets `skipAddingFilesFromTsConfig`,
|
|
1390
|
+
* `skipFileDependencyResolution` and `skipLoadingLibFiles`, and `getModuleSpecifierSourceFile`
|
|
1391
|
+
* carries the same note. Inside a bundler the program is built alongside the module graph
|
|
1392
|
+
* in one heap, so the cost lands as a slow build and then an OOM.
|
|
1393
|
+
*
|
|
1394
|
+
* A lexical walk is enough because this only ever runs for a callee that is declared in
|
|
1395
|
+
* this file: `resolveCallee` matches against the import map first, and `collectImports`
|
|
1396
|
+
* covers every import form. Innermost scope wins, which is how the binding resolves
|
|
1397
|
+
* anyway, and a scope can hold only one declaration of a given name.
|
|
1398
|
+
*/
|
|
1399
|
+
const findLocalDeclaration = (identifier) => {
|
|
1400
|
+
const name = identifier.getText();
|
|
1401
|
+
for (let scope = identifier.getParent(); scope; scope = scope.getParent()) {
|
|
1402
|
+
if (!Node.isStatemented(scope)) continue;
|
|
1403
|
+
const variable = scope.getVariableDeclaration(name);
|
|
1404
|
+
if (variable) return variable;
|
|
1405
|
+
const fn = scope.getFunction(name);
|
|
1406
|
+
if (fn) return fn;
|
|
1407
|
+
}
|
|
1408
|
+
};
|
|
1381
1409
|
const createCompiledJsxContext = (sourceFile) => {
|
|
1382
1410
|
const imports = collectImports(sourceFile);
|
|
1383
1411
|
const normalizeCallee = (node) => {
|
|
@@ -1404,30 +1432,26 @@ const createCompiledJsxContext = (sourceFile) => {
|
|
|
1404
1432
|
if (Node.isConditionalExpression(expression)) return resolveLocalAlias(expression.getWhenTrue()) ?? resolveLocalAlias(expression.getWhenFalse());
|
|
1405
1433
|
if (Node.isBinaryExpression(expression) && expression.getOperatorToken().getKind() === SyntaxKind.CommaToken) return resolveLocalAlias(expression.getRight());
|
|
1406
1434
|
};
|
|
1407
|
-
|
|
1408
|
-
|
|
1409
|
-
|
|
1410
|
-
|
|
1411
|
-
|
|
1412
|
-
|
|
1413
|
-
|
|
1414
|
-
|
|
1415
|
-
|
|
1416
|
-
|
|
1417
|
-
|
|
1418
|
-
return resolved;
|
|
1419
|
-
}
|
|
1420
|
-
if (Node.isVariableDeclaration(declaration)) {
|
|
1421
|
-
const directImport = resolveBundledHelperImport(declaration.getName(), declaration.getInitializer());
|
|
1422
|
-
const aliasImport = directImport ? {
|
|
1423
|
-
mod: directImport.mod,
|
|
1424
|
-
importedName: directImport.importedName
|
|
1425
|
-
} : resolveLocalAlias(declaration.getInitializer());
|
|
1426
|
-
if (!aliasImport) continue;
|
|
1427
|
-
localDefinitionCache.set(name, aliasImport);
|
|
1428
|
-
return aliasImport;
|
|
1429
|
-
}
|
|
1435
|
+
const declaration = findLocalDeclaration(identifier);
|
|
1436
|
+
if (!declaration) return;
|
|
1437
|
+
if (Node.isFunctionDeclaration(declaration)) {
|
|
1438
|
+
const imported = resolveBundledHelperImport(declaration.getName() ?? name, declaration);
|
|
1439
|
+
if (!imported) return;
|
|
1440
|
+
const resolved = {
|
|
1441
|
+
mod: imported.mod,
|
|
1442
|
+
importedName: imported.importedName
|
|
1443
|
+
};
|
|
1444
|
+
localDefinitionCache.set(name, resolved);
|
|
1445
|
+
return resolved;
|
|
1430
1446
|
}
|
|
1447
|
+
const directImport = resolveBundledHelperImport(declaration.getName(), declaration.getInitializer());
|
|
1448
|
+
const aliasImport = directImport ? {
|
|
1449
|
+
mod: directImport.mod,
|
|
1450
|
+
importedName: directImport.importedName
|
|
1451
|
+
} : resolveLocalAlias(declaration.getInitializer());
|
|
1452
|
+
if (!aliasImport) return;
|
|
1453
|
+
localDefinitionCache.set(name, aliasImport);
|
|
1454
|
+
return aliasImport;
|
|
1431
1455
|
};
|
|
1432
1456
|
const resolveCallee = (node) => {
|
|
1433
1457
|
const expression = normalizeCallee(node);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@bamboocss/extractor",
|
|
3
|
-
"version": "1.16.
|
|
3
|
+
"version": "1.16.1",
|
|
4
4
|
"description": "The css extractor for css bamboo",
|
|
5
5
|
"homepage": "https://bamboocss.com",
|
|
6
6
|
"license": "MIT",
|
|
@@ -35,7 +35,7 @@
|
|
|
35
35
|
"dependencies": {
|
|
36
36
|
"ts-evaluator": "1.2.0",
|
|
37
37
|
"ts-morph": "28.0.0",
|
|
38
|
-
"@bamboocss/shared": "1.16.
|
|
38
|
+
"@bamboocss/shared": "1.16.1"
|
|
39
39
|
},
|
|
40
40
|
"scripts": {
|
|
41
41
|
"build": "tsdown src/index.ts --format=cjs,esm --shims --dts",
|