monaco-languageclient: Vite build throws numerous errors
Vite build throws numerous errors
Description
I am trying to provide an npm library with various components, including those based on monaco-editor-react. Everything works as expected in the local development environment, but even with a minimal build configuration, I encounter numerous errors when integrating a component from the package (see screenshot).
Additionally, I receive the following warning:
11:36:00 AM [vite] warning: C:/Users/pbrostean/develop/vite-monaco-library-example/dist/index.js 330412| } 330413| async _workerLoadScript(i) { 330414| return this._amdPolicy && (i = this._amdPolicy.createScriptURL(i)), await import(i).then((e) => e.default ?? e), this._defineCalls.pop(); | ^ 330415| } 330416| async _nodeJSLoadScript(i) { The above dynamic import cannot be analyzed by Vite. See https://github.com/rollup/plugins/tree/master/packages/dynamic-import-vars#limitations for supported dynamic import formats. If this is intended to be left as-is, you can use the /* @vite-ignore */ comment inside the import() call to suppress this warning.
Plugin: vite:import-analysis File: C:/Users/pbrostean/develop/vite-monaco-library-example/dist/index.js Server responded with status code 431. See https://vite.dev/guide/troubleshooting.html#_431-request-header-fields-too-large.
Steps to Reproduce
- Clone the minimal example repository I have set up. (https://github.com/pbrostean/vite-monaco-library-example)
- Follow the build configuration provided in the repository.
- Attempt to build the package and integrate a component.
Expected Behavior
The build should complete without errors, and the components should work as expected when integrated.
Actual Behavior
The build fails with numerous errors and warnings as described above.
Any help or guidance would be greatly appreciated!
About this issue
- Original URL
- State: closed
- Created 2 years ago
- Comments: 23
I now have a very dirty but working version of my build set in GitHub.
InlineDynamicImportsapparently had nothing to do with the problems of the build as it turned out, the only thing that causes this is the error with theViewContainersByLocation. I don’t know if I can still get rid of that, I think it has something to do with the import order of rollup.Thanks again for your support, I don’t think I’m very clever at this as it’s all quite new to me
The extension host runs in an iframe, the iframe needs to load an html asset, that asset shouldn’t be base64ified.
I don’t know why all the assets get transformed to base64 urls in your project, but
webWorkerExtensionHostIframe.htmlshouldn’tWell, at least I got that solved again, it always worked locally with vite dev. If you add the importMetaUrlPlugin, it also works again, then the language is activated when the editor is loaded with the correct file and the color themes are also available again…
However, including the editor from the lib (
import { MonacoEditor } from "./dist/index.js";) still leads to the warnings of the dynamic importe and does not work.