File tree Expand file tree Collapse file tree 1 file changed +4
-0
lines changed Expand file tree Collapse file tree 1 file changed +4
-0
lines changed Original file line number Diff line number Diff line change @@ -176,11 +176,15 @@ loader.pitch = function(request) {
176
176
workerUrl = `"data:,importScripts('"+location.origin+${ workerUrl } +"')"` ;
177
177
}
178
178
179
+ // workerUrl will be URL.revokeObjectURL() to avoid memory leaks on browsers
180
+ // https://github.com/webpack-contrib/worker-loader/issues/208
181
+
179
182
return cb ( null , `
180
183
var addMethods = require(${ loaderUtils . stringifyRequest ( this , path . resolve ( __dirname , 'rpc-wrapper.js' ) ) } )
181
184
var methods = ${ JSON . stringify ( exports ) }
182
185
module.exports = function() {
183
186
var w = new Worker(${ workerUrl } , { name: ${ JSON . stringify ( filename ) } })
187
+ URL.revokeObjectURL(${ workerUrl } );
184
188
addMethods(w, methods)
185
189
${ options . ready ? 'w.ready = new Promise(function(r) { w.addEventListener("ready", function(){ r(w) }) })' : '' }
186
190
return w
You can’t perform that action at this time.
0 commit comments