Skip to content

Commit

Permalink
feat: rollup 4.x officially supported (#435)
Browse files Browse the repository at this point in the history
  • Loading branch information
kyle-johnson authored Jul 31, 2024
1 parent afa4382 commit af5f97d
Show file tree
Hide file tree
Showing 12 changed files with 705 additions and 150 deletions.
5 changes: 5 additions & 0 deletions .changeset/happy-dolls-pay.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@optimize-lodash/rollup-plugin": major
---

NodeJS 18+ required. Rollup 4.x+ required. Previous versions probably worked with Rollup 4.x, but this makes it official and frees us from assumptions of past versions.
5 changes: 5 additions & 0 deletions .changeset/quiet-mice-type.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@optimize-lodash/transform": patch
---

Be slightly more specific about dependency versions to avoid potential deep type-check issues.
2 changes: 1 addition & 1 deletion packages/rollup-plugin/.depcheckrc
Original file line number Diff line number Diff line change
@@ -1 +1 @@
ignores: ["@types/*", "@tsconfig/*", "depcheck"]
ignores: ["@types/*", "@tsconfig/*", "depcheck", "ts-node"]
1 change: 1 addition & 0 deletions packages/rollup-plugin/.eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,5 +19,6 @@ module.exports = {
"unicorn/no-null": "off",
"unicorn/prefer-module": "off",
"unicorn/expiring-todo-comments": "off",
"unicorn/no-negated-condition": "off",
},
};
2 changes: 2 additions & 0 deletions packages/rollup-plugin/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ There are [multiple](https://github.com/webpack/webpack/issues/6925) [issues](ht

There 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`.

Note: versions of this plugin prior to 5.x supported NodeJS 12 and Rollup 2.x - 3.x. If you need support for these older versions, please use the 4.x release. [Rollup 4.x contains significant performance improvements](https://github.com/rollup/rollup/releases/tag/v4.0.0) over previous versions and is highly recommended.

### This input

```javascript
Expand Down
11 changes: 11 additions & 0 deletions packages/rollup-plugin/jest.config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
import { Config } from "jest";

const config: Config = {
coverageDirectory: "coverage",
testEnvironment: "node",
preset: "ts-jest",
testTimeout: 10_000,
prettierPath: require.resolve("prettier-2"),
};

export default config;
44 changes: 20 additions & 24 deletions packages/rollup-plugin/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
"author": "Kyle Johnson",
"license": "MIT",
"engines": {
"node": ">= 12"
"node": ">= 18"
},
"publishConfig": {
"access": "public"
Expand All @@ -42,41 +42,37 @@
"format:check": "prettier --check .",
"depcheck": "depcheck"
},
"jest": {
"coverageDirectory": "coverage",
"testEnvironment": "node",
"preset": "ts-jest",
"testTimeout": 10000
},
"peerDependencies": {
"rollup": ">=2.x"
"rollup": ">= 4.x"
},
"devDependencies": {
"@rollup/plugin-commonjs": "25.0.5",
"@rollup/plugin-node-resolve": "15.2.1",
"@rollup/plugin-terser": "0.4.3",
"@tsconfig/node12": "1.0.11",
"@rollup/plugin-commonjs": "26.0.1",
"@rollup/plugin-node-resolve": "15.2.3",
"@rollup/plugin-terser": "0.4.4",
"@tsconfig/node18": "18.2.4",
"@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",
"@types/node": "18.15.3",
"@typescript-eslint/eslint-plugin": "7.18.0",
"@typescript-eslint/parser": "7.18.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",
"eslint": "8.57.0",
"eslint-config-prettier": "9.1.0",
"eslint-plugin-jest": "28.6.0",
"eslint-plugin-unicorn": "55.0.0",
"gen-esm-wrapper": "1.1.3",
"jest": "29.7.0",
"lodash": "4.17.21",
"prettier": "3.0.3",
"rollup": "3.29.4",
"prettier": "3.3.3",
"prettier-2": "npm:[email protected]",
"rollup": "4.19.1",
"ts-jest": "29.1.1",
"typescript": "5.2.2"
"ts-node": "10.9.2",
"typescript": "5.5.4"
},
"dependencies": {
"@optimize-lodash/transform": "workspace:3.0.3",
"@rollup/pluginutils": "~5.0.2"
"@rollup/pluginutils": "^5.1.0",
"@optimize-lodash/transform": "workspace:3.0.3"
}
}
2 changes: 1 addition & 1 deletion packages/rollup-plugin/tests/rollup.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ describe("rollup", () => {
await expect(
wrapperRollupGenerate(STANDARD_AND_FP, { useLodashEs: true }, "cjs"),
).rejects.toThrowErrorMatchingInlineSnapshot(
`"'useLodashEs' is true but the output format is not 'es', 'esm' or 'module', it's cjs"`,
`"[plugin optimize-lodash-imports] 'useLodashEs' is true but the output format is not 'es', 'esm' or 'module', it's cjs"`,
);
});

Expand Down
4 changes: 1 addition & 3 deletions packages/rollup-plugin/tests/test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,7 @@ import { ParseFunction, transform } from "@optimize-lodash/transform";
import { optimizeLodashImports, OptimizeLodashOptions } from "../src";

jest.mock("@optimize-lodash/transform");
const sourceTransformerMock = transform as jest.MockedFunction<
typeof transform
>;
const sourceTransformerMock = jest.mocked(transform);

const UNCHANGED = null;
type UNCHANGED = null;
Expand Down
4 changes: 2 additions & 2 deletions packages/rollup-plugin/tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"extends": "@tsconfig/node12/tsconfig.json",
"extends": "@tsconfig/node18/tsconfig.json",

"include": ["src/**/*", "tests/*"],
"include": ["src/**/*", "tests/*", "jest.config.ts"],
"exclude": ["node_modules", "dist", "tests/fixtures"]
}
4 changes: 2 additions & 2 deletions packages/transform/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@
"typescript": "5.2.2"
},
"dependencies": {
"estree-walker": "2.x",
"magic-string": "0.30.x"
"estree-walker": "^2.0.2",
"magic-string": "~0.30.11"
}
}
Loading

0 comments on commit af5f97d

Please sign in to comment.