@bamboocss/extractor 1.43.1 → 1.44.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 +32 -2
- package/dist/index.mjs +32 -2
- package/package.json +2 -2
package/dist/index.cjs
CHANGED
|
@@ -1345,6 +1345,35 @@ const resolveBundledHelperImport = (name, node) => {
|
|
|
1345
1345
|
mod: "preact/jsx-runtime"
|
|
1346
1346
|
};
|
|
1347
1347
|
};
|
|
1348
|
+
/**
|
|
1349
|
+
* Text a module must contain before either bundled-output walk below can match anything.
|
|
1350
|
+
*
|
|
1351
|
+
* Both walks hunt for *bundler output* — Parcel's module registry, and Vue/Solid/Preact runtime
|
|
1352
|
+
* helpers inlined by a bundler — and both are whole-tree reads that run on every extracted module.
|
|
1353
|
+
* Hand-written source matches neither, which is nearly every module a project has.
|
|
1354
|
+
*
|
|
1355
|
+
* Each entry is a necessary condition of some branch, read off the matchers themselves:
|
|
1356
|
+
* `parcelRegister` is the callee the first walk tests for, and the rest are the substrings
|
|
1357
|
+
* `resolveBundledHelperImport` requires — one per framework it recognises. They are matched against
|
|
1358
|
+
* `node.getText()`, which is a slice of this same text, so if none appears here none can appear in
|
|
1359
|
+
* any declaration.
|
|
1360
|
+
*
|
|
1361
|
+
* `\u` is in the list because the Parcel callee is compared through `getText()`, which returns an
|
|
1362
|
+
* identifier as the compiler resolves it: `\u0070arcelRegister` matches the walk while the plain
|
|
1363
|
+
* name appears nowhere. The helper matchers read source text and need no such allowance, but one
|
|
1364
|
+
* escape anywhere costs only the walk that would have run regardless.
|
|
1365
|
+
*/
|
|
1366
|
+
const BUNDLED_OUTPUT_MARKERS = [
|
|
1367
|
+
"parcelRegister",
|
|
1368
|
+
"type, props = null, children = null",
|
|
1369
|
+
"_createVNode",
|
|
1370
|
+
"const ret = {}",
|
|
1371
|
+
"Comp(props || {})",
|
|
1372
|
+
"resolveSource",
|
|
1373
|
+
"__v:",
|
|
1374
|
+
"\\u"
|
|
1375
|
+
];
|
|
1376
|
+
const mayHoldBundledOutput = (text) => BUNDLED_OUTPUT_MARKERS.some((marker) => text.includes(marker));
|
|
1348
1377
|
const collectImports = (sourceFile) => {
|
|
1349
1378
|
const named = /* @__PURE__ */ new Map();
|
|
1350
1379
|
const defaultImports = /* @__PURE__ */ new Map();
|
|
@@ -1370,7 +1399,8 @@ const collectImports = (sourceFile) => {
|
|
|
1370
1399
|
if (/requirereact/i.test(calleeName)) return "react";
|
|
1371
1400
|
}
|
|
1372
1401
|
};
|
|
1373
|
-
sourceFile.
|
|
1402
|
+
const bundledCandidates = mayHoldBundledOutput(sourceFile.getFullText());
|
|
1403
|
+
(bundledCandidates ? sourceFile.getDescendantsOfKind(ts_morph.SyntaxKind.CallExpression) : []).forEach((callExpression) => {
|
|
1374
1404
|
const callee = unwrapExpression(callExpression.getExpression());
|
|
1375
1405
|
if (!ts_morph.Node.isIdentifier(callee) || callee.getText() !== "parcelRegister") return;
|
|
1376
1406
|
const [idArg, factoryArg] = callExpression.getArguments();
|
|
@@ -1416,7 +1446,7 @@ const collectImports = (sourceFile) => {
|
|
|
1416
1446
|
if (!mod) return;
|
|
1417
1447
|
bundledNamespace.set(variableName, mod);
|
|
1418
1448
|
});
|
|
1419
|
-
sourceFile.getDescendantsOfKind(ts_morph.SyntaxKind.FunctionDeclaration).forEach((declaration) => {
|
|
1449
|
+
(bundledCandidates ? sourceFile.getDescendantsOfKind(ts_morph.SyntaxKind.FunctionDeclaration) : []).forEach((declaration) => {
|
|
1420
1450
|
const bundledImport = resolveBundledHelperImport(declaration.getName() ?? "", declaration);
|
|
1421
1451
|
if (!bundledImport || !declaration.getName()) return;
|
|
1422
1452
|
bundledNamed.set(declaration.getName(), bundledImport);
|
package/dist/index.mjs
CHANGED
|
@@ -1344,6 +1344,35 @@ const resolveBundledHelperImport = (name, node) => {
|
|
|
1344
1344
|
mod: "preact/jsx-runtime"
|
|
1345
1345
|
};
|
|
1346
1346
|
};
|
|
1347
|
+
/**
|
|
1348
|
+
* Text a module must contain before either bundled-output walk below can match anything.
|
|
1349
|
+
*
|
|
1350
|
+
* Both walks hunt for *bundler output* — Parcel's module registry, and Vue/Solid/Preact runtime
|
|
1351
|
+
* helpers inlined by a bundler — and both are whole-tree reads that run on every extracted module.
|
|
1352
|
+
* Hand-written source matches neither, which is nearly every module a project has.
|
|
1353
|
+
*
|
|
1354
|
+
* Each entry is a necessary condition of some branch, read off the matchers themselves:
|
|
1355
|
+
* `parcelRegister` is the callee the first walk tests for, and the rest are the substrings
|
|
1356
|
+
* `resolveBundledHelperImport` requires — one per framework it recognises. They are matched against
|
|
1357
|
+
* `node.getText()`, which is a slice of this same text, so if none appears here none can appear in
|
|
1358
|
+
* any declaration.
|
|
1359
|
+
*
|
|
1360
|
+
* `\u` is in the list because the Parcel callee is compared through `getText()`, which returns an
|
|
1361
|
+
* identifier as the compiler resolves it: `\u0070arcelRegister` matches the walk while the plain
|
|
1362
|
+
* name appears nowhere. The helper matchers read source text and need no such allowance, but one
|
|
1363
|
+
* escape anywhere costs only the walk that would have run regardless.
|
|
1364
|
+
*/
|
|
1365
|
+
const BUNDLED_OUTPUT_MARKERS = [
|
|
1366
|
+
"parcelRegister",
|
|
1367
|
+
"type, props = null, children = null",
|
|
1368
|
+
"_createVNode",
|
|
1369
|
+
"const ret = {}",
|
|
1370
|
+
"Comp(props || {})",
|
|
1371
|
+
"resolveSource",
|
|
1372
|
+
"__v:",
|
|
1373
|
+
"\\u"
|
|
1374
|
+
];
|
|
1375
|
+
const mayHoldBundledOutput = (text) => BUNDLED_OUTPUT_MARKERS.some((marker) => text.includes(marker));
|
|
1347
1376
|
const collectImports = (sourceFile) => {
|
|
1348
1377
|
const named = /* @__PURE__ */ new Map();
|
|
1349
1378
|
const defaultImports = /* @__PURE__ */ new Map();
|
|
@@ -1369,7 +1398,8 @@ const collectImports = (sourceFile) => {
|
|
|
1369
1398
|
if (/requirereact/i.test(calleeName)) return "react";
|
|
1370
1399
|
}
|
|
1371
1400
|
};
|
|
1372
|
-
sourceFile.
|
|
1401
|
+
const bundledCandidates = mayHoldBundledOutput(sourceFile.getFullText());
|
|
1402
|
+
(bundledCandidates ? sourceFile.getDescendantsOfKind(SyntaxKind.CallExpression) : []).forEach((callExpression) => {
|
|
1373
1403
|
const callee = unwrapExpression(callExpression.getExpression());
|
|
1374
1404
|
if (!Node.isIdentifier(callee) || callee.getText() !== "parcelRegister") return;
|
|
1375
1405
|
const [idArg, factoryArg] = callExpression.getArguments();
|
|
@@ -1415,7 +1445,7 @@ const collectImports = (sourceFile) => {
|
|
|
1415
1445
|
if (!mod) return;
|
|
1416
1446
|
bundledNamespace.set(variableName, mod);
|
|
1417
1447
|
});
|
|
1418
|
-
sourceFile.getDescendantsOfKind(SyntaxKind.FunctionDeclaration).forEach((declaration) => {
|
|
1448
|
+
(bundledCandidates ? sourceFile.getDescendantsOfKind(SyntaxKind.FunctionDeclaration) : []).forEach((declaration) => {
|
|
1419
1449
|
const bundledImport = resolveBundledHelperImport(declaration.getName() ?? "", declaration);
|
|
1420
1450
|
if (!bundledImport || !declaration.getName()) return;
|
|
1421
1451
|
bundledNamed.set(declaration.getName(), bundledImport);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@bamboocss/extractor",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.44.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": "2.0.0",
|
|
37
37
|
"ts-morph": "28.0.0",
|
|
38
|
-
"@bamboocss/shared": "1.
|
|
38
|
+
"@bamboocss/shared": "1.44.1"
|
|
39
39
|
},
|
|
40
40
|
"scripts": {
|
|
41
41
|
"build": "tsdown src/index.ts --format=cjs,esm --shims --dts",
|