Created
December 17, 2019 06:59
-
-
Save bengry/68123239a506a6147755ac9b624bbc85 to your computer and use it in GitHub Desktop.
Patches `workerize-loader` based on https://github.com/developit/workerize-loader/pull/61
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
diff --git a/node_modules/workerize-loader/dist/index.js b/node_modules/workerize-loader/dist/index.js | |
index f318035..7b16cc1 100644 | |
--- a/node_modules/workerize-loader/dist/index.js | |
+++ b/node_modules/workerize-loader/dist/index.js | |
@@ -80,7 +80,7 @@ loader.pitch = function (request) { | |
var entry = compilation.entries[0].resource; // only process entry exports | |
if (current.resource !== entry) { return; } | |
- var exports = compilation.__workerizeExports || (compilation.__workerizeExports = {}); | |
+ var exports = CACHE[entry] || (CACHE[entry] = {}); | |
if (decl.id) { | |
exports[decl.id.name] = true; | |
@@ -99,8 +99,10 @@ loader.pitch = function (request) { | |
if (entries[0]) { | |
worker.file = entries[0].files[0]; | |
+ | |
+ var entry = entries[0].entryModule.resource; | |
var contents = compilation.assets[worker.file].source(); | |
- var exports = Object.keys(CACHE[worker.file] = compilation.__workerizeExports || CACHE[worker.file] || {}); // console.log('Workerized exports: ', exports.join(', ')); | |
+ var exports = Object.keys(CACHE[entry] || {}); | |
if (options.inline) { | |
worker.url = "URL.createObjectURL(new Blob([" + (JSON.stringify(contents)) + "]))"; | |
diff --git a/node_modules/workerize-loader/src/index.js b/node_modules/workerize-loader/src/index.js | |
index 8f4c9fb..6759d5c 100644 | |
--- a/node_modules/workerize-loader/src/index.js | |
+++ b/node_modules/workerize-loader/src/index.js | |
@@ -83,7 +83,8 @@ loader.pitch = function(request) { | |
// only process entry exports | |
if (current.resource!==entry) return; | |
- let exports = compilation.__workerizeExports || (compilation.__workerizeExports = {}); | |
+ let exports = CACHE[entry] || (CACHE[entry] = {}); | |
if (decl.id) { | |
exports[decl.id.name] = true; | |
@@ -106,8 +107,9 @@ loader.pitch = function(request) { | |
if (entries[0]) { | |
worker.file = entries[0].files[0]; | |
- let contents = compilation.assets[worker.file].source(); | |
- let exports = Object.keys(CACHE[worker.file] = compilation.__workerizeExports || CACHE[worker.file] || {}); | |
+ let entry = entries[0].entryModule.resource; | |
+ let contents = compilation.assets[worker.file].source(); | |
+ let exports = Object.keys(CACHE[entry] || {}); | |
// console.log('Workerized exports: ', exports.join(', ')); | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment