-
Notifications
You must be signed in to change notification settings - Fork 6
feat: optimize lodash for esm/mjs + add bundleDeps option #97
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,40 @@ | ||
| import type { Plugin } from "rollup"; | ||
| import { FilterPattern } from "@rollup/pluginutils"; | ||
| export declare type OptimizeLodashOptions = { | ||
| /** | ||
| * A minimatch pattern, or array of patterns, of files that should be | ||
| * processed by this plugin (if omitted, all files are included by default) | ||
| */ | ||
| include?: FilterPattern; | ||
| /** | ||
| * Files that should be excluded, if `include` is otherwise too permissive. | ||
| */ | ||
| exclude?: FilterPattern; | ||
| /** | ||
| * Changes *all* lodash imports (but not lodash/fp imports!) to 'lodash-es' imports. | ||
| * Don't use this for CommonJS outputs, the plugin will error should you do so. | ||
| */ | ||
| useLodashEs?: true; | ||
| }; | ||
| /** | ||
| * Converts lodash imports to be specific, enabling better tree-shaking: | ||
| * | ||
| * `import { isNil } from "lodash";` -> `import { isNil } from "lodash/isNil";` | ||
| * | ||
| * Note that only specific named imports are supported, unlike babel-plugin-lodash. For example, | ||
| * this plugin will print a warning for this import and make no changes to the import: | ||
| * | ||
| * `import _ from "lodash";` | ||
| * | ||
| * Optionally, set `useLodashEs` to true and `lodash` imports will be converted to `lodash-es` | ||
| * imports. Note that it's up to user to include the `lodash-es` module and ensure the output | ||
| * is set to some form of `es` (other output formats will error). An example: | ||
| * | ||
| * `import { isNil } from "lodash";` -> `import { isNil } from "lodash-es";` | ||
| * | ||
| * @param include files/globs to include with this plugin (optional) | ||
| * @param exclude files/globs to exclude from this plugin (optional) | ||
| * @param useLodashEs set `true` to convert imports to use "lodash-es" (optional; default false) | ||
| */ | ||
| export declare function optimizeLodashImports({ include, exclude, useLodashEs, }?: OptimizeLodashOptions): Plugin & Required<Pick<Plugin, "transform">>; | ||
| //# sourceMappingURL=index.d.ts.map |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,79 @@ | ||
| { | ||
| "name": "@optimize-lodash/rollup-plugin", | ||
| "version": "2.1.0", | ||
| "description": "Rewrite lodash imports with Rollup for improved tree-shaking.", | ||
| "keywords": [ | ||
| "lodash", | ||
| "rollup", | ||
| "rollup-plugin", | ||
| "optimize", | ||
| "minify" | ||
| ], | ||
| "homepage": "https://github.com/kyle-johnson/rollup-plugin-optimize-lodash-imports/tree/main/packages/rollup-plugin", | ||
| "repository": { | ||
| "type": "git", | ||
| "url": "https://github.com/kyle-johnson/rollup-plugin-optimize-lodash-imports.git" | ||
| }, | ||
| "main": "dist/index.js", | ||
| "types": "dist/index.d.ts", | ||
| "files": [ | ||
| "dist" | ||
| ], | ||
| "author": "Kyle Johnson", | ||
| "license": "MIT", | ||
| "engines": { | ||
| "node": ">= 12" | ||
| }, | ||
| "publishConfig": { | ||
| "access": "public" | ||
| }, | ||
| "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" | ||
| }, | ||
| "jest": { | ||
| "coverageDirectory": "coverage", | ||
| "testEnvironment": "node", | ||
| "preset": "ts-jest", | ||
| "globals": { | ||
| "ts-jest": {} | ||
| }, | ||
| "testTimeout": 10000 | ||
| }, | ||
| "peerDependencies": { | ||
| "rollup": "2.x" | ||
| }, | ||
| "devDependencies": { | ||
| "@rollup/plugin-commonjs": "21.0.1", | ||
| "@rollup/plugin-node-resolve": "13.0.6", | ||
| "@tsconfig/node12": "1.0.9", | ||
| "@types/estree": "0.0.50", | ||
| "@types/jest": "27.0.3", | ||
| "@types/lodash": "4.14.177", | ||
| "@types/node": "12.20.37", | ||
| "@typescript-eslint/eslint-plugin": "5.4.0", | ||
| "@typescript-eslint/parser": "5.4.0", | ||
| "depcheck": "1.4.2", | ||
| "eslint": "8.2.0", | ||
| "eslint-config-prettier": "8.3.0", | ||
| "eslint-plugin-jest": "25.2.4", | ||
| "eslint-plugin-unicorn": "38.0.1", | ||
| "jest": "27.3.1", | ||
| "lodash": "4.17.21", | ||
| "prettier": "2.4.1", | ||
| "rollup": "2.59.0", | ||
| "rollup-plugin-terser": "7.0.2", | ||
| "ts-jest": "27.0.7", | ||
| "typescript": "4.3.5" | ||
| }, | ||
| "dependencies": { | ||
| "@optimize-lodash/transform": "workspace:2.x", | ||
| "@rollup/pluginutils": "4.x" | ||
| } | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,5 @@ | ||
| import type { BaseNode, ImportDeclaration, ImportSpecifier, Program } from "estree"; | ||
| export declare function isImportDeclaration(node: BaseNode): node is ImportDeclaration; | ||
| export declare function isProgram(node: BaseNode): node is Program; | ||
| export declare function isImportSpecifierArray(items: ImportDeclaration["specifiers"]): items is Array<ImportSpecifier>; | ||
| //# sourceMappingURL=guards.d.ts.map |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,24 @@ | ||
| import type { Node } from "acorn"; | ||
| import { SourceMap } from "magic-string"; | ||
| declare module "estree" { | ||
| interface BaseNodeWithoutComments { | ||
| start: number; | ||
| end: number; | ||
| } | ||
| } | ||
| export declare type UNCHANGED = null; | ||
| export declare const UNCHANGED: null; | ||
| export interface CodeWithSourcemap { | ||
| code: string; | ||
| map: SourceMap; | ||
| } | ||
| export declare type ParseFunction = (code: string) => Node; | ||
| export declare type WarnFunction = (message: string) => void; | ||
| export declare function transform({ code, id, parse, warn, useLodashEs, }: { | ||
| code: string; | ||
| id: string; | ||
| parse: ParseFunction; | ||
| warn?: WarnFunction; | ||
| useLodashEs?: true; | ||
| }): CodeWithSourcemap | UNCHANGED; | ||
| //# sourceMappingURL=index.d.ts.map |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Uh oh!
There was an error while loading. Please reload this page.