From efe1b37326a4ca928eab8c6b4bd11a9bc779d1ca Mon Sep 17 00:00:00 2001 From: Lukas Bombach Date: Wed, 5 Feb 2020 13:51:15 +0100 Subject: [PATCH 1/2] Adds types for multiEntry --- packages/multi-entry/package.json | 9 ++++++--- packages/multi-entry/test/types.ts | 19 +++++++++++++++++++ packages/multi-entry/types/index.d.ts | 17 +++++++++++++++++ 3 files changed, 42 insertions(+), 3 deletions(-) create mode 100644 packages/multi-entry/test/types.ts create mode 100644 packages/multi-entry/types/index.d.ts diff --git a/packages/multi-entry/package.json b/packages/multi-entry/package.json index e925791ee..8b9558367 100755 --- a/packages/multi-entry/package.json +++ b/packages/multi-entry/package.json @@ -16,7 +16,7 @@ "ci:coverage": "nyc pnpm run test && nyc report --reporter=text-lcov > coverage.lcov", "ci:lint": "pnpm run build && pnpm run lint", "ci:lint:commits": "commitlint --from=${CIRCLE_BRANCH} --to=${CIRCLE_SHA1}", - "ci:test": "pnpm run test -- --verbose", + "ci:test": "pnpm run test -- --verbose && pnpm run test:ts", "lint": "pnpm run lint:js && pnpm run lint:docs && pnpm run lint:package", "lint:docs": "prettier --single-quote --write README.md", "lint:js": "eslint --fix --cache src test", @@ -25,10 +25,12 @@ "prepare": "pnpm run build", "prepublishOnly": "pnpm run lint", "pretest": "pnpm run build", - "test": "ava" + "test": "ava", + "test:ts": "tsc types/index.d.ts test/types.ts --noEmit" }, "files": [ "dist", + "types", "README.md", "LICENSE" ], @@ -60,5 +62,6 @@ "!**/types.ts" ] }, - "module": "dist/index.es.js" + "module": "dist/index.es.js", + "types": "types/index.d.ts" } diff --git a/packages/multi-entry/test/types.ts b/packages/multi-entry/test/types.ts new file mode 100644 index 000000000..32a63487d --- /dev/null +++ b/packages/multi-entry/test/types.ts @@ -0,0 +1,19 @@ +// @ts-check +import multiEntry from ".."; + +/** @type {import("rollup").RollupOptions} */ +const config = { + input: ["main.js", "secondary.js"], + output: { + file: "bundle.js", + format: "iife", + name: "MyModule" + }, + plugins: [ + multiEntry({ + exports: false + }) + ] +}; + +export default config; diff --git a/packages/multi-entry/types/index.d.ts b/packages/multi-entry/types/index.d.ts new file mode 100644 index 000000000..ec55ed4f4 --- /dev/null +++ b/packages/multi-entry/types/index.d.ts @@ -0,0 +1,17 @@ +import { Plugin } from "rollup"; + +export interface Options { + /** + * If `true`, instructs the plugin to export named exports to the bundle from all + * entries. If `false`, the plugin will not export any entry exports to the bundle. + * This can be useful when wanting to combine code from multiple entry files, but + * not necessarily to export each entry file's exports. + * @default true + */ + exports?: boolean; +} + +/** + * allow the use of multiple entry points for a bundle + */ +export default function multiEntry(options?: Options): Plugin; From 087f95b46e31496f725d207d81d22952a3d81b59 Mon Sep 17 00:00:00 2001 From: Lukas Bombach Date: Wed, 5 Feb 2020 21:38:30 +0100 Subject: [PATCH 2/2] Update packages/multi-entry/types/index.d.ts Co-Authored-By: Tiger Oakes --- packages/multi-entry/types/index.d.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/multi-entry/types/index.d.ts b/packages/multi-entry/types/index.d.ts index ec55ed4f4..561745a9f 100644 --- a/packages/multi-entry/types/index.d.ts +++ b/packages/multi-entry/types/index.d.ts @@ -12,6 +12,6 @@ export interface Options { } /** - * allow the use of multiple entry points for a bundle + * 🍣 A Rollup plugin which allows use of multiple entry points for a bundle. */ export default function multiEntry(options?: Options): Plugin;