Do not create file:/// protocol fallback for web workers

This commit is contained in:
Alex Dima 2018-08-11 00:32:26 +02:00
parent 2fa1e0f3a6
commit ca5e6abbe0
3 changed files with 4 additions and 17 deletions

View file

@ -120,9 +120,6 @@ function createLoaderRules(languages, features, workers, outputPath, publicPath)
} }
function createPlugins(workers, outputPath) { function createPlugins(workers, outputPath) {
const workerFallbacks = workers.reduce((acc, { id, fallback }) => (fallback ? Object.assign(acc, {
[id]: resolveMonacoPath(fallback)
}) : acc), {});
return ( return (
[] []
.concat(uniqBy(workers, ({ id }) => id).map(({ id, entry, output }) => .concat(uniqBy(workers, ({ id }) => id).map(({ id, entry, output }) =>
@ -131,20 +128,10 @@ function createPlugins(workers, outputPath) {
entry: resolveMonacoPath(entry), entry: resolveMonacoPath(entry),
filename: path.join(outputPath, output), filename: path.join(outputPath, output),
plugins: [ plugins: [
createContextPlugin(WORKER_LOADER_PATH, {}),
new webpack.optimize.LimitChunkCountPlugin({ maxChunks: 1 }), new webpack.optimize.LimitChunkCountPlugin({ maxChunks: 1 }),
], ],
}) })
)) ))
.concat(workerFallbacks ? [createContextPlugin(WORKER_LOADER_PATH, workerFallbacks)] : [])
);
}
function createContextPlugin(filePath, contextPaths) {
return new webpack.ContextReplacementPlugin(
new RegExp(`^${path.dirname(filePath).replace(/[\/\\]/g, '(/|\\\\)')}$`),
'',
contextPaths
); );
} }

6
package-lock.json generated
View file

@ -2765,9 +2765,9 @@
} }
}, },
"monaco-editor": { "monaco-editor": {
"version": "0.14.1", "version": "0.14.2",
"resolved": "https://registry.npmjs.org/monaco-editor/-/monaco-editor-0.14.1.tgz", "resolved": "https://registry.npmjs.org/monaco-editor/-/monaco-editor-0.14.2.tgz",
"integrity": "sha512-a73LapNgGxSHW0TOor9IkOvyFG5t0zupXb+sGrx7UMkMif/Ql/Fc9QXYZ26GLx80GHMmDVTZN4lBINzXltAhUg==", "integrity": "sha512-SgWGZtoUcb+34gK/aEoqRpJ8/zKp19j1zqP2rZlT75pGHQoM3EIGZH7Qrlp6n5RWDySGVNdxlvsoecs5SghJ3A==",
"dev": true "dev": true
}, },
"move-concurrently": { "move-concurrently": {

View file

@ -28,7 +28,7 @@
}, },
"devDependencies": { "devDependencies": {
"css-loader": "^1.0.0", "css-loader": "^1.0.0",
"monaco-editor": "^0.14.1", "monaco-editor": "^0.14.2",
"style-loader": "^0.22.1", "style-loader": "^0.22.1",
"webpack": "^4.16.5", "webpack": "^4.16.5",
"webpack-cli": "^3.1.0" "webpack-cli": "^3.1.0"