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

haste-map-webpack-resolver

v2.0.1

Published

A webpack resolver plugin using facebook's haste-map

Downloads

15

Readme

Build Status npm version

haste-map-webpack-resolver

A webpack resolver plugin using facebook's haste map.

In CommonJS all require() calls to internal modules are using relative paths.

This can be a pain in mono-repositories:

  • referencing a module requires some relative path computation (very often trial and error).
  • when moving files to different folders, most require() calls have to be updated.

Facebook's Haste map can be useful for that, each module is assigned a unique name using the @providesModule annotation and can be required() using its name.

Since Jest, Flow & React Native are already supporting it, having a webpack resolver is the last thing you need to use it on node.js and on web bundles.

Some resources on it :

  • https://facebook.github.io/react/contributing/codebase-overview.html#custom-module-system
  • https://github.com/facebook/flow/issues/2648
  • https://github.com/facebookarchive/node-haste
  • https://github.com/facebook/jest/tree/master/packages/jest-haste-map

This implementation is based on jest-haste-map, the haste map implementation used by Jest runner.

Usage in webpack 1

Add the following code to your webpack configuration file:

var HasteMapWebPackResolver = require('haste-map-webpack-resolver');
var hasteMapWebPackResolver = new HasteMapWebPackResolver({
    rootPath: path.resolve(__dirname, '.'),
});

    ....
    // Within the configuration object:
    plugins: [
        new ProgressBarPlugin(hasteMapWebPackResolver),
        new webpack.ResolverPlugin([hasteMapWebPackResolver.resolver]),
    ],

I've written a fully working webpack 1 demo

Beware this configuration is only valid for haste-map-webpack-resolver 2.x: in order to handle https://github.com/flegall/haste-map-webpack-resolver/issues/2 I had to break the configuration of 1.x. If you're still using 1.x, please READ the configuration from here : https://github.com/flegall/haste-map-webpack-resolver/blob/v1.0.8/README.md

Usage in webpack 2

Add the following code to your webpack configuration file:

var HasteMapWebPackResolver = require('haste-map-webpack-resolver');
var hasteMapWebPackResolver = new HasteMapWebPackResolver({
    rootPath: path.resolve(__dirname, '.'),
});

    ....
    // Within the configuration object:
    resolve: {
        plugins: [hasteMapWebPackResolver.resolver],
    },
    plugins: [
        hasteMapWebPackResolver,
    ],

I've written a fully working webpack 2 demo

Beware this configuration is only valid for haste-map-webpack-resolver 2.x: in order to handle https://github.com/flegall/haste-map-webpack-resolver/issues/2 I had to break the configuration of 1.x. If you're still using 1.x, please READ the configuration from here : https://github.com/flegall/haste-map-webpack-resolver/blob/v1.0.8/README.md