npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

@xt-pagesource/flow-types-share

v1.0.0

Published

This modules enables you to share flow config between different private NPM modules.

Downloads

2

Readme

Flow-types-share

Purpose

Flow is a wonderful type checker and works great with-in a package/application. If you are publishing any flow-typed libraries, you will want Flow to make use of their exported types in the consuming applications. This doesn't work as intended with Flow because of following reasons.

If one keeps node_modules in the ignore list of flowconfig, then flow starts to throw unable to resolve module error. To overcome this one can define modules in the flow-typed folder; however, the libraries which export flow types also starts getting ignored, hence we cannot make use of the typings provided by the library owners.

The other way, which is a recommended way across community, is not to put node_modules in the ignore list at all. Everything works fine, but the downside is if you have a very large codebase with large dependencies flow starts parsing each and every node_modules which could take a lot of time especially if you are not on ssd drive. It took me 15 mins when I ran flow using this configuration on a medium codebase.

The solution of this problem could be to ignore node_modules except for the few libraries which are exporting flow typings. But since oCamel regex, the regex supported by flowconfig [ignore], does not provide a way to exclude specific folders (there is no ! character in them); the only solution is to list down all node_modules folder name in the [ignore] list excluding the names of the 3rd party which exports flow types.

This module just does that out of the box for you.

Uses

Follow below steps:

1. Add the package to dev dependencies

yarn add --dev @xt-pagesource/flow-types-share

2. In the package.json add below task under scripts

"flow:config": "flow-config-generate"

3. Create a .flowconfig.template file in the root folder

It should be mirroring the .flowconfig suggested by flow and add below content.

[include]

[ignore]
.*/lib1/.*
{{DYNAMIC_IGNORE}}

[exclusion]
lib2
lib3

Note: The current script makes use of [exclusion] and {{DYNAMIC_IGNORE}}

4. Run the task

npm run flow:config

A .flowconfig file will be generated, listing the names of all modules present in node_modules, excluding the name present in [exclusion] list, at the position marked by {{DYNAMIC_IGNORE}}

After this you will start seeing Flow typed errors

Note: Another way to solve this would be publishing your flow-typed definitions and thats quite a big effort, since there are no mature enough tools to auto generate it, just yet.

Usage: bin/flow-config-generate.js [-t|--template] [-p|--folderPath] [-o|--outputPath]

Options:
  -t, --template     path including name of .flowconfig.template file    defaults to .flowconfig.template at the root      [string]
  -p, --folderPath   path of folder from where searching happens         defaults to node_modules                          [string]
  -o, --outputPath   path including name of generated .flwconfig file    defaults to .flowconfig at root                   [string]