-
Notifications
You must be signed in to change notification settings - Fork 186
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
Would you consider exposing a sync resolve function? #46
Comments
If possible, it would be useful for my webpack dependency suite too. Would be especially useful if the sync resolve function could return cached values from the async resolve in case the FS is async in the calling context. |
So it turns out this is catered for; just not really documented. I've written a blog post about it here. The TL;DR; show me an example is: const node = require("enhanced-resolve/lib/node");
function makeSyncResolver(options) {
return node.create.sync(options.resolve);
}
const resolveSync = makeSyncResolver(loader.options);
const resolvedFileName = resolveSync(
undefined,
'C:\source\ts-loader\.test\babel-issue92',
'./submodule/submodule'
);
// resolvedFileName: C:\source\ts-loader\.test\babel-issue92\submodule\submodule.tsx |
@johnnyreilly Would this work with a custom |
I haven't tried - have a go! |
@johnnyreilly please feel free to open a PR to the documentation of this repo (the README) describe this sync resolver. In the meantime, I'm going to consider this issue closed. Thanks! |
Both awesome-typescript-loader and ts-loader are presently rolling their own sync resolver functions. It'd be great to get official support for this directly. Is that something you'd consider supporting? I suspect there may well be others out there similarly implementing this by hand as well.
cc @jbrantly @s-panferov
The text was updated successfully, but these errors were encountered: