worker-plugin
Advanced tools
Comparing version 3.1.0 to 3.2.0
@@ -60,2 +60,3 @@ function _interopDefault (ex) { return (ex && (typeof ex === 'object') && 'default' in ex) ? ex['default'] : ex; } | ||
workerCompiler.context = this._compiler.context; | ||
new WebWorkerTemplatePlugin(workerOptions).apply(workerCompiler); | ||
@@ -62,0 +63,0 @@ new FetchCompileWasmTemplatePlugin({ |
@@ -34,2 +34,4 @@ function _interopDefault (ex) { return (ex && (typeof ex === 'object') && 'default' in ex) ? ex['default'] : ex; } | ||
compiler.hooks.normalModuleFactory.tap(NAME, function (factory) { | ||
var workerId = 0; | ||
for (var i = 0, list = JS_TYPES; i < list.length; i += 1) { | ||
@@ -39,3 +41,2 @@ var type = list[i]; | ||
factory.hooks.parser.for(("javascript/" + type)).tap(NAME, function (parser) { | ||
var workerId = 0; | ||
parser.hooks.new.for('Worker').tap(NAME, function (expr) { | ||
@@ -78,7 +79,7 @@ var dep = parser.evaluateExpression(expr.arguments[0]); | ||
var loaderOptions = opts.name && { | ||
name: opts.name | ||
var loaderOptions = { | ||
name: opts.name || workerId + '' | ||
}; | ||
var req = "require(" + (JSON.stringify(workerLoader + (loaderOptions ? '?' + JSON.stringify(loaderOptions) : '') + '!' + dep.string)) + ")"; | ||
var id = "__webpack__worker__" + (++workerId); | ||
var req = "require(" + (JSON.stringify(workerLoader + '?' + JSON.stringify(loaderOptions) + '!' + dep.string)) + ")"; | ||
var id = "__webpack__worker__" + (workerId++); | ||
ParserHelpers.toConstantDependency(parser, id)(expr.arguments[0]); | ||
@@ -85,0 +86,0 @@ |
{ | ||
"name": "worker-plugin", | ||
"version": "3.1.0", | ||
"version": "3.2.0", | ||
"description": "Webpack plugin to bundle Workers automagically.", | ||
@@ -34,3 +34,3 @@ "main": "dist/worker-plugin.js", | ||
"<rootDir>/node_modules/", | ||
"<rootDir>/test/fixtures/.*?/dist/" | ||
"<rootDir>/test/fixtures/" | ||
] | ||
@@ -63,2 +63,5 @@ }, | ||
"devDependencies": { | ||
"@file-services/memory": "^1.0.3", | ||
"@file-services/node": "^1.0.3", | ||
"@file-services/overlay": "^1.0.3", | ||
"babel-plugin-transform-es2015-modules-commonjs": "^6.26.2", | ||
@@ -73,2 +76,3 @@ "clean-webpack-plugin": "^1.0.0", | ||
"jest": "^23.6.0", | ||
"memory-fs": "^0.4.1", | ||
"microbundle": "^0.8.2", | ||
@@ -75,0 +79,0 @@ "puppeteer": "^1.11.0", |
@@ -33,6 +33,5 @@ /** | ||
compiler.hooks.normalModuleFactory.tap(NAME, factory => { | ||
let workerId = 0; | ||
for (const type of JS_TYPES) { | ||
factory.hooks.parser.for(`javascript/${type}`).tap(NAME, parser => { | ||
let workerId = 0; | ||
parser.hooks.new.for('Worker').tap(NAME, expr => { | ||
@@ -72,5 +71,5 @@ const dep = parser.evaluateExpression(expr.arguments[0]); | ||
let loaderOptions = opts.name && { name: opts.name }; | ||
const req = `require(${JSON.stringify(workerLoader + (loaderOptions ? ('?' + JSON.stringify(loaderOptions)) : '') + '!' + dep.string)})`; | ||
const id = `__webpack__worker__${++workerId}`; | ||
const loaderOptions = { name: opts.name || workerId + '' }; | ||
const req = `require(${JSON.stringify(workerLoader + '?' + JSON.stringify(loaderOptions) + '!' + dep.string)})`; | ||
const id = `__webpack__worker__${workerId++}`; | ||
ParserHelpers.toConstantDependency(parser, id)(expr.arguments[0]); | ||
@@ -77,0 +76,0 @@ |
@@ -59,2 +59,3 @@ /** | ||
const workerCompiler = this._compilation.createChildCompiler(NAME, workerOptions, plugins); | ||
workerCompiler.context = this._compiler.context; | ||
(new WebWorkerTemplatePlugin(workerOptions)).apply(workerCompiler); | ||
@@ -61,0 +62,0 @@ (new FetchCompileWasmTemplatePlugin({ |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
46279
344
18