Coder Social home page Coder Social logo

rollup-plugin-optimize-lodash-imports's Introduction

Optimize lodash imports

GitHub Workflow Status Codecov

There are multiple issues surrounding tree-shaking of lodash. Minifiers, even with dead-code elimination, cannot currently solve this problem.

Plugins can reduce final bundle sizes with minimal or no manual code changes. See the example showing a 70% reduced bundle size for an example input.

Packages:

npm node-current npm peer dependency version

A fast, lightweight plugin for Rollup bundling.

npm node-current npm peer dependency version

A expertimental plugin for esbuild bundling. (Experimental = esbuild is rapidly changing and unlike the Rollup plugin, this has not been used in a production code base.)

npm

Code transforms for lodash imports. Used by bundler plugins for a consistent, well-tested, shared set of transforms.

rollup-plugin-optimize-lodash-imports's People

Contributors

antixrist avatar github-actions[bot] avatar ilyasemenov avatar kyle-johnson avatar renovate[bot] avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

rollup-plugin-optimize-lodash-imports's Issues

Dependency Dashboard

This issue lists Renovate updates and detected dependencies. Read the Dependency Dashboard docs to learn more.

Rate-Limited

These updates are currently rate-limited. Click on a checkbox below to force their creation now.

  • chore(deps): update dependency @rollup/plugin-commonjs to v25.0.7
  • chore(deps): update dependency @rollup/plugin-node-resolve to v15.2.3
  • chore(deps): update dependency @rollup/plugin-terser to v0.4.4
  • chore(deps): update dependency @types/estree to v1.0.5
  • chore(deps): update dependency @types/lodash to v4.14.202
  • chore(deps): update dependency depcheck to v1.4.7
  • chore(deps): update dependency esbuild to v0.15.18
  • chore(deps): update eslint packages to v6.7.5 (patch) (@typescript-eslint/eslint-plugin, @typescript-eslint/parser)
  • chore(deps): update jest packages (patch) (@types/jest, eslint-plugin-jest, ts-jest)
  • chore(deps): update dependency @changesets/changelog-github to v0.5.0
  • chore(deps): update dependency @changesets/cli to v2.27.1
  • chore(deps): update dependency @types/lodash to v4.17.1
  • chore(deps): update dependency eslint-plugin-jest to v27.9.0
  • chore(deps): update dependency prettier to v3.2.5
  • chore(deps): update dependency typescript to v5.4.5
  • chore(deps): update eslint packages (minor) (@typescript-eslint/eslint-plugin, @typescript-eslint/parser, eslint, eslint-config-prettier)
  • fix(deps): update dependency @rollup/pluginutils to ~5.1.0
  • chore(deps): update actions/cache action to v4
  • chore(deps): update actions/setup-node action to v4
  • chore(deps): update codecov/codecov-action action to v4
  • chore(deps): update dependency eslint-plugin-jest to v28
  • ๐Ÿ” Create all rate-limited PRs at once ๐Ÿ”

Pending Status Checks

These updates await pending status checks. To force their creation now, click the checkbox below.

  • chore(deps): update github/codeql-action action to v3

Open

These updates have all been created already. Click a checkbox below to force a retry/rebase of any.

Detected dependencies

github-actions
.github/workflows/codeql-analysis.yml
  • actions/checkout v4
  • github/codeql-action v2
  • github/codeql-action v2
  • github/codeql-action v2
.github/workflows/main.yml
  • actions/checkout v4
  • actions/setup-node v3
  • actions/cache v3
  • actions/checkout v4
  • actions/setup-node v3
  • actions/cache v3
  • codecov/codecov-action v3
  • actions/checkout v4
  • actions/setup-node v3
  • changesets/action v1
npm
package.json
  • @changesets/changelog-github 0.4.8
  • @changesets/cli 2.26.2
packages/esbuild-plugin/package.json
  • acorn 8.x
  • @tsconfig/node12 1.0.11
  • @types/estree 1.0.1
  • @types/jest 29.5.4
  • @types/lodash 4.14.199
  • @types/node 10.17.60
  • @typescript-eslint/eslint-plugin 6.7.0
  • @typescript-eslint/parser 6.7.0
  • depcheck 1.4.6
  • esbuild 0.15.16
  • eslint 8.51.0
  • eslint-config-prettier 9.0.0
  • eslint-plugin-jest 27.4.0
  • eslint-plugin-unicorn 44.0.2
  • jest 29.7.0
  • lodash 4.17.21
  • prettier 3.0.3
  • ts-jest 29.1.1
  • typescript 5.2.2
  • esbuild >= 0.8.0
  • node >= 12
packages/rollup-plugin/package.json
  • @rollup/pluginutils ~5.0.2
  • @rollup/plugin-commonjs 25.0.5
  • @rollup/plugin-node-resolve 15.2.1
  • @rollup/plugin-terser 0.4.3
  • @tsconfig/node12 1.0.11
  • @types/estree 1.0.1
  • @types/jest 29.5.4
  • @types/lodash 4.14.199
  • @types/node 12.20.55
  • @typescript-eslint/eslint-plugin 6.7.0
  • @typescript-eslint/parser 6.7.0
  • depcheck 1.4.6
  • eslint 8.51.0
  • eslint-config-prettier 9.0.0
  • eslint-plugin-jest 27.4.0
  • eslint-plugin-unicorn 44.0.2
  • gen-esm-wrapper 1.1.3
  • jest 29.7.0
  • lodash 4.17.21
  • prettier 3.0.3
  • rollup 3.29.4
  • ts-jest 29.1.1
  • typescript 5.2.2
  • rollup >=2.x
  • node >= 12
packages/transform/package.json
  • estree-walker 2.x
  • magic-string 0.30.x
  • @tsconfig/node12 1.0.11
  • @types/estree 1.0.1
  • @types/jest 29.5.4
  • @types/lodash 4.14.199
  • @types/node 12.20.55
  • @typescript-eslint/eslint-plugin 6.7.0
  • @typescript-eslint/parser 6.7.0
  • acorn 8.8.2
  • depcheck 1.4.6
  • eslint 8.51.0
  • eslint-config-prettier 9.0.0
  • eslint-plugin-jest 27.4.0
  • eslint-plugin-unicorn 44.0.2
  • jest 29.7.0
  • prettier 3.0.3
  • ts-jest 29.1.1
  • typescript 5.2.2
  • node >= 12

  • Check this box to trigger a request for Renovate to run again on this repository

Does this also optimise single function packages?

Lots of packages opt for single function lodash packages e.g. lodash.isempty, lodash.clonedeep etc.
Does this package also optimise these to ensure we dedupe to always use the same lodash function across all dependencies?

Question: should this work with Vite 3?

Hi there,

I have Vite 3 + React project that uses lodash-es and every import from the library follows the format import isEmpty from 'lodash/isEmpty';.

The thing is, many other used dependencies bring in lodash and I cringe when analyzing the production bundle with duplicated lodash functionality.

My hopes for this library were:

  1. Just work with Vite 3
  2. Reduce the production bundle size by optimizing all lodash imports.

Maybe my expectations are wrong? ๐Ÿคท Or maybe I'm overlooking some Vite 3 config detail? Well, any tips or clarifications are welcome.

This is my Vite config:

import react from '@vitejs/plugin-react';
import { defineConfig } from 'vite';
import { visualizer } from "rollup-plugin-visualizer";
import { optimizeLodashImports } from "@optimize-lodash/rollup-plugin";

export default defineConfig({
  build: {
    rollupOptions: {
      plugins: [
        optimizeLodashImports({ useLodashEs: true }),
        visualizer({
          template: process.env.VIEW_BUNDLE,
          open: true,
          gzipSize: true,
        })
      ],
    }
  },

  plugins: [
    react(),
  ],
})

Cheers!

Problem with [email protected] and [email protected]

After updating vite from 4.0.4 to 4.1.0 I'm getting the following error:

Cannot read properties of undefined (reading 'thisArg') error during build:
TypeError: Cannot read properties of undefined (reading 'thisArg')
    at CallExpression.applyDeoptimizations (file:///Users/.../node_modules/vite/node_modules/rollup/dist/es/shared/node-entry.js:9525:30)

Looks like problem stars happening when updating rollup from 3.8 to ^3.10.

Dependency Dashboard

This issue contains a list of Renovate updates and their statuses.

Rate Limited

These updates are currently rate limited. Click on a checkbox below to force their creation now.

  • chore(deps): update dependency @rollup/plugin-node-resolve to v11.2.0
  • chore(deps): update dependency eslint to v7.20.0

Open

These updates have all been created already. Click a checkbox below to force a retry/rebase of any.

[esbuild] could not interpret ts syntax

There was a problem with using esbuild plugins in ts package among those modules. esbuild was an issue that could not interpret ts syntax,

I would like to write the loader value among the return values of onLoad in consideration of ts.

  build.onLoad({ filter: /.(js|ts|jsx|tsx)$/ }, (args) => {
   ...
            return {
              ...
              loader: 'ts' // or path.parse(args.path).ext.slice(1),
             }
   })

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.