@optimize-lodash/rollup-plugin
Advanced tools
Comparing version 3.0.0 to 3.1.0
@@ -36,3 +36,3 @@ import type { Plugin } from "rollup"; | ||
* 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: | ||
* is set to some form of `es`/`esm`/`module` (other output formats will error). An example: | ||
* | ||
@@ -39,0 +39,0 @@ * `import { isNil } from "lodash";` -> `import { isNil } from "lodash-es";` |
@@ -7,2 +7,3 @@ "use strict"; | ||
const UNCHANGED = null; | ||
const ROLLUP_ESM_FORMATS = new Set(["es", "esm", "module"]); | ||
/** | ||
@@ -20,3 +21,3 @@ * Converts lodash imports to be specific, enabling better tree-shaking: | ||
* 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: | ||
* is set to some form of `es`/`esm`/`module` (other output formats will error). An example: | ||
* | ||
@@ -31,3 +32,3 @@ * `import { isNil } from "lodash";` -> `import { isNil } from "lodash-es";` | ||
function optimizeLodashImports({ include, exclude, useLodashEs, appendDotJs, } = {}) { | ||
const filter = pluginutils_1.createFilter(include, exclude); | ||
const filter = (0, pluginutils_1.createFilter)(include, exclude); | ||
return { | ||
@@ -37,4 +38,6 @@ name: "optimize-lodash-imports", | ||
var _a; | ||
if (useLodashEs && options.format !== "es") { | ||
this.error(`'useLodashEs' is true but the output format is not 'es', it's ${(_a = options.format) !== null && _a !== void 0 ? _a : "undefined"}`); | ||
if (useLodashEs && | ||
options.format && | ||
!ROLLUP_ESM_FORMATS.has(options.format)) { | ||
this.error(`'useLodashEs' is true but the output format is not 'es', 'esm' or 'module', it's ${(_a = options.format) !== null && _a !== void 0 ? _a : "undefined"}`); | ||
} | ||
@@ -50,3 +53,3 @@ return UNCHANGED; | ||
} | ||
return transform_1.transform({ | ||
return (0, transform_1.transform)({ | ||
code, | ||
@@ -53,0 +56,0 @@ id, |
{ | ||
"name": "@optimize-lodash/rollup-plugin", | ||
"version": "3.0.0", | ||
"version": "3.1.0", | ||
"description": "Rewrite lodash imports with Rollup for improved tree-shaking.", | ||
@@ -43,23 +43,23 @@ "keywords": [ | ||
"devDependencies": { | ||
"@rollup/plugin-commonjs": "21.0.1", | ||
"@rollup/plugin-node-resolve": "13.1.1", | ||
"@tsconfig/node12": "1.0.9", | ||
"@types/estree": "0.0.50", | ||
"@types/jest": "27.0.3", | ||
"@types/lodash": "4.14.178", | ||
"@types/node": "12.20.37", | ||
"@typescript-eslint/eslint-plugin": "5.7.0", | ||
"@typescript-eslint/parser": "5.7.0", | ||
"depcheck": "1.4.2", | ||
"eslint": "8.5.0", | ||
"eslint-config-prettier": "8.3.0", | ||
"eslint-plugin-jest": "25.3.0", | ||
"eslint-plugin-unicorn": "39.0.0", | ||
"jest": "27.4.5", | ||
"@rollup/plugin-commonjs": "22.0.2", | ||
"@rollup/plugin-node-resolve": "13.3.0", | ||
"@tsconfig/node12": "1.0.11", | ||
"@types/estree": "1.0.0", | ||
"@types/jest": "28.1.8", | ||
"@types/lodash": "4.14.186", | ||
"@types/node": "12.20.55", | ||
"@typescript-eslint/eslint-plugin": "5.38.0", | ||
"@typescript-eslint/parser": "5.38.0", | ||
"depcheck": "1.4.3", | ||
"eslint": "8.24.0", | ||
"eslint-config-prettier": "8.5.0", | ||
"eslint-plugin-jest": "27.0.4", | ||
"eslint-plugin-unicorn": "43.0.2", | ||
"jest": "28.1.3", | ||
"lodash": "4.17.21", | ||
"prettier": "2.5.1", | ||
"rollup": "2.61.1", | ||
"prettier": "2.7.1", | ||
"rollup": "2.77.3", | ||
"rollup-plugin-terser": "7.0.2", | ||
"ts-jest": "27.1.2", | ||
"typescript": "4.3.5" | ||
"ts-jest": "28.0.8", | ||
"typescript": "4.8.3" | ||
}, | ||
@@ -66,0 +66,0 @@ "dependencies": { |
@@ -95,3 +95,3 @@ # Optimize `lodash` imports with Rollup.js | ||
_Note: the build will fail if your Rollup output format is not also set to `es`!_ | ||
_Note: the build will fail if your Rollup output format is not also set to `es`, `esm`, or `module`!_ | ||
@@ -98,0 +98,0 @@ ### `appendDotJs` |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
15120
105