-
-
Notifications
You must be signed in to change notification settings - Fork 599
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(dsv,dynamic-import-vars,image,legacy,multi-entry,strip,sucrase,u…
…rl,yaml): add typings (#898) * feat(dsv): add typings * feat(dynamic-import-vars): add typings * feat(image): add typings * feat(legacy): add typings * feat(multi-entry): add typings * feat(strip): add typings * feat(sucrase): add typings * feat(url): add typings * feat(yaml): add typings * fix(dynamic-import-vars): fix typings * chore(types): make options optional * chore(types): make options optional * run linter * test(types): add tests for typings * deps(dsv): add @types/d3-dsv * deps: make `@types/d3-dsv` a dependency * chore(tests): explicitly import from `types` dir * chore(tests): import plugins from root
- Loading branch information
1 parent
ca0540f
commit 4885d59
Showing
30 changed files
with
621 additions
and
273 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
import { RollupOptions } from 'rollup'; | ||
|
||
import dsv from '..'; | ||
|
||
const config: RollupOptions = { | ||
input: 'main.js', | ||
output: { | ||
file: 'bundle.js', | ||
format: 'iife' | ||
}, | ||
plugins: [ | ||
dsv({ | ||
include: 'node_modules/**', | ||
exclude: ['node_modules/foo/**', 'node_modules/bar/**'], | ||
processRow(row) { | ||
return row; | ||
} | ||
}) | ||
] | ||
}; | ||
|
||
export default config; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
import { DSVRowString } from 'd3-dsv'; | ||
import { FilterPattern } from '@rollup/pluginutils'; | ||
import { Plugin } from 'rollup'; | ||
|
||
interface RollupDsvOptions { | ||
/** | ||
* A minimatch pattern, or array of patterns, which specifies the files in the build the plugin | ||
* should operate on. | ||
* By default all files are targeted. | ||
*/ | ||
include?: FilterPattern; | ||
/** | ||
* A minimatch pattern, or array of patterns, which specifies the files in the build the plugin | ||
* should _ignore_. | ||
* By default no files are ignored. | ||
*/ | ||
exclude?: FilterPattern; | ||
/** | ||
* Specifies a function which processes each row in the parsed array. | ||
* The function can either manipulate the passed row, or return an entirely new row object. | ||
* @default undefined | ||
*/ | ||
processRow?: null | ((row: DSVRowString, id: string) => DSVRowString | undefined); | ||
} | ||
|
||
/** | ||
* Convert `.csv` and `.tsv `files into JavaScript modules with `d3-dsv`. | ||
*/ | ||
export default function dsv(options?: RollupDsvOptions): Plugin; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
import { RollupOptions } from 'rollup'; | ||
|
||
import dynamicImportVars from '..'; | ||
|
||
const config: RollupOptions = { | ||
input: 'main.js', | ||
output: { | ||
file: 'bundle.js', | ||
format: 'iife' | ||
}, | ||
plugins: [ | ||
dynamicImportVars({ | ||
include: 'node_modules/**', | ||
exclude: ['node_modules/foo/**', 'node_modules/bar/**'], | ||
warnOnError: true | ||
}) | ||
] | ||
}; | ||
|
||
export default config; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
import { FilterPattern } from '@rollup/pluginutils'; | ||
import { walk } from 'estree-walker'; | ||
import { Plugin } from 'rollup'; | ||
|
||
interface RollupDynamicImportVariablesOptions { | ||
/** | ||
* A minimatch pattern, or array of patterns, which specifies the files in the build the plugin | ||
* should operate on. | ||
* By default all files are targeted. | ||
*/ | ||
include?: FilterPattern; | ||
/** | ||
* A minimatch pattern, or array of patterns, which specifies the files in the build the plugin | ||
* should _ignore_. | ||
* By default no files are ignored. | ||
*/ | ||
exclude?: FilterPattern; | ||
/** | ||
* By default, the plugin quits the build process when it encounters an error. | ||
* If you set this option to true, it will throw a warning instead and leave the code untouched. | ||
* @default false | ||
*/ | ||
warnOnError?: boolean; | ||
} | ||
|
||
export class VariableDynamicImportError extends Error {} | ||
|
||
export function dynamicImportToGlob(...params: Parameters<typeof walk>): null | string; | ||
|
||
/** | ||
* Support variables in dynamic imports in Rollup. | ||
*/ | ||
export default function dynamicImportVariables( | ||
options?: RollupDynamicImportVariablesOptions | ||
): Plugin; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
import { RollupOptions } from 'rollup'; | ||
|
||
import image from '..'; | ||
|
||
const config: RollupOptions = { | ||
input: 'main.js', | ||
output: { | ||
file: 'bundle.js', | ||
format: 'iife' | ||
}, | ||
plugins: [ | ||
image({ | ||
include: 'node_modules/**', | ||
exclude: ['node_modules/foo/**', 'node_modules/bar/**'], | ||
dom: false | ||
}) | ||
] | ||
}; | ||
|
||
export default config; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
import { FilterPattern } from '@rollup/pluginutils'; | ||
import { Plugin } from 'rollup'; | ||
|
||
interface RollupImageOptions { | ||
/** | ||
* A minimatch pattern, or array of patterns, which specifies the files in the build the plugin | ||
* should operate on. | ||
* By default all files are targeted. | ||
*/ | ||
include?: FilterPattern; | ||
/** | ||
* A minimatch pattern, or array of patterns, which specifies the files in the build the plugin | ||
* should _ignore_. | ||
* By default no files are ignored. | ||
*/ | ||
exclude?: FilterPattern; | ||
/** | ||
* If `true`, instructs the plugin to generate an ES Module which exports a DOM `Image` which can | ||
* be used with a browser's DOM. | ||
* Otherwise, the plugin generates an ES Module which exports a `default const` containing the | ||
* Base64 representation of the image. | ||
* | ||
* Using this option set to `true`, the export can be used as such: | ||
* | ||
* @example | ||
* import logo from './rollup.png'; | ||
* document.body.appendChild(logo); | ||
* | ||
* @default false | ||
*/ | ||
dom?: boolean; | ||
} | ||
|
||
export default function image(options?: RollupImageOptions): Plugin; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -30,6 +30,7 @@ | |
}, | ||
"files": [ | ||
"dist", | ||
"types", | ||
"README.md", | ||
"LICENSE" | ||
], | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
import { RollupOptions } from 'rollup'; | ||
|
||
import legacy from '..'; | ||
|
||
const config: RollupOptions = { | ||
input: 'main.js', | ||
output: { | ||
file: 'bundle.js', | ||
format: 'iife' | ||
}, | ||
plugins: [ | ||
legacy({ | ||
'vendor/some-library.js': 'someLibrary', | ||
|
||
'vendor/another-library.js': { | ||
foo: 'anotherLib.foo', | ||
bar: 'anotherLib.bar', | ||
baz: 'anotherLib.baz' | ||
} | ||
}) | ||
] | ||
}; | ||
|
||
export default config; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
import { Plugin } from 'rollup'; | ||
|
||
interface RollupLegacyOptions { | ||
[key: string]: string | { [key: string]: string }; | ||
} | ||
|
||
/** | ||
* A Rollup plugin which adds `export` declarations to legacy non-module scripts. | ||
*/ | ||
export default function legacy(options: RollupLegacyOptions): Plugin; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
import { RollupOptions } from 'rollup'; | ||
|
||
import multiEntry from '..'; | ||
|
||
const config: RollupOptions = { | ||
input: 'main.js', | ||
output: { | ||
file: 'bundle.js', | ||
format: 'iife' | ||
}, | ||
plugins: [ | ||
multiEntry({ | ||
include: 'node_modules/**', | ||
exclude: ['node_modules/foo/**', 'node_modules/bar/**'], | ||
exports: false, | ||
entryFileName: 'multi-entry.js' | ||
}) | ||
] | ||
}; | ||
|
||
export default config; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
import { FilterPattern } from '@rollup/pluginutils'; | ||
import { Plugin } from 'rollup'; | ||
|
||
interface RollupMultiEntryOptions { | ||
/** | ||
* A minimatch pattern, or array of patterns, which specifies the files in the build the plugin | ||
* should operate on. | ||
* By default all files are targeted. | ||
*/ | ||
include?: FilterPattern; | ||
/** | ||
* A minimatch pattern, or array of patterns, which specifies the files in the build the plugin | ||
* should _ignore_. | ||
* By default no files are ignored. | ||
*/ | ||
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. | ||
* @default true | ||
*/ | ||
exports?: boolean; | ||
/** | ||
* `entryFileName` changes the name of the generated entry file. | ||
* By default, it will override `outputOptions.entryFileNames` to be `'multi-entry.js'`. | ||
* @default 'multi-entry.js' | ||
*/ | ||
entryFileName?: string; | ||
} | ||
|
||
/** | ||
* A Rollup plugin which allows use of multiple entry points for a bundle. | ||
* | ||
* _Note: `default` exports cannot be combined and exported by this plugin. Only named exports | ||
* will be exported._ | ||
*/ | ||
export default function multiEntry(options?: RollupMultiEntryOptions): Plugin; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
import { RollupOptions } from 'rollup'; | ||
|
||
import strip from '../types/index'; | ||
|
||
const config: RollupOptions = { | ||
input: 'main.js', | ||
output: { | ||
file: 'bundle.js', | ||
format: 'iife' | ||
}, | ||
plugins: [ | ||
strip({ | ||
include: 'node_modules/**', | ||
exclude: ['node_modules/foo/**', 'node_modules/bar/**'], | ||
debugger: true, | ||
functions: ['console.*', 'assert.*', 'expect'], | ||
labels: [], | ||
sourceMap: true | ||
}) | ||
] | ||
}; | ||
|
||
export default config; |
Oops, something went wrong.