Skip to content

Commit 4885d59

Browse files
feat(dsv,dynamic-import-vars,image,legacy,multi-entry,strip,sucrase,url,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
1 parent ca0540f commit 4885d59

File tree

30 files changed

+621
-273
lines changed

30 files changed

+621
-273
lines changed

packages/commonjs/test/types.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import type { RollupOptions } from 'rollup';
22

3-
import commonjs from '../types';
3+
import commonjs from '..';
44

55
const config: RollupOptions = {
66
input: 'main.js',

packages/dsv/package.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,18 +30,21 @@
3030
},
3131
"files": [
3232
"dist",
33+
"types",
3334
"README.md",
3435
"LICENSE"
3536
],
3637
"dependencies": {
3738
"@rollup/pluginutils": "^3.1.0",
39+
"@types/d3-dsv": "~1.2.0",
3840
"d3-dsv": "1.2.0",
3941
"tosource": "^1.0.0"
4042
},
4143
"devDependencies": {
4244
"del-cli": "^3.0.1",
4345
"rollup": "^2.23.0"
4446
},
47+
"types": "./types/index.d.ts",
4548
"ava": {
4649
"babel": {
4750
"compileEnhancements": false

packages/dsv/test/types.ts

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
import { RollupOptions } from 'rollup';
2+
3+
import dsv from '..';
4+
5+
const config: RollupOptions = {
6+
input: 'main.js',
7+
output: {
8+
file: 'bundle.js',
9+
format: 'iife'
10+
},
11+
plugins: [
12+
dsv({
13+
include: 'node_modules/**',
14+
exclude: ['node_modules/foo/**', 'node_modules/bar/**'],
15+
processRow(row) {
16+
return row;
17+
}
18+
})
19+
]
20+
};
21+
22+
export default config;

packages/dsv/types/index.d.ts

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
import { DSVRowString } from 'd3-dsv';
2+
import { FilterPattern } from '@rollup/pluginutils';
3+
import { Plugin } from 'rollup';
4+
5+
interface RollupDsvOptions {
6+
/**
7+
* A minimatch pattern, or array of patterns, which specifies the files in the build the plugin
8+
* should operate on.
9+
* By default all files are targeted.
10+
*/
11+
include?: FilterPattern;
12+
/**
13+
* A minimatch pattern, or array of patterns, which specifies the files in the build the plugin
14+
* should _ignore_.
15+
* By default no files are ignored.
16+
*/
17+
exclude?: FilterPattern;
18+
/**
19+
* Specifies a function which processes each row in the parsed array.
20+
* The function can either manipulate the passed row, or return an entirely new row object.
21+
* @default undefined
22+
*/
23+
processRow?: null | ((row: DSVRowString, id: string) => DSVRowString | undefined);
24+
}
25+
26+
/**
27+
* Convert `.csv` and `.tsv `files into JavaScript modules with `d3-dsv`.
28+
*/
29+
export default function dsv(options?: RollupDsvOptions): Plugin;

packages/dynamic-import-vars/package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,7 @@
6262
"prettier": "^2.0.5",
6363
"rollup": "^2.23.0"
6464
},
65+
"types": "./types/index.d.ts",
6566
"ava": {
6667
"babel": {
6768
"compileEnhancements": false
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
import { RollupOptions } from 'rollup';
2+
3+
import dynamicImportVars from '..';
4+
5+
const config: RollupOptions = {
6+
input: 'main.js',
7+
output: {
8+
file: 'bundle.js',
9+
format: 'iife'
10+
},
11+
plugins: [
12+
dynamicImportVars({
13+
include: 'node_modules/**',
14+
exclude: ['node_modules/foo/**', 'node_modules/bar/**'],
15+
warnOnError: true
16+
})
17+
]
18+
};
19+
20+
export default config;
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
import { FilterPattern } from '@rollup/pluginutils';
2+
import { walk } from 'estree-walker';
3+
import { Plugin } from 'rollup';
4+
5+
interface RollupDynamicImportVariablesOptions {
6+
/**
7+
* A minimatch pattern, or array of patterns, which specifies the files in the build the plugin
8+
* should operate on.
9+
* By default all files are targeted.
10+
*/
11+
include?: FilterPattern;
12+
/**
13+
* A minimatch pattern, or array of patterns, which specifies the files in the build the plugin
14+
* should _ignore_.
15+
* By default no files are ignored.
16+
*/
17+
exclude?: FilterPattern;
18+
/**
19+
* By default, the plugin quits the build process when it encounters an error.
20+
* If you set this option to true, it will throw a warning instead and leave the code untouched.
21+
* @default false
22+
*/
23+
warnOnError?: boolean;
24+
}
25+
26+
export class VariableDynamicImportError extends Error {}
27+
28+
export function dynamicImportToGlob(...params: Parameters<typeof walk>): null | string;
29+
30+
/**
31+
* Support variables in dynamic imports in Rollup.
32+
*/
33+
export default function dynamicImportVariables(
34+
options?: RollupDynamicImportVariablesOptions
35+
): Plugin;

packages/html/types/index.d.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ export interface RollupHtmlOptions {
1515
fileName?: string;
1616
meta?: Record<string, any>[];
1717
publicPath?: string;
18-
template?: (templateOptions: RollupHtmlTemplateOptions) => string;
18+
template?: (templateoptions?: RollupHtmlTemplateOptions) => string;
1919
}
2020

2121
export function makeHtmlAttributes(attributes: Record<string, string>): string;

packages/image/package.json

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@
3333
},
3434
"files": [
3535
"dist",
36+
"tests",
3637
"README.md",
3738
"LICENSE"
3839
],
@@ -53,6 +54,7 @@
5354
"@rollup/plugin-buble": "^0.21.3",
5455
"rollup": "^2.23.0"
5556
},
57+
"types": "./types/index.d.ts",
5658
"ava": {
5759
"babel": {
5860
"compileEnhancements": false

packages/image/test/types.ts

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
import { RollupOptions } from 'rollup';
2+
3+
import image from '..';
4+
5+
const config: RollupOptions = {
6+
input: 'main.js',
7+
output: {
8+
file: 'bundle.js',
9+
format: 'iife'
10+
},
11+
plugins: [
12+
image({
13+
include: 'node_modules/**',
14+
exclude: ['node_modules/foo/**', 'node_modules/bar/**'],
15+
dom: false
16+
})
17+
]
18+
};
19+
20+
export default config;

0 commit comments

Comments
 (0)