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

[request] webpack #165

Closed
anonymni opened this issue Jul 5, 2016 · 13 comments
Closed

[request] webpack #165

anonymni opened this issue Jul 5, 2016 · 13 comments
Labels
libdef Related to a library definition request

Comments

@anonymni
Copy link

anonymni commented Jul 5, 2016

webpack is one of the most widely used Javascript library. It would be great to have Flow definitions for it.

@oliviertassinari
Copy link
Contributor

oliviertassinari commented Sep 9, 2016

I'm using the following declaration if that can help:

declare var module : {
  hot : {
    accept(path:string, callback:() => void): void;
  };
};

declare var require: any;

@jamiebuilds
Copy link
Contributor

Are there Webpack API docs somewhere? I thought you only have a JSON-like config file and the CLI. Didn't know there was a JS api...

@oliviertassinari
Copy link
Contributor

oliviertassinari commented Sep 12, 2016

There is only three js API I'm aware of:

  • the hot reloading
  • the lasy loading
  • the context loading

I'm not sure where the best docs is.

@relekang
Copy link
Contributor

I think it is covered in api-in-modules

@ccorcos
Copy link

ccorcos commented Nov 29, 2016

@jamiebuilds
Copy link
Contributor

cc @TheLarkInn

@TheLarkInn
Copy link

If I provided a PR which contains a TS equivalent would this be of assistance? webpack/webpack#3094

@jamiebuilds
Copy link
Contributor

That would be awesome :)

@ccorcos
Copy link

ccorcos commented Nov 30, 2016

@TheLarkInn TS is very close to Flow now-a-days. It shouldn't be too hard to convert.

@TheLarkInn
Copy link

The PR above should be enough to assist I hope. Lmk if you have any other questions

@sibelius
Copy link
Contributor

declare for react-native

declare var module: {
  hot: {
    accept(callback: () => void): void,
  },
};

@langpavel
Copy link

langpavel commented Apr 2, 2018

I'm using this: EDIT

declare type ModuleHotStatus =
  | 'idle' // The process is waiting for a call to check (see below)
  | 'check' // The process is checking for updates
  | 'prepare' // The process is getting ready for the update (e.g. downloading the updated module)
  | 'ready' // The update is prepared and available
  | 'dispose' // The process is calling the dispose handlers on the modules that will be replaced
  | 'apply' // The process is calling the accept handlers and re-executing self-accepted modules
  | 'abort' // An update was aborted, but the system is still in it's previous state
  | 'fail' // An update has thrown an exception and the system's state has been compromised
  ;

declare type ModuleHotStatusHandler = (status: ModuleHotStatus) => any

declare interface ModuleHot {
  data: any;
  accept(paths?: string | Array<string>, callback?: () => any): void;
  decline(paths?: string | Array<string>): void;
  dispose(callback: (data?: mixed) => any): void;
  addDisposeHandler(callback: (data: mixed) => any): void;
  status(): ModuleHotStatus;
  check(autoApply: boolean | Object): Promise<string[]>; // TODO
  apply(options: Object): Promise<string[]>; // TODO
  addStatusHandler(callback: ModuleHotStatusHandler): void;
  removeStatusHandler(callback: ModuleHotStatusHandler): void;
};

declare var module: {
  hot?: ModuleHot,
};

@AndrewSouthpaw
Copy link
Contributor

Any of y'all are welcome to submit a PR. Looks like this most recent def is a good starting point. :)

gantoine pushed a commit that referenced this issue Nov 5, 2018
Heavily inspired from the TypeScript declarations

    Anyone is welcome to contribute and/or write tests in order to
    answer to #165
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
libdef Related to a library definition request
Projects
None yet
Development

No branches or pull requests