|
|
|
@ -43,7 +43,7 @@ function loader() {
|
|
|
|
|
const entryFileName = `${FileNamePrefix}index`; |
|
|
|
|
|
|
|
|
|
// 获取传递给 loader 的 options
|
|
|
|
|
loaderUtils.getOptions(this) || {}; |
|
|
|
|
const options = loaderUtils.getOptions(this) || {}; |
|
|
|
|
|
|
|
|
|
// 创建 childCompiler, 用于实现 worker 构建为独立 js 资源
|
|
|
|
|
const childCompiler = this._compilation.createChildCompiler(WorkerLoaderName, { |
|
|
|
@ -92,15 +92,24 @@ function loader() {
|
|
|
|
|
return callback(error); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
return callback( |
|
|
|
|
// 支持blob url形式
|
|
|
|
|
return options.inline |
|
|
|
|
? callback( |
|
|
|
|
null, |
|
|
|
|
// 插入代码的转译和压缩由主构建配置的 babel/ts loader 处理, 不需要 worker-worker 来处理
|
|
|
|
|
// 添加 @ts-nocheck 避免 ts-check 报错
|
|
|
|
|
`// @ts-nocheck
|
|
|
|
|
const blob = new Blob([${JSON.stringify(compilation.assets[entry].source())}]); |
|
|
|
|
export const workerUrl = window.URL.createObjectURL(blob); |
|
|
|
|
` |
|
|
|
|
) |
|
|
|
|
: callback( |
|
|
|
|
null, |
|
|
|
|
`// @ts-nocheck
|
|
|
|
|
const servicePath = __webpack_public_path__ + ${JSON.stringify(entry)}; |
|
|
|
|
export const workerUrl = servicePath; |
|
|
|
|
` |
|
|
|
|
); |
|
|
|
|
) |
|
|
|
|
}); |
|
|
|
|
|
|
|
|
|
return; |
|
|
|
|