Skip to content
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

Custom loader integration #293

Closed
guybedford opened this issue Feb 27, 2015 · 8 comments
Closed

Custom loader integration #293

guybedford opened this issue Feb 27, 2015 · 8 comments

Comments

@guybedford
Copy link

Is it currently possible to specify a custom resolve hook? It would be really useful with this to be able to integrate a custom loader like SystemJS into Flow, which has its own resolution rules.

Basically, allowing a loader resolution hook to be provided as input. Generally the resolve hook takes the following form:

function resolve(url, parentUrl) {
  return resolvedUrl;
}

In the loader I believe it may also allow a promise to be returned for asynchronous resolution.

Does such a thing exist? Does it sound sensible?

@akxcv
Copy link

akxcv commented Apr 20, 2017

The issue is also described well in #2939 by @JohnLouderback.
At our company, we have the following lookup process:

import './myFile'
// => apps/[currentProjectName]/assets/javascripts/myFile
// => apps/common/assets/javascripts/myFile (if the former file does not exist)

This is currently accomplished by a custom Babel plugin.

AFAIK, this isn't currently possible to do with Flow. What would be the best way to accomplish such behavior? I don't think we can allow babel to process files before Flow because then we'd need source maps and it would really complicate things overall. But clearly, we need to do some kind of processing that includes checking if a file exists (accounting for many possible extensions).

I'm willing to submit a PR, but first, we need to decide what we want to do (if anything).

@jakesylvestre
Copy link

jakesylvestre commented Oct 18, 2018

Looks like this got resolved in #6132/ 08b0c8f

@apsavin
Copy link
Contributor

apsavin commented Sep 17, 2019

@goodmind should it be closed?

@goodmind
Copy link
Contributor

I don't think it should, Flow team planned to remove custom loaders

@nicolo-ribaudo
Copy link
Contributor

This is needed to be able to still use Flow with Yarn 2.

@jakesylvestre
Copy link

@goodmind where's that thread?

@alexandrukis
Copy link

Is there any (at this point I would accept any ugly, hack-ish solution) way of achieving this using the latest version of Flow?

@SamChou19815
Copy link
Contributor

I don't think we are likely to allow this in the future. Module resolution gets more complicated than a simple function call, when you also need to worry about updating the dependency graph incrementally.

@SamChou19815 SamChou19815 closed this as not planned Won't fix, can't repro, duplicate, stale Jan 20, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

9 participants