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 definitions #236

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
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
10 changes: 5 additions & 5 deletions packages/multi-entry/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -49,14 +49,14 @@ export const color = 'purple';
Then, create a `rollup.config.js` [configuration file](https://www.rollupjs.org/guide/en/#configuration-files) and import the plugin:

```js
import multi from '@rollup/plugin-multi-entry';
import multiEntry from '@rollup/plugin-multi-entry';

export default {
input: ['batman.js', 'robin.js', 'joker.js'],
output: {
dir: 'output'
},
plugins: [multi()]
plugins: [multiEntry()]
};
```

Expand Down Expand Up @@ -84,7 +84,7 @@ When using `plugin-multi-entry`, input values passed as a normal `String` are [g
```js
export default {
input: 'batcave/friends/**/*.js',
plugins: [multi()]
plugins: [multiEntry()]
// ...
};
```
Expand All @@ -96,7 +96,7 @@ An `Array` of `String` can be passed as the input. Values are glob-aware and can
```js
export default {
input: ['party/supplies.js', 'batcave/friends/**/*.js'],
plugins: [multi()]
plugins: [multiEntry()]
// ...
};
```
Expand All @@ -113,7 +113,7 @@ export default {
// except for the joker
exclude: ['**/joker.js']
},
plugins: [multi()]
plugins: [multiEntry()]
// ...
};
```
Expand Down
20 changes: 12 additions & 8 deletions packages/multi-entry/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,19 +16,21 @@
"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",
"lint:js": "eslint --fix --cache src test types --ext .js,.ts",
"lint:package": "prettier --write package.json --plugin=prettier-plugin-package",
"prebuild": "del-cli dist",
"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 All @@ -44,13 +46,14 @@
"rollup": "^1.20.0"
},
"dependencies": {
"@rollup/pluginutils": "^3.0.8",
"matched": "^1.0.2"
},
"devDependencies": {
"@babel/core": "^7.2.0",
"@babel/preset-env": "^7.2.0",
"rollup": "^1.20.1",
"rollup-plugin-babel": "^4.0.3"
"@babel/core": "^7.8.3",
"@babel/preset-env": "^7.8.3",
"rollup": "^1.29.0",
"rollup-plugin-babel": "^4.3.3"
},
"ava": {
"files": [
Expand All @@ -60,5 +63,6 @@
"!**/types.ts"
]
},
"module": "dist/index.es.js"
"module": "dist/index.es.js",
"types": "types/index.d.ts"
}
20 changes: 20 additions & 0 deletions packages/multi-entry/test/types.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
import { RollupOptions } from 'rollup';

import multiEntry from '..';

const config: RollupOptions = {
input: 'main.js',
output: {
file: 'bundle.js',
format: 'iife'
},
plugins: [
multiEntry({
include: 'src/*',
exclude: 'src/foo/**',
exports: false,
})
]
};

export default config;
27 changes: 27 additions & 0 deletions packages/multi-entry/types/index.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
import { FilterPattern } from '@rollup/pluginutils';
import { Plugin } from 'rollup';

export interface RollupMultiEntryOptions {
/**
* 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;
/**
* 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;
}

/**
* Allows use of multiple entry points for a bundle
*/
export default function multiEntry(options?: RollupMultiEntryOptions): Plugin;
10 changes: 6 additions & 4 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.