@@ -13,7 +13,11 @@ ensureEmpty(src)
13
13
ensureEmpty ( types )
14
14
ensureEmpty ( tests )
15
15
16
- fs . writeFileSync ( path . join ( types , 'index.d.ts' ) , fs . readFileSync ( path . join ( 'types' , 'index.d.ts' ) ) )
16
+ fs . writeFileSync (
17
+ path . join ( types , 'index.d.ts' ) ,
18
+ transpile ( fs . readFileSync ( path . join ( 'types' , 'index.d.ts' ) , 'utf8' ) , 'index.d.ts' , 'types' )
19
+ )
20
+
17
21
fs . writeFileSync (
18
22
path . join ( root , 'README.md' ) ,
19
23
fs . readFileSync ( 'README.md' , 'utf8' )
@@ -54,6 +58,10 @@ function transpile(x, name, folder) {
54
58
x += '\n;window.addEventListener("unload", () => Deno.exit(process.exitCode))'
55
59
}
56
60
61
+ const stream = x . includes ( 'import(\'node:stream\')' )
62
+ ? 'import { Readable, Writable } from \'' + std + 'node/stream.ts\'\n'
63
+ : ''
64
+
57
65
const buffer = x . includes ( 'Buffer' )
58
66
? 'import { Buffer } from \'' + std + 'node/buffer.ts\'\n'
59
67
: ''
@@ -70,7 +78,7 @@ function transpile(x, name, folder) {
70
78
? 'import { HmacSha256 } from \'' + std + 'hash/sha256.ts\'\n'
71
79
: ''
72
80
73
- return hmac + buffer + process + timers + x
81
+ return hmac + buffer + process + stream + timers + x
74
82
. replace (
75
83
/ s e t T i m e o u t \( ( .* ) \) \. u n r e f \( \) / g,
76
84
'(window.timer = setTimeout($1), Deno.unrefTimer(window.timer), window.timer)'
@@ -84,6 +92,7 @@ function transpile(x, name, folder) {
84
92
'(query.writable.push({ chunk }), callback())'
85
93
)
86
94
. replace ( / .s e t K e e p A l i v e \( [ ^ ) ] + \) / g, '' )
95
+ . replace ( / i m p o r t \( ' n o d e : s t r e a m ' \) \. / g, '' )
87
96
. replace ( / i m p o r t n e t f r o m ' n e t ' / , 'import { net } from \'../polyfills.js\'' )
88
97
. replace ( / i m p o r t t l s f r o m ' t l s ' / , 'import { tls } from \'../polyfills.js\'' )
89
98
. replace ( / f r o m ' ( [ a - z _ ] + ) ' / g, ' from \'' + std + 'node/$1.ts\'' )
0 commit comments