{"_id":"@1-week/esbuild-plugin-ramda","name":"@1-week/esbuild-plugin-ramda","dist-tags":{"latest":"1.0.0"},"versions":{"1.0.0":{"name":"@1-week/esbuild-plugin-ramda","version":"1.0.0","description":"Rewrite Ramda imports with esbuild for improved tree-shaking.","keywords":["ramda","esbuild","esbuild-plugin","optimize","minify"],"homepage":"https://github.com/kyle-johnson/rollup-plugin-optimize-lodash-imports/tree/main/packages/esbuild-plugin","repository":{"type":"git","url":"git+https://github.com/kyle-johnson/rollup-plugin-optimize-lodash-imports.git"},"main":"dist/index.js","types":"dist/index.d.ts","author":{"name":"Kyle Johnson"},"license":"MIT","engines":{"node":">= 16"},"publishConfig":{"access":"public"},"jest":{"coverageDirectory":"coverage","testEnvironment":"node","preset":"ts-jest","testTimeout":10000},"peerDependencies":{"esbuild":">= 0.8.47","acorn-typescript":"^1.4.13"},"devDependencies":{"@tsconfig/node16":"16.1.3","@types/estree":"1.0.1","@types/jest":"29.5.4","@types/ramda":"^0.30.1","@types/node":"16.11.68","@typescript-eslint/eslint-plugin":"7.18.0","@typescript-eslint/parser":"7.18.0","acorn-typescript":"1.4.13","depcheck":"1.4.7","esbuild":"0.23.0","eslint":"8.57.0","eslint-config-prettier":"9.1.0","eslint-plugin-jest":"28.6.0","eslint-plugin-unicorn":"55.0.0","jest":"29.7.0","ramda":"^0.30.1","prettier":"3.3.3","ts-jest":"29.1.1","typescript":"5.5.4"},"dependencies":{"acorn":"~8.12.1","@1-week/ramda-transform":"1.0.0"},"scripts":{"type-check":"tsc --noEmit","lint":"eslint .","test":"jest","test:ci":"jest --coverage --ci","build":"rm -rf dist && tsc -p tsconfig.dist.json","format":"prettier --write .","format:check":"prettier --check .","depcheck":"depcheck"},"_id":"@1-week/esbuild-plugin-ramda@1.0.0","bugs":{"url":"https://github.com/kyle-johnson/rollup-plugin-optimize-lodash-imports/issues"},"_integrity":"sha512-w124yr5SMeIMfEbNZuLO+HX30S1rFwumyuOTrPZ8xWmNtEBljLhn9xjHNagrbLTflHPALS8541kFbtwokuUEVQ==","_resolved":"/private/var/folders/_w/lzw0dlfx3t9czlbj3k8f1kyh0000gn/T/deac771b2c9ecb82915f4af10ddf7ef8/1-week-esbuild-plugin-ramda-1.0.0.tgz","_from":"file:1-week-esbuild-plugin-ramda-1.0.0.tgz","_nodeVersion":"20.16.0","_npmVersion":"10.8.1","dist":{"integrity":"sha512-w124yr5SMeIMfEbNZuLO+HX30S1rFwumyuOTrPZ8xWmNtEBljLhn9xjHNagrbLTflHPALS8541kFbtwokuUEVQ==","shasum":"bc3aaf88c42e2f81c14f2e187bccf89ef8c4f074","tarball":"https://registry.npmjs.org/@1-week/esbuild-plugin-ramda/-/esbuild-plugin-ramda-1.0.0.tgz","fileCount":7,"unpackedSize":15058,"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIDKQPilVSCg7TlJLHydWhxI6ACeHTD9Yoxr7k0dKygsvAiEA7hCElyzRr2/Uf+uFvpJxVQBTOsw47kt5NW5o1jiLv3E="}]},"_npmUser":{"name":"1-week","email":"bayeszou@gmail.com"},"directories":{},"maintainers":[{"name":"1-week","email":"bayeszou@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/esbuild-plugin-ramda_1.0.0_1726129257162_0.9324698221961989"},"_hasShrinkwrap":false}},"time":{"created":"2024-09-12T08:20:57.044Z","1.0.0":"2024-09-12T08:20:57.325Z","modified":"2024-09-12T08:20:57.608Z"},"maintainers":[{"name":"1-week","email":"bayeszou@gmail.com"}],"description":"Rewrite Ramda imports with esbuild for improved tree-shaking.","homepage":"https://github.com/kyle-johnson/rollup-plugin-optimize-lodash-imports/tree/main/packages/esbuild-plugin","keywords":["ramda","esbuild","esbuild-plugin","optimize","minify"],"repository":{"type":"git","url":"git+https://github.com/kyle-johnson/rollup-plugin-optimize-lodash-imports.git"},"author":{"name":"Kyle Johnson"},"bugs":{"url":"https://github.com/kyle-johnson/rollup-plugin-optimize-lodash-imports/issues"},"license":"MIT","readme":"# Optimize `lodash` imports with esbuild\n\n[![npm](https://img.shields.io/npm/v/@1-week/rollup-plugin-esbuild)](https://www.npmjs.com/package/@1-week/rollup-plugin-esbuild)\n![node-current](https://img.shields.io/node/v/@1-week/rollup-plugin-esbuild)\n![npm peer dependency version](https://img.shields.io/npm/dependency-version/@1-week/rollup-plugin-esbuild/peer/esbuild)\n[![GitHub Workflow Status](https://img.shields.io/github/actions/workflow/status/kyle-johnson/rollup-plugin-optimize-lodash-imports/main.yml?branch=main)](https://github.com/kyle-johnson/rollup-plugin-optimize-lodash-imports/actions)\n[![license](https://img.shields.io/npm/l/@1-week/rollup-plugin-esbuild)](https://github.com/kyle-johnson/rollup-plugin-optimize-lodash-imports/blob/main/packages/esbuild-plugin/LICENSE)\n[![Codecov](https://img.shields.io/codecov/c/github/kyle-johnson/rollup-plugin-optimize-lodash-imports?flag=esbuild-plugin&label=coverage)](https://app.codecov.io/gh/kyle-johnson/rollup-plugin-optimize-lodash-imports/)\n![GitHub last commit](https://img.shields.io/github/last-commit/kyle-johnson/rollup-plugin-optimize-lodash-imports)\n\n_**This is a proof of concept! esbuild loader plugins are \"greedy\" and need additional code to enable chaining. If you want something that's proven in production, consider using [@1-week/rollup-plugin-ramda](https://www.npmjs.com/package/@1-week/rollup-plugin-ramda).**_\n\nThere are [multiple](https://github.com/webpack/webpack/issues/6925) [issues](https://github.com/lodash/lodash/issues/3839) [surrounding](https://github.com/rollup/rollup/issues/1403) [tree-shaking](https://github.com/rollup/rollup/issues/691) of lodash. Minifiers, even with dead-code elimination, cannot currently solve this problem. With this plugin, bundled code output will _only_ include the specific lodash methods your code requires.\n\nThere is also an option to use [lodash-es](https://www.npmjs.com/package/lodash-es) for projects which ship CommonJS and ES builds: the ES build will be transformed to import from `lodash-es`.\n\nVersions of this plugin _before_ 3.x did not support Typescript. 3.x and later support Typescript, although Typescript support is considered experimental.\n\n### This input\n\n```javascript\nimport { isNil, isString } from \"lodash\";\n```\n\n### Becomes this output\n\n```javascript\nimport isNil from \"lodash/isNil.js\";\nimport isString from \"lodash/isString.js\";\nimport padStartFp from \"lodash/fp/padStart.js\";\n```\n\n## `useLodashEs` for ES Module Output\n\nWhile `lodash-es` is not usable from CommonJS modules, some projects use Rollup to create two outputs: one for ES and one for CommonJS.\n\nIn this case, you can offer your users the best of both:\n\n### Your source input\n\n```javascript\nimport { isNil } from \"lodash\";\n```\n\n#### CommonJS output\n\n```javascript\nimport isNil from \"lodash/isNil.js\";\n```\n\n#### ES output (with `useLodashEs: true`)\n\n```javascript\nimport { isNil } from \"lodash-es\";\n```\n\n## Usage\n\n_Please see the [esbuild docs for the most up to date info on using plugins](https://esbuild.github.io/plugins/#using-plugins)._\n\n```javascript\nconst { lodashOptimizeImports } = require(\"@1-week/rollup-plugin-esbuild\");\n\nrequire(\"esbuild\").buildSync({\n  entryPoints: [\"app.js\"],\n  outfile: \"out.js\",\n  plugins: [lodashOptimizeImports()],\n});\n```\n\n## Options\n\n### `useLodashEs`\n\nType: `boolean`<br>\nDefault: `false`\n\nIf `true`, the plugin will rewrite _lodash_ imports to use _lodash-es_.\n\n**\\*NOTE:** be sure esbuild's `format: \"esm\"` option is set!\\*\n\n### `appendDotJs`\n\nType: `boolean`<br>\nDefault: `true`\n\nIf `true`, the plugin will append `.js` to the end of CommonJS lodash imports.\n\nSet to `false` if you don't want the `.js` suffix added (prior to v2.x, this was the default).\n\n## Limitations\n\n### Default imports are not optimized\n\nUnlike [babel-plugin-lodash](https://github.com/lodash/babel-plugin-lodash), there is no support for optimizing the lodash default import, such as in this case:\n\n```javascript\n// this import can't be optimized\nimport _ from \"lodash\";\n\nexport function testX(x) {\n  return _.isNil(x);\n}\n```\n\nThe above code will not be optimized, and Rollup will print a warning.\n\nTo avoid this, always import the specific method(s) you need:\n\n```javascript\n// this import will be optimized\nimport { isNil } from \"lodash\";\n\nexport function testX(x) {\n  return isNil(x);\n}\n```\n\n## Alternatives\n\nThere aren't a lot of esbuild plugins today.\n\nIf you wish to shift the responsibility off to developers, `eslint-plugin-lodash` with the [`import-scope` rule enabled](https://github.com/wix/eslint-plugin-lodash/blob/HEAD/docs/rules/import-scope.md) may help.\n\nUsing Rollup? Check out [`@1-week/rollup-plugin-ramda`](https://www.npmjs.com/package/@1-week/rollup-plugin-ramda).\n\nUsing Babel? Check out [`babel-plugin-lodash`](https://github.com/lodash/babel-plugin-lodash) (it fixes default imports too!).\n","readmeFilename":"README.md"}