-
Notifications
You must be signed in to change notification settings - Fork 4k
Closed
Milestone
Description
Would it be possible to use a getWorker function in case getWorkerUrl is undefined? This would simplify the setup using Webpack or Parcel and make bundles smallers (shared dependencies). Example :
index.js
import JsonWorker from 'monaco-editor/esm/vs/language/json/json.worker';
import EditorWorker from 'monaco-editor/esm/vs/editor/editor.worker';
// Since packaging is done by you, you need
// to instruct the editor how you named the
// bundles that contain the web workers.
self.MonacoEnvironment = {
getWorker: function (moduleId, label) {
// Webpack
if (label === 'json') {
return new JsonWorker();
}
// ....
return new EditorWorker();
// Parcel
if (label === 'json') {
return new Worker('monaco-editor/esm/vs/language/json/json.worker');
}
// ....
return new Worker('monaco-editor/esm/vs/editor/editor.worker');
}
}webpack.config.js
const path = require('path');
const webpack = require('webpack');
module.exports = {
entry: {
"app": './index.js'
},
output: {
filename: '[name].bundle.js',
path: path.resolve(__dirname, 'dist')
},
module: {
rules: [{
test: /\.css$/,
use: [ 'style-loader', 'css-loader' ]
}, {
test: /\.worker\.js$/,
use: ['worker-loader']
}]
},
plugins: [
// Ignore require() calls in vs/language/typescript/lib/typescriptServices.js
new webpack.IgnorePlugin(
/^((fs)|(path)|(os)|(crypto)|(source-map-support))$/,
/vs\/language\/typescript\/lib/
)
]
}
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels