File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 4444 " rollup-plugin"
4545 ],
4646 "peerDependencies" : {
47- "rollup" : " ^1.20.0||^2.0 .0||^3.0.0||^4.0.0"
47+ "rollup" : " ^2.78 .0||^3.0.0||^4.0.0"
4848 },
4949 "peerDependenciesMeta" : {
5050 "rollup" : {
Original file line number Diff line number Diff line change @@ -6,29 +6,39 @@ import { createFilter } from '@rollup/pluginutils';
66import stripBom from 'strip-bom' ;
77
88const parsers = { '.csv' : csvParse , '.tsv' : tsvParse } ;
9+ const idFilter = new RegExp (
10+ `\\.(?:${ Object . keys ( parsers )
11+ . map ( ( ext ) => ext . slice ( 1 ) )
12+ . join ( '|' ) } )$`
13+ ) ;
914
1015export default function dsv ( options = { } ) {
1116 const filter = createFilter ( options . include , options . exclude ) ;
1217
1318 return {
1419 name : 'dsv' ,
1520
16- transform ( code , id ) {
17- if ( ! filter ( id ) ) return null ;
21+ transform : {
22+ filter : {
23+ id : idFilter
24+ } ,
25+ handler ( code , id ) {
26+ if ( ! filter ( id ) ) return null ;
1827
19- const ext = extname ( id ) ;
20- if ( ! ( ext in parsers ) ) return null ;
28+ const ext = extname ( id ) ;
29+ if ( ! ( ext in parsers ) ) return null ;
2130
22- let rows = parsers [ ext ] ( stripBom ( code ) ) ;
31+ let rows = parsers [ ext ] ( stripBom ( code ) ) ;
2332
24- if ( options . processRow ) {
25- rows = rows . map ( ( row ) => options . processRow ( row , id ) || row ) ;
26- }
33+ if ( options . processRow ) {
34+ rows = rows . map ( ( row ) => options . processRow ( row , id ) || row ) ;
35+ }
2736
28- return {
29- code : `export default ${ toSource ( rows ) } ;` ,
30- map : { mappings : '' }
31- } ;
37+ return {
38+ code : `export default ${ toSource ( rows ) } ;` ,
39+ map : { mappings : '' }
40+ } ;
41+ }
3242 }
3343 } ;
3444}
You can’t perform that action at this time.
0 commit comments