@@ -18,28 +18,13 @@ import resolve from '@rollup/plugin-node-resolve';
18
18
import typescript from '@rollup/plugin-typescript' ;
19
19
import commonjs from '@rollup/plugin-commonjs' ;
20
20
import compiler from '@ampproject/rollup-plugin-closure-compiler' ;
21
- import MagicString from 'magic-string' ;
22
-
23
- function makeExecutable ( ) {
24
- return {
25
- name : 'make-executable' ,
26
- renderChunk ( code , chunkInfo ) {
27
- if ( chunkInfo . fileName === 'filesize' ) {
28
- const magicString = new MagicString ( code ) ;
29
- magicString . prepend ( '#!/usr/bin/env node\n\n' ) ;
30
- return { code : magicString . toString ( ) , map : magicString . generateMap ( { hires : true } ) } ;
31
- }
32
- } ,
33
- } ;
34
- }
35
21
36
22
const external = [ 'os' , 'zlib' , 'path' , 'fs' , 'stream' , 'util' , 'events' , 'fast-glob' , 'process' ] ;
37
23
const plugins = executable => [
38
24
resolve ( { preferBuiltins : true } ) ,
39
25
commonjs ( { include : 'node_modules/**' } ) ,
40
26
typescript ( { tsconfig : 'src/tsconfig.json' , include : '**/*.ts' , exclude : 'dist/**/*.ts' } ) ,
41
27
executable ? compiler ( ) : null ,
42
- executable ? makeExecutable ( ) : null ,
43
28
] ;
44
29
45
30
export default [
@@ -49,15 +34,16 @@ export default [
49
34
file : 'dist/filesize' ,
50
35
format : 'cjs' ,
51
36
sourcemap : true ,
37
+ banner : '#!/usr/bin/env node' ,
52
38
} ,
53
39
external,
54
40
plugins : plugins ( true ) ,
55
41
} ,
56
42
{
57
- input : 'src/index .ts' ,
43
+ input : 'src/api .ts' ,
58
44
output : {
59
- file : 'dist/index.js ' ,
60
- format : 'cjs ' ,
45
+ file : 'dist/api.mjs ' ,
46
+ format : 'esm ' ,
61
47
sourcemap : true ,
62
48
} ,
63
49
external,
@@ -66,8 +52,8 @@ export default [
66
52
{
67
53
input : 'src/api.ts' ,
68
54
output : {
69
- file : 'dist/api.mjs ' ,
70
- format : 'esm ' ,
55
+ file : 'dist/api.js ' ,
56
+ format : 'cjs ' ,
71
57
sourcemap : true ,
72
58
} ,
73
59
external,
0 commit comments