forked from cypress-io/cypress
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathasync-rewriters.ts
32 lines (28 loc) · 936 Bytes
/
async-rewriters.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
import { queueRewriting } from './threads'
import { DeferSourceMapRewriteFn } from './js'
// these functions are not included in `./js` or `./html` because doing so
// would mean that `./threads/worker` would unnecessarily end up loading in the
// `./threads` module for each worker
export function rewriteHtmlJsAsync (url: string, html: string, deferSourceMapRewrite: DeferSourceMapRewriteFn): Promise<string> {
return queueRewriting({
url,
deferSourceMapRewrite,
source: html,
isHtml: true,
})
}
export function rewriteJsAsync (url: string, js: string, deferSourceMapRewrite: DeferSourceMapRewriteFn): Promise<string> {
return queueRewriting({
url,
deferSourceMapRewrite,
source: js,
})
}
export function rewriteJsSourceMapAsync (url: string, js: string, inputSourceMap: any): Promise<string> {
return queueRewriting({
url,
inputSourceMap,
sourceMap: true,
source: js,
})
}