From 9c00a920d4c7d744999666804b862c17038fa18f Mon Sep 17 00:00:00 2001 From: Eoin O'Brien Date: Mon, 21 Jan 2019 23:35:00 +0000 Subject: [PATCH] [rollup-plugin-commonjs] Add types --- types/rollup-plugin-commonjs/index.d.ts | 62 +++++++++++++++++++ types/rollup-plugin-commonjs/package.json | 6 ++ .../rollup-plugin-commonjs-tests.ts | 18 ++++++ types/rollup-plugin-commonjs/tsconfig.json | 23 +++++++ types/rollup-plugin-commonjs/tslint.json | 1 + 5 files changed, 110 insertions(+) create mode 100644 types/rollup-plugin-commonjs/index.d.ts create mode 100644 types/rollup-plugin-commonjs/package.json create mode 100644 types/rollup-plugin-commonjs/rollup-plugin-commonjs-tests.ts create mode 100644 types/rollup-plugin-commonjs/tsconfig.json create mode 100644 types/rollup-plugin-commonjs/tslint.json diff --git a/types/rollup-plugin-commonjs/index.d.ts b/types/rollup-plugin-commonjs/index.d.ts new file mode 100644 index 0000000000..8f4c9238d4 --- /dev/null +++ b/types/rollup-plugin-commonjs/index.d.ts @@ -0,0 +1,62 @@ +// Type definitions for rollup-plugin-commonjs 9.2 +// Project: https://github.com/rollup/rollup-plugin-commonjs +// Definitions by: Eoin O'Brien +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped +// TypeScript Version: 2.3 + +/// +import { Plugin } from 'rollup'; + +export type IgnoreFunction = (id: string) => boolean; + +export interface Options { + /** + * Non-CommonJS modules will be ignored, but you can also + * specifically include files. + * @default undefined + */ + include?: string | Array; + + /** + * Non-CommonJS modules will be ignored, but you can also + * specifically exclude files. + * @default undefined + */ + exclude?: string | Array; + + /** + * Search for files other than .js files (must already + * be transpiled by a previous plugin). + * @default [ '.js' ] + */ + extensions?: string[]; + + /** + * If `true`, then uses of `global` won't be dealt with by this plugin. + * @default false + */ + ignoreGlobal?: boolean; + + /** + * If false, then skip sourceMap generation for CommonJS modules. + * @default true + */ + sourceMap?: boolean; + + /** + * Explicitly specify unresolvable named exports. + * @default undefined + */ + namedExports?: { [key: string]: string[] }; + + /** + * Sometimes you have to leave require statements + * unconverted. Pass an array containing the IDs + * or a `id => boolean` function. Only use this + * option if you know what you're doing! + * @default undefined + */ + ignore?: IgnoreFunction | string[]; +} + +export default function commonjs(options?: Options): Plugin; diff --git a/types/rollup-plugin-commonjs/package.json b/types/rollup-plugin-commonjs/package.json new file mode 100644 index 0000000000..02dc5dd6f1 --- /dev/null +++ b/types/rollup-plugin-commonjs/package.json @@ -0,0 +1,6 @@ +{ + "private": true, + "dependencies": { + "rollup": "^0.63.5" + } +} diff --git a/types/rollup-plugin-commonjs/rollup-plugin-commonjs-tests.ts b/types/rollup-plugin-commonjs/rollup-plugin-commonjs-tests.ts new file mode 100644 index 0000000000..fce577ceb7 --- /dev/null +++ b/types/rollup-plugin-commonjs/rollup-plugin-commonjs-tests.ts @@ -0,0 +1,18 @@ +import commonjs from 'rollup-plugin-commonjs'; + +// $ExpectType Plugin +commonjs(); + +// $ExpectType Plugin +commonjs({}); + +// $ExpectType Plugin +commonjs({ + include: 'node_modules/**', + exclude: [ 'node_modules/foo/**', 'node_modules/bar/**' ], + extensions: [ '.js', '.coffee' ], + ignoreGlobal: false, + sourceMap: false, + namedExports: { './module.js': ['foo', 'bar' ] }, + ignore: [ 'conditional-runtime-dependency' ], +}); diff --git a/types/rollup-plugin-commonjs/tsconfig.json b/types/rollup-plugin-commonjs/tsconfig.json new file mode 100644 index 0000000000..cd8f963487 --- /dev/null +++ b/types/rollup-plugin-commonjs/tsconfig.json @@ -0,0 +1,23 @@ +{ + "compilerOptions": { + "module": "commonjs", + "lib": [ + "es6" + ], + "noImplicitAny": true, + "noImplicitThis": true, + "strictNullChecks": true, + "strictFunctionTypes": true, + "baseUrl": "../", + "typeRoots": [ + "../" + ], + "types": [], + "noEmit": true, + "forceConsistentCasingInFileNames": true + }, + "files": [ + "index.d.ts", + "rollup-plugin-commonjs-tests.ts" + ] +} diff --git a/types/rollup-plugin-commonjs/tslint.json b/types/rollup-plugin-commonjs/tslint.json new file mode 100644 index 0000000000..3db14f85ea --- /dev/null +++ b/types/rollup-plugin-commonjs/tslint.json @@ -0,0 +1 @@ +{ "extends": "dtslint/dt.json" }