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

rollup-plugin-flow-entry

v0.3.6

Published

Allows Flow to find the original typed source code for the Rollup bundle

Downloads

3,133

Readme

rollup-plugin-flow-entry

JavaScript Style Guide Build Status

If you are writing a library using the Flow type system, you might want to make your library's types available to your end users. One way to do this is to place a file with a .js.flow extension alongside your bundled source code. Flow knows to look inside files like this for type information.

This Rollup plugin will create one of these .js.flow files alongside each of your output files. The .js.flow file will simply export * from your un-bundled input file, allowing Flow to find your original type information.

Usage

Here is an example rollup.config.js file using this plugin:

import flowEntry from 'rollup-plugin-flow-entry'

export default {
  input: 'src/index.js',
  output: { file: 'lib/index.js', format: 'cjs' },
  plugins: [
    flowEntry()
    // You will also need rollup-plugin-babel or rollup-plugin-flow
    // in here to strip your type annotations...
  ]
}

This will produce a file called lib/index.js.flow alongside the normal lib/index.js output file. The output file will look like this:

// @flow

export * from '../src/index.js'

Flow Strict

If you want to enable stricter type checking, pass a mode into configuration options:

export default {
  input: 'src/index.js',
  output: { file: 'lib/index.js', format: 'cjs' },
  plugins: [
    flowEntry({ mode: 'strict-local' })
    // Other plugins...
  ]
}

Multiple Entry Points

If you use Rollup's built-in code splitting feature, this plugin will create one Flow entry point for each entry chunk.

This plugin can also detect when @rollup/plugin-multi-entry is being used, and will create a single combined Flow entry point when appropriate.

Customizing Source Locations

By default rollup-plugin-flow-entry will link each output file back to its original source file (if one exists). If you want to change this behavior, though, you can pass a types option to the plugin, which will replace the original source location.

This is useful if your library is written in TypeScript, for example, but you would still like to ship Flow types. Just put your Flow type definitions somewhere in your source directory, and then use the types option to link back to the Flow types instead of your original TypeScript source code:

export default {
  input: 'src/index.ts',
  output: { file: 'lib/index.js', format: 'cjs' },
  plugins: [
    flowEntry({ types: 'src/flow-types.js', })
    // Other plugins for TypeScript support...
  ]
}

If you have multiple entry points, you can pass an object for types to customize each output file individually:

flowEntry({
  types: {
    'index.js': 'src/flow-types.js',
    'skip.js': false
  }
})

The output filename goes on the left, and the source filename goes on the right. Passing false will skip that output file entirely.