@@ -13,7 +13,11 @@ ensureEmpty(src)
1313ensureEmpty ( types )
1414ensureEmpty ( tests )
1515
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+
1721fs . writeFileSync (
1822 path . join ( root , 'README.md' ) ,
1923 fs . readFileSync ( 'README.md' , 'utf8' )
@@ -54,6 +58,10 @@ function transpile(x, name, folder) {
5458 x += '\n;window.addEventListener("unload", () => Deno.exit(process.exitCode))'
5559 }
5660
61+ const stream = x . includes ( 'import(\'node:stream\')' )
62+ ? 'import { Readable, Writable } from \'' + std + 'node/stream.ts\'\n'
63+ : ''
64+
5765 const buffer = x . includes ( 'Buffer' )
5866 ? 'import { Buffer } from \'' + std + 'node/buffer.ts\'\n'
5967 : ''
@@ -70,7 +78,7 @@ function transpile(x, name, folder) {
7078 ? 'import { HmacSha256 } from \'' + std + 'hash/sha256.ts\'\n'
7179 : ''
7280
73- return hmac + buffer + process + timers + x
81+ return hmac + buffer + process + stream + timers + x
7482 . replace (
7583 / s e t T i m e o u t \( ( .* ) \) \. u n r e f \( \) / g,
7684 '(window.timer = setTimeout($1), Deno.unrefTimer(window.timer), window.timer)'
@@ -84,6 +92,7 @@ function transpile(x, name, folder) {
8492 '(query.writable.push({ chunk }), callback())'
8593 )
8694 . 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, '' )
8796 . replace ( / i m p o r t n e t f r o m ' n e t ' / , 'import { net } from \'../polyfills.js\'' )
8897 . replace ( / i m p o r t t l s f r o m ' t l s ' / , 'import { tls } from \'../polyfills.js\'' )
8998 . replace ( / f r o m ' ( [ a - z _ ] + ) ' / g, ' from \'' + std + 'node/$1.ts\'' )
0 commit comments