perf: prevent stack overflow when concat buffer
This commit is contained in:
parent
e67050ca65
commit
fe316e9dcb
|
@ -1,6 +1,6 @@
|
||||||
import { fromFileUrl, join } from '$std/path/mod.ts'
|
import { fromFileUrl, join } from '$std/path/mod.ts'
|
||||||
import { builder } from './builder.ts'
|
import { builder } from './builder.ts'
|
||||||
import { cssImports, Logger } from './helpers.ts'
|
import { cssImports, Logger, uInt8ArrayConcat } from './helpers.ts'
|
||||||
|
|
||||||
export async function bundleCss(
|
export async function bundleCss(
|
||||||
sourceDir: string,
|
sourceDir: string,
|
||||||
|
@ -24,7 +24,7 @@ export async function bundleCss(
|
||||||
)
|
)
|
||||||
await Deno.writeFile(
|
await Deno.writeFile(
|
||||||
join(assetDir, pathname),
|
join(assetDir, pathname),
|
||||||
Uint8Array.of(...code, ...sourceMappingURL),
|
uInt8ArrayConcat(code, sourceMappingURL),
|
||||||
)
|
)
|
||||||
|
|
||||||
await Deno.writeFile(
|
await Deno.writeFile(
|
||||||
|
|
|
@ -26,3 +26,10 @@ export async function hashFile(file: ArrayBuffer): Promise<string> {
|
||||||
}
|
}
|
||||||
|
|
||||||
export const cssImports: Map<string, string> = new Map()
|
export const cssImports: Map<string, string> = new Map()
|
||||||
|
|
||||||
|
export function uInt8ArrayConcat(a: Uint8Array, b: Uint8Array) {
|
||||||
|
const dest = new Uint8Array(a.length + b.length)
|
||||||
|
dest.set(a)
|
||||||
|
dest.set(b, a.length)
|
||||||
|
return dest
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in a new issue