Skip to content
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

feat(multi-entry): add typescript typings #198

Closed
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 6 additions & 3 deletions packages/multi-entry/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand All @@ -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"
],
Expand Down Expand Up @@ -60,5 +62,6 @@
"!**/types.ts"
]
},
"module": "dist/index.es.js"
"module": "dist/index.es.js",
"types": "types/index.d.ts"
}
19 changes: 19 additions & 0 deletions packages/multi-entry/test/types.ts
Original file line number Diff line number Diff line change
@@ -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;
17 changes: 17 additions & 0 deletions packages/multi-entry/types/index.d.ts
Original file line number Diff line number Diff line change
@@ -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;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The options type can also be the input type: string, string array, or object with includes/excludes. See the configure function

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah ok, that contradicts the readme, that should be updated too then

https://github.com/rollup/plugins/tree/master/packages/multi-entry#options

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@shellscape Is this intended behaviour? If so I agree we should update the README

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The README isn't necessarily wrong, but it needs an update to be more in line with other plugins. Specifically around include and exclude

}

/**
* allow the use of multiple entry points for a bundle
LukasBombach marked this conversation as resolved.
Show resolved Hide resolved
*/
export default function multiEntry(options?: Options): Plugin;