-
-
Notifications
You must be signed in to change notification settings - Fork 198
feat: add TsconfigPathsPlugin #463
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
Codecov Report❌ Patch coverage is
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
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
3a9a876
to
9243884
Compare
} | ||
}, | ||
); | ||
} |
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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.
lib/TsconfigPathsPlugin.js
Outdated
? this.configFile | ||
: resolver.join(process.cwd(), this.configFile); | ||
|
||
const mainOptions = await this.readTsconfigCompilerOptions( |
There was a problem hiding this comment.
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.
This comment was marked as outdated.
Sorry, something went wrong.
There was a problem hiding this comment.
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.
There was a problem hiding this 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
This comment was marked as outdated.
This comment was marked as outdated.
b1a6c4e
to
f45b2f3
Compare
6af0057
to
49820ff
Compare
4362983
to
50aa0ca
Compare
No description provided.