Skip to content

Conversation

xiaoxiaojx
Copy link
Member

No description provided.

Copy link

codecov bot commented Sep 11, 2025

Codecov Report

❌ Patch coverage is 91.34199% with 20 lines in your changes missing coverage. Please review.
✅ Project coverage is 92.74%. Comparing base (79e2961) to head (50aa0ca).

Files with missing lines Patch % Lines
lib/TsconfigPathsUtils.js 84.69% 15 Missing ⚠️
lib/TsconfigPathsPlugin.js 91.89% 3 Missing ⚠️
lib/index.js 0.00% 2 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main     #463      +/-   ##
==========================================
- Coverage   93.13%   92.74%   -0.39%     
==========================================
  Files          45       49       +4     
  Lines        2155     2303     +148     
  Branches      654      696      +42     
==========================================
+ Hits         2007     2136     +129     
- Misses        119      138      +19     
  Partials       29       29              
Flag Coverage Δ
integration 92.74% <91.34%> (-0.39%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@xiaoxiaojx xiaoxiaojx changed the title [WIP] feat: add TsconfigPathsPlugin feat: add TsconfigPathsPlugin Sep 12, 2025
}
},
);
}
Copy link
Member

@alexander-akait alexander-akait Sep 18, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we union two hooks? Looks like we can collect directories and call different helpers (aliasResolveHandler or modulesResolveHandler), less hooks = less memory

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For this tsconfig.json, it’s essentially equivalent to the following enhanced-resolve config.
So, to reuse code, we ended up using two different hooks.

// tsconfig.json
{
    "paths": {
      "foo": ["./src/mapped/foo"],
      "*": ["./src/mapped/star/*"]
    }
}
// enhanced-resolve config
{
  alias: {
    foo: "/xxx/my-app/src/mapped/foo"
  },
  modules: ["/xxx/my-app/src/mapped/star"]
}

We can’t really unify them, since alias belongs to the raw-resolve phase while modules belongs to the raw-module phase.

? this.configFile
: resolver.join(process.cwd(), this.configFile);

const mainOptions = await this.readTsconfigCompilerOptions(
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we can cache readTsconfigCompilerOptions using (and the same for readTsconfigCompilerOptions below)

this.tsconfigProcessorCache = new WeakMap<TS_CONFIG_JSON_VALUE, { aliases: Aliases, references: References }>;

So we will read everything only on the first run, and will keep results until GC allow it

Feel free to think how we can avoid more tasks on the second and third calls

This comment was marked as outdated.

Copy link
Member Author

@xiaoxiaojx xiaoxiaojx Sep 21, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What if we just store the data on this.tsconfigPathsData?
It doesn’t need to be garbage-collected anyway, so the cache implementation doesn’t have to be too complex.

Copy link
Member

@alexander-akait alexander-akait left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added comments, also let's add test cases, good start for this plugin, thank you

@xiaoxiaojx

This comment was marked as outdated.

@xiaoxiaojx xiaoxiaojx changed the title feat: add TsconfigPathsPlugin [WIP] feat: add TsconfigPathsPlugin Sep 24, 2025
@xiaoxiaojx xiaoxiaojx force-pushed the feat/tsconfigPaths branch 2 times, most recently from b1a6c4e to f45b2f3 Compare September 25, 2025 18:22
@xiaoxiaojx xiaoxiaojx changed the title [WIP] feat: add TsconfigPathsPlugin feat: add TsconfigPathsPlugin Sep 25, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants