@@ -3,6 +3,7 @@ import inject from '@rollup/plugin-inject';
33import json from '@rollup/plugin-json' ;
44import nodeResolve from '@rollup/plugin-node-resolve' ;
55import terser from '@rollup/plugin-terser' ;
6+ import { dts } from 'rollup-plugin-dts' ;
67
78/**
89 * @returns {import('rollup').RollupOptions }
@@ -13,36 +14,43 @@ export default (commandLineArgs) => {
1314 // Clears rollup CLI warning https://github.com/rollup/rollup/issues/2694
1415 delete commandLineArgs . sourceMap ;
1516
16- return {
17- input : 'lib/index.js' ,
18- output : [
19- {
20- file : 'dist/bundle.mjs' ,
21- format : 'esm' ,
22- sourcemap : sourceMap
23- } ,
24- {
25- file : 'dist/bundle.cjs' ,
26- format : 'cjs' ,
27- sourcemap : sourceMap
28- }
29- ] ,
30- plugins : [
31- json ( ) ,
32- nodeResolve ( { preferBuiltins : false , browser : true } ) ,
33- commonjs ( { } ) ,
34- inject ( {
35- Buffer : [ 'buffer' , 'Buffer' ] ,
36- ReadableStream : [ 'web-streams-polyfill/ponyfill' , 'ReadableStream' ] ,
37- // Used by can-ndjson-stream
38- TextDecoder : [ 'text-encoding' , 'TextDecoder' ]
39- } ) ,
40- terser ( { sourceMap } )
41- ] ,
42- // This makes life easier
43- external : [
44- // This has dynamic logic - makes bundling hard
45- 'cross-fetch'
46- ]
47- } ;
17+ return [
18+ {
19+ input : 'lib/index.js' ,
20+ output : [
21+ {
22+ file : 'dist/bundle.mjs' ,
23+ format : 'esm' ,
24+ sourcemap : sourceMap
25+ } ,
26+ {
27+ file : 'dist/bundle.cjs' ,
28+ format : 'cjs' ,
29+ sourcemap : sourceMap
30+ }
31+ ] ,
32+ plugins : [
33+ json ( ) ,
34+ nodeResolve ( { preferBuiltins : false , browser : true } ) ,
35+ commonjs ( { } ) ,
36+ inject ( {
37+ Buffer : [ 'buffer' , 'Buffer' ] ,
38+ ReadableStream : [ 'web-streams-polyfill/ponyfill' , 'ReadableStream' ] ,
39+ // Used by can-ndjson-stream
40+ TextDecoder : [ 'text-encoding' , 'TextDecoder' ]
41+ } ) ,
42+ terser ( { sourceMap } )
43+ ] ,
44+ // This makes life easier
45+ external : [
46+ // This has dynamic logic - makes bundling hard
47+ 'cross-fetch'
48+ ]
49+ } ,
50+ {
51+ input : './lib/index.d.ts' ,
52+ output : [ { file : 'dist/index.d.cts' , format : 'cjs' } ] ,
53+ plugins : [ dts ( ) ]
54+ }
55+ ] ;
4856} ;
0 commit comments