Many packages are published with the same version, and almost all of them depend on the @codingame/monaco-vscode-api
main package (with strict version range).
It is VERY important that only a single version of ALL the packages is installed, otherwise weird things can happen.
You can check that npm list vscode
only lists a single version.
Starting from v2, monaco-editor-webpack-plugin can't be used
Here's the alternative for each options:
filename
: it can be configured at the webpack level directlypublicPath
: it can be configured at the webpack level or by hands when redistering the worker in window.MonacoEnvironment
.languages
: Import VSCode language extensions (@codingame/monaco-vscode-xxx-default-extension
) or (@codingame/@codingame/monaco-vscode-standalone-*
). Please obey: VSCode extensions can only be used if themes
and textmate
service overrides are configured and monaco languages can only be used if those two services are not configured (see here for further details).features
: With this lib, you can't remove editor features.globalAPI
: you can set window.MonacoEnvironment.globalAPI
to trueWebpack makes all file go through all matching loaders. This libraries need to load a lot of internals resources, including HTML, svg and javascript files (for default extension codes).
We need webpack to let those file untouched:
Fortunately, all the assets are loaded via the new URL('asset.extension', import.meta.url)
syntax, and webpack provide a way to exclude the file loaded that way: dependency: { not: ['url'] }
see https://webpack.js.org/guides/asset-modules/
This library uses a lot the new URL('asset.extension', import.meta.url)
syntax which is supported by vite
While it works great in build
mode (because rollup is used), there is some issues in watch
mode:
import.meta.url
is not replaced while creating bundles, it is an issue when the syntax is used inside a dependencyThere are workarounds for both:
import.meta.url
by the original module path:import importMetaUrlPlugin from '@codingame/esbuild-import-meta-url-plugin' { ... optimizeDeps: { esbuildOptions: { plugins: [importMetaUrlPlugin] } } }
Some dependencies are published only as CommonJS, and vite fails by default to work with them when used in a worker.
Those libraries are concerned:
vscode-textmate
vscode-oniguruma
(textmate dependency)@vscode/vscode-languagedetection
If you use the corresponding service override, you can force vite to optimize them, which will make vite properly handle commonjs, by adding them in the vite config in optimizeDeps.include
:
export default defineConfig({ optimizeDeps: { include: [ 'vscode-textmate', 'vscode-oniguruma', '@vscode/vscode-languagedetection' ] } })If using Angular and getting
Not allowed to load local resource:
errors
The short version: set up and use a custom webpack config file and add this under module
:
parser: { javascript: { url: true, } }
See this issue or this StackOverflow answer for more details, and this discussion for more context.
The typescript language features extension is not providing project-wide intellisenseThe typescript language features extensions requires SharedArrayBuffer to enable project wide intellisense or only a per-file intellisense is provided.
It requires crossOriginIsolated to be true, which requires assets files to be servers with some specific headers:
same-origin
require-corp
or credentialless
At least thoses files should have the headers:
webWorkerExtensionHostIframe.html
extensionHost.worker.js
If adding those headers is not an options, you can have a look at https://github.com/gzuidhof/coi-serviceworker, but only if you are not using webviews as it introduces problems then.
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4