File tree Expand file tree Collapse file tree 5 files changed +13
-14
lines changed
Expand file tree Collapse file tree 5 files changed +13
-14
lines changed Original file line number Diff line number Diff line change @@ -25,8 +25,8 @@ fetchMock.mockGlobal();
2525( global as any ) . fetchMock = fetchMock ;
2626
2727// Mock the effects of the file-loader which our Webpack config defines
28- // for JS files under res : The "default export" is the path to the file.
29- jest . mock ( 'firefox-profiler-res/gz- worker.js' , ( ) => './res /gz- worker.js' ) ;
28+ // for files ending in .worker.js : The "default export" is the path to the file.
29+ jest . mock ( '../utils/gz. worker.js' , ( ) => 'src/utils /gz. worker.js' ) ;
3030
3131// Install a Worker class which is similar to the DOM Worker class.
3232( global as any ) . Worker = NodeWorker ;
Original file line number Diff line number Diff line change 55// Added by webpack's DefinePlugin
66declare const AVAILABLE_STAGING_LOCALES : string [ ] | null ;
77
8- declare module 'firefox-profiler-res/* .js' {
8+ declare module '*.worker .js' {
99 const content : string ;
1010 export default content ;
1111}
Original file line number Diff line number Diff line change 22 * License, v. 2.0. If a copy of the MPL was not distributed with this
33 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
44
5- import gzWorkerPath from 'firefox-profiler-res /gz- worker.js' ;
5+ import gzWorkerPath from '. /gz. worker.js' ;
66
77function runGzWorker (
88 kind : 'compress' | 'decompress' ,
Original file line number Diff line number Diff line change @@ -31,7 +31,7 @@ async function readableStreamToBuffer(stream) {
3131}
3232
3333onmessage = async ( e ) => {
34- let data = e . data ;
34+ const data = e . data ;
3535 if ( data . kind === 'compress' ) {
3636 // Create a gzip compression stream
3737 const compressionStream = new CompressionStream ( 'gzip' ) ;
@@ -42,7 +42,7 @@ onmessage = async (e) => {
4242 writer . close ( ) ;
4343
4444 // Read the compressed data back into a buffer
45- let result = await readableStreamToBuffer ( compressionStream . readable ) ;
45+ const result = await readableStreamToBuffer ( compressionStream . readable ) ;
4646 postMessage ( result , [ result . buffer ] ) ;
4747 } else if ( data . kind === 'decompress' ) {
4848 // Create a gzip compression stream
@@ -54,7 +54,7 @@ onmessage = async (e) => {
5454 writer . close ( ) ;
5555
5656 // Read the compressed data back into a buffer
57- let result = await readableStreamToBuffer ( decompressionStream . readable ) ;
57+ const result = await readableStreamToBuffer ( decompressionStream . readable ) ;
5858 postMessage ( result , [ result . buffer ] ) ;
5959 } else {
6060 throw new Error ( 'unknown message' ) ;
Original file line number Diff line number Diff line change @@ -32,15 +32,15 @@ const config = {
3232 devtool : 'source-map' ,
3333 module : {
3434 rules : [
35- {
36- test : / \. j s $ / ,
37- use : [ 'file-loader' ] ,
38- include : [ path . join ( __dirname , 'res' ) ] ,
39- } ,
4035 {
4136 test : / \. ( j s | t s | t s x ) $ / ,
4237 use : [ 'babel-loader' ] ,
43- include : [ path . join ( __dirname , 'src' ) ] ,
38+ include : includes ,
39+ } ,
40+ {
41+ test : / \. w o r k e r \. j s $ / ,
42+ use : [ 'file-loader' ] ,
43+ include : includes ,
4444 } ,
4545 {
4646 test : / \. j s o n $ / ,
@@ -99,7 +99,6 @@ const config = {
9999 patterns : [
100100 'res/_headers' ,
101101 'res/_redirects' ,
102- 'res/gz-worker.js' ,
103102 'res/contribute.json' ,
104103 'res/robots.txt' ,
105104 'res/service-worker-compat.js' ,
You can’t perform that action at this time.
0 commit comments