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

@tinkoff/babel-plugin-lodash

v0.1.0

Published

Transform lodash imports to include into bundle only imported functions

Downloads

1,201

Readme

@tinkoff/babel-plugin-lodash

This plugin transforms lodash imports to include into bundle only imported functions.

Installation

npm install --save-dev @tinkoff/babel-plugin-lodash
yarn add --dev @tinkoff/babel-plugin-lodash

Example

In

import _ from "lodash";
import { add } from "lodash/fp";
import { slice } from "lodash-es";

const addOne = add(1);
_.map([1, 2, 3], addOne);
slice([1, 2, 3], 2);

Out

import _add from "lodash/fp/add";
import _map from "lodash/map";
import _slice from "lodash-es/slice";

const addOne = _add(1);
_map([1, 2, 3], addOne);
_slice([1, 2, 3], 2);

Usage

With a configuration file (Recommended)

.babelrc

{
  "plugins": ["@tinkoff/babel-plugin-lodash"]
}

Via CLI

$ babel --plugins @tinkoff/babel-plugin-lodash script.js

Via Node.js API

require("@babel/core").transformSync(code, {
  plugins: ["@tinkoff/babel-plugin-lodash"],
});

Options

ensureModuleExists

boolean, defaults to false.

When this option is enabled, plugin tries to resolve path to imported lodash module using require.resolve(). If the module can not be found, an error is thrown. Usually such check is done out of box by bundler (e.g. webpack) or typescript. Enabling this option may lead to decreasing performance.

In

import _ from "lodash";

_.slice([1, 2], 1);
_.unknownFunc();

Out

import _slice from "lodash/slice"; // OK
import _unknownFunc from "lodash/unknownFunc"; // ERROR

_slice([1, 2], 1);
_unknownFunc();

Limitations

  • Supported lodash packages: lodash, lodash/fp, lodash-es
  • You must use ES6 imports to load Lodash
  • Babel < 7 & Node.js < 16 aren’t supported
  • Chain sequences aren’t supported. See this blog post for alternatives.
  • Modularized method packages aren’t supported