deslop-js 0.8.2 → 0.9.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.
package/dist/index.cjs CHANGED
@@ -7513,7 +7513,7 @@ const traceReachability = (graph) => {
7513
7513
  //#endregion
7514
7514
  //#region src/linker/re-exports.ts
7515
7515
  const resolveReExportChains = (graph) => {
7516
- const sourceToTargets = buildSourceTargetMap(graph);
7516
+ const sourceToWildcardTargets = buildSourceWildcardTargetMap(graph);
7517
7517
  const maxIterations = graph.modules.length * 2 + 1;
7518
7518
  let didChange = true;
7519
7519
  let iterationCount = 0;
@@ -7521,43 +7521,40 @@ const resolveReExportChains = (graph) => {
7521
7521
  didChange = false;
7522
7522
  iterationCount++;
7523
7523
  for (const module of graph.modules) {
7524
- const originalExportCount = module.exports.length;
7525
- for (let exportIndex = 0; exportIndex < originalExportCount; exportIndex++) {
7526
- const exportInfo = module.exports[exportIndex];
7527
- if (!exportInfo.isReExport || !exportInfo.reExportSource) continue;
7528
- if (!exportInfo.isNamespaceReExport) continue;
7529
- const targetIndices = sourceToTargets.get(module.fileId.index);
7530
- if (!targetIndices) continue;
7531
- for (const targetIndex of targetIndices) {
7532
- const targetModule = graph.modules[targetIndex];
7533
- if (!targetModule) continue;
7534
- for (const targetExport of targetModule.exports) {
7535
- if (targetExport.name === "*" && targetExport.isNamespaceReExport) continue;
7536
- if (!module.exports.some((existingExport) => existingExport.name === targetExport.name && !existingExport.isNamespaceReExport)) {
7537
- module.exports.push({
7538
- name: targetExport.name,
7539
- isDefault: targetExport.isDefault,
7540
- isTypeOnly: targetExport.isTypeOnly || exportInfo.isTypeOnly,
7541
- isReExport: true,
7542
- isSynthetic: true,
7543
- reExportSource: exportInfo.reExportSource,
7544
- reExportOriginalName: targetExport.name,
7545
- isNamespaceReExport: false,
7546
- line: exportInfo.line,
7547
- column: exportInfo.column
7548
- });
7549
- didChange = true;
7550
- }
7551
- }
7524
+ const namespaceReExport = module.exports.find((exportInfo) => exportInfo.isReExport && exportInfo.reExportSource !== void 0 && exportInfo.isNamespaceReExport);
7525
+ if (!namespaceReExport) continue;
7526
+ const targetIndices = sourceToWildcardTargets.get(module.fileId.index);
7527
+ if (!targetIndices) continue;
7528
+ const existingExportNames = new Set(module.exports.filter((exportInfo) => !exportInfo.isNamespaceReExport).map((exportInfo) => exportInfo.name));
7529
+ for (const targetIndex of targetIndices) {
7530
+ const targetModule = graph.modules[targetIndex];
7531
+ if (!targetModule) continue;
7532
+ for (const targetExport of targetModule.exports) {
7533
+ if (targetExport.name === "*" && targetExport.isNamespaceReExport) continue;
7534
+ if (existingExportNames.has(targetExport.name)) continue;
7535
+ existingExportNames.add(targetExport.name);
7536
+ module.exports.push({
7537
+ name: targetExport.name,
7538
+ isDefault: targetExport.isDefault,
7539
+ isTypeOnly: targetExport.isTypeOnly || namespaceReExport.isTypeOnly,
7540
+ isReExport: true,
7541
+ isSynthetic: true,
7542
+ reExportSource: namespaceReExport.reExportSource,
7543
+ reExportOriginalName: targetExport.name,
7544
+ isNamespaceReExport: false,
7545
+ line: namespaceReExport.line,
7546
+ column: namespaceReExport.column
7547
+ });
7548
+ didChange = true;
7552
7549
  }
7553
7550
  }
7554
7551
  }
7555
7552
  }
7556
7553
  };
7557
- const buildSourceTargetMap = (graph) => {
7554
+ const buildSourceWildcardTargetMap = (graph) => {
7558
7555
  const sourceTargets = /* @__PURE__ */ new Map();
7559
7556
  for (const edge of graph.edges) {
7560
- if (!edge.isReExportEdge) continue;
7557
+ if (!edge.isReExportEdge || !edge.reExportedNames.includes("*")) continue;
7561
7558
  const existing = sourceTargets.get(edge.source);
7562
7559
  if (existing) {
7563
7560
  if (!existing.includes(edge.target)) existing.push(edge.target);
package/dist/index.mjs CHANGED
@@ -7480,7 +7480,7 @@ const traceReachability = (graph) => {
7480
7480
  //#endregion
7481
7481
  //#region src/linker/re-exports.ts
7482
7482
  const resolveReExportChains = (graph) => {
7483
- const sourceToTargets = buildSourceTargetMap(graph);
7483
+ const sourceToWildcardTargets = buildSourceWildcardTargetMap(graph);
7484
7484
  const maxIterations = graph.modules.length * 2 + 1;
7485
7485
  let didChange = true;
7486
7486
  let iterationCount = 0;
@@ -7488,43 +7488,40 @@ const resolveReExportChains = (graph) => {
7488
7488
  didChange = false;
7489
7489
  iterationCount++;
7490
7490
  for (const module of graph.modules) {
7491
- const originalExportCount = module.exports.length;
7492
- for (let exportIndex = 0; exportIndex < originalExportCount; exportIndex++) {
7493
- const exportInfo = module.exports[exportIndex];
7494
- if (!exportInfo.isReExport || !exportInfo.reExportSource) continue;
7495
- if (!exportInfo.isNamespaceReExport) continue;
7496
- const targetIndices = sourceToTargets.get(module.fileId.index);
7497
- if (!targetIndices) continue;
7498
- for (const targetIndex of targetIndices) {
7499
- const targetModule = graph.modules[targetIndex];
7500
- if (!targetModule) continue;
7501
- for (const targetExport of targetModule.exports) {
7502
- if (targetExport.name === "*" && targetExport.isNamespaceReExport) continue;
7503
- if (!module.exports.some((existingExport) => existingExport.name === targetExport.name && !existingExport.isNamespaceReExport)) {
7504
- module.exports.push({
7505
- name: targetExport.name,
7506
- isDefault: targetExport.isDefault,
7507
- isTypeOnly: targetExport.isTypeOnly || exportInfo.isTypeOnly,
7508
- isReExport: true,
7509
- isSynthetic: true,
7510
- reExportSource: exportInfo.reExportSource,
7511
- reExportOriginalName: targetExport.name,
7512
- isNamespaceReExport: false,
7513
- line: exportInfo.line,
7514
- column: exportInfo.column
7515
- });
7516
- didChange = true;
7517
- }
7518
- }
7491
+ const namespaceReExport = module.exports.find((exportInfo) => exportInfo.isReExport && exportInfo.reExportSource !== void 0 && exportInfo.isNamespaceReExport);
7492
+ if (!namespaceReExport) continue;
7493
+ const targetIndices = sourceToWildcardTargets.get(module.fileId.index);
7494
+ if (!targetIndices) continue;
7495
+ const existingExportNames = new Set(module.exports.filter((exportInfo) => !exportInfo.isNamespaceReExport).map((exportInfo) => exportInfo.name));
7496
+ for (const targetIndex of targetIndices) {
7497
+ const targetModule = graph.modules[targetIndex];
7498
+ if (!targetModule) continue;
7499
+ for (const targetExport of targetModule.exports) {
7500
+ if (targetExport.name === "*" && targetExport.isNamespaceReExport) continue;
7501
+ if (existingExportNames.has(targetExport.name)) continue;
7502
+ existingExportNames.add(targetExport.name);
7503
+ module.exports.push({
7504
+ name: targetExport.name,
7505
+ isDefault: targetExport.isDefault,
7506
+ isTypeOnly: targetExport.isTypeOnly || namespaceReExport.isTypeOnly,
7507
+ isReExport: true,
7508
+ isSynthetic: true,
7509
+ reExportSource: namespaceReExport.reExportSource,
7510
+ reExportOriginalName: targetExport.name,
7511
+ isNamespaceReExport: false,
7512
+ line: namespaceReExport.line,
7513
+ column: namespaceReExport.column
7514
+ });
7515
+ didChange = true;
7519
7516
  }
7520
7517
  }
7521
7518
  }
7522
7519
  }
7523
7520
  };
7524
- const buildSourceTargetMap = (graph) => {
7521
+ const buildSourceWildcardTargetMap = (graph) => {
7525
7522
  const sourceTargets = /* @__PURE__ */ new Map();
7526
7523
  for (const edge of graph.edges) {
7527
- if (!edge.isReExportEdge) continue;
7524
+ if (!edge.isReExportEdge || !edge.reExportedNames.includes("*")) continue;
7528
7525
  const existing = sourceTargets.get(edge.source);
7529
7526
  if (existing) {
7530
7527
  if (!existing.includes(edge.target)) existing.push(edge.target);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "deslop-js",
3
- "version": "0.8.2",
3
+ "version": "0.9.0",
4
4
  "description": "Remove AI slop from JavaScript code.",
5
5
  "keywords": [
6
6
  "dead-code",
@@ -63,11 +63,11 @@
63
63
  "access": "public"
64
64
  },
65
65
  "dependencies": {
66
- "@oxc-project/types": "^0.138.0",
66
+ "@oxc-project/types": "^0.141.0",
67
67
  "fast-glob": "^3.3.3",
68
68
  "minimatch": "^10.2.5",
69
- "oxc-parser": "^0.138.0",
70
- "oxc-resolver": "^11.23.0",
69
+ "oxc-parser": "^0.141.0",
70
+ "oxc-resolver": "^11.24.2",
71
71
  "typescript": ">=5.0.4 <6"
72
72
  },
73
73
  "devDependencies": {