@@ -8,29 +8,6 @@ const package = require("../package.json");
88
99// --- utils ---
1010
11- const MAX_CHUNK_SIZE = 3 * 1024 * 1024 ; // 3 MiB
12-
13- function addFileInChunks ( zip , filePath , toDir , baseName , maxChunkSize = MAX_CHUNK_SIZE ) {
14- const buffer = fs . readFileSync ( filePath ) ;
15- let offset = 0 ;
16-
17- const chunks = [ ] ;
18- while ( offset < buffer . length ) {
19- const end = Math . min ( offset + maxChunkSize , buffer . length ) ;
20- const chunk = buffer . subarray ( offset , end ) ;
21- chunks . push ( chunk ) ;
22- offset = end ;
23- }
24- const len = chunks . length ;
25-
26- for ( let idx = 0 ; idx < len ; idx += 1 ) {
27- const chunk = chunks [ idx ] ;
28- // e.g. src/ts.worker.js.part30, src/ts.worker.js.part31, ...
29- const chunkPath = `${ toDir } ${ baseName } .part${ idx } ` ;
30- zip . file ( chunkPath , chunk ) ;
31- }
32- }
33-
3411const createJSZip = ( ) => {
3512 const currDate = new Date ( ) ;
3613 const dateWithOffset = new Date ( currDate . getTime ( ) - currDate . getTimezoneOffset ( ) * 60000 ) ;
@@ -154,15 +131,7 @@ chrome.file("manifest.json", JSON.stringify(chromeManifest));
154131firefox . file ( "manifest.json" , JSON . stringify ( firefoxManifest ) ) ;
155132
156133addDir ( chrome , "./dist/ext" , "" , [ "manifest.json" ] ) ;
157- addDir ( firefox , "./dist/ext" , "" , [ "manifest.json" , "ts.worker.js" ] ) ;
158-
159- // Now split ts.worker.js into chunks (<4MB each) for Firefox
160- addFileInChunks (
161- firefox ,
162- "./dist/ext/src/ts.worker.js" , // source file on disk
163- "src/" , // folder path inside zip
164- "ts.worker.js" // base name for chunked file
165- ) ;
134+ addDir ( firefox , "./dist/ext" , "" , [ "manifest.json" ] ) ;
166135
167136// 导出zip包
168137chrome
0 commit comments