Comments (10)
I have the same problem
BlazorMonaco version 3.0.0
Blazorise (bootstrap and other dependecies) version 1.0.7
Any update?
from blazormonaco.
Having the same issue here too. Should we expect to see this issue addressed or will we need to look for alternative solutions?
Edit: I was able to find a solution here.
According to the solution in #59, you can replace the following scripts:
- <script src="_content/BlazorMonaco/lib/monaco-editor/min/vs/loader.js"></script>
- <script src="_content/BlazorMonaco/lib/monaco-editor/min/vs/editor/editor.main.js"></script>
+ <script src="https://cdn.jsdelivr.net/npm/monaco-yaml-prebuilt/dist/monaco-editor.min.js"></script>
from blazormonaco.
Similar problem with Blazorise.Bootstrap 1.2.1 and BlazorMonaco 3.0.0
Error: Microsoft.JSInterop.JSException: Can only have one anonymous define call per script file Error: Can only have one anonymous define call per script file at s.enqueueDefineAnonymousModule (https://localhost:59356/_content/BlazorMonaco/lib/monaco-editor/min/vs/loader.js:8:5413) at g (https://localhost:***/_content/BlazorMonaco/lib/monaco-editor/min/vs/loader.js:9:1857) at https://localhost:***/_content/Blazorise/vendors/sha512.js?v=1.2.1.0:9:17673 at https://localhost:***/_content/Blazorise/vendors/sha512.js?v=1.2.1.0:9:17703 at Microsoft.JSInterop.JSRuntime.InvokeAsync[TValue](Int64 targetInstanceId, String identifier, Object[] args) at Blazorise.Modules.BaseJSModule.InvokeSafeVoidAsync(String identifier, Object[] args) at Blazorise.BaseComponent.OnAfterRenderAsync(Boolean firstRender) at Microsoft.AspNetCore.Components.RenderTree.Renderer.GetErrorHandledTask(Task taskToHandle, ComponentState owningComponentState)
from blazormonaco.
Also having the same issue after upgrading to Blazorise 1.2.2
and BlazorMonaco 3.0.0
. Has anyone found a workaround?
from blazormonaco.
Stuck here as well...
from blazormonaco.
no expert on JS, but after some digging I think the problem stems from Blazorise using ESM and Monaco using AMD.
I have a working application using Blazorise 0.9.3.5 and BlazorMonaco 2.0.0, but I can't upgrade, because it breaks with the same error message you got.
Found this and played around according to the suggestions, unsuccessfully unfortunately: microsoft/monaco-editor#2283
from blazormonaco.
Stuck as well
from blazormonaco.
@gt-jkinter - This is great, thanks for sharing!
from blazormonaco.
I have solved this by replacing the way the JavaScript is bundled. It works in all combinations of Blazorise and Monaco.
Advantage: Full control of code and can be bundled locally (with LigerSharp or similar), no external repo calls!
Steps:
- Prepare to compile javascript, add npm to your project (I use Blazor server). Use this package.json:
{
"name": "my.app",
"version": "1.0.0",
"description": "",
"main": "index.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"keywords": [],
"author": "",
"license": "ISC",
"devDependencies": {
"css-loader": "^6.9.0",
"file-loader": "^6.2.0",
"monaco-editor-webpack-plugin": "^7.1.0",
"style-loader": "^3.3.4",
"webpack": "^5.89.0",
"webpack-cli": "^5.1.4"
},
"dependencies": {
"monaco-editor": "^0.45.0"
}
}
This includes the original monaco editor sources.
- Create your own bundler, I use Webpack. This is "webpack.config.js':
const MonacoWebpackPlugin = require('monaco-editor-webpack-plugin');
const path = require('path');
module.exports = {
mode: 'production',
entry: './src/index.js',
output: {
path: path.resolve(__dirname, 'wwwroot/assets/vendor/monaco-editor'),
filename: 'editor.js'
},
module: {
rules: [
{`const MonacoWebpackPlugin = require('monaco-editor-webpack-plugin');
const path = require('path');
module.exports = {
mode: 'production',
entry: './src/index.js',
output: {
path: path.resolve(__dirname, 'wwwroot/assets/vendor/monaco-editor'),
filename: 'editor.js'
},
module: {
rules: [
{
test: /\.css$/,
use: ['style-loader', 'css-loader']
},
{
test: /\.ttf$/,
use: ['file-loader']
}
]
},
plugins: [new MonacoWebpackPlugin()]
};`
test: /\.css$/,
use: ['style-loader', 'css-loader']
},
{
test: /\.ttf$/,
use: ['file-loader']
}
]
},
plugins: [new MonacoWebpackPlugin()]
};
- Compile using Webpack CLI:
npx webpack
. A lot output appears
- You get the JS bundle in wwwroot/assets/vendor/monaco-editor. Now reference in your app.razor (or whereever)
<script src="/assets/vendor/monaco-editor/editor.js"></script>
<script src="_content/BlazorMonaco/jsInterop.js"></script>
Put the BlazorMonaco script afterwards!
This bundle uses a different loader and is fully compatible with Blazorise. Also, I run this with Syncfusion and this works too.
from blazormonaco.
Tried to make this work as well. I followed the steps by @joergkrause , but it wasn't fully working for me yet. A few changes I made:
- Create the package.json
{
"version": "1.0.0",
"name": "my-app",
"main": "index.js",
"private": true,
"devDependencies": {
"css-loader": "6.10.0",
"file-loader": "6.2.0",
"monaco-editor-webpack-plugin": "7.1.0",
"style-loader": "3.3.4",
"webpack": "5.90.3",
"webpack-cli": "5.1.4"
},
"dependencies": {
"monaco-editor": "0.46.0"
}
}
- Create
webpack.config.js
:
Note that this differs from the original code, found this example at https://github.com/microsoft/monaco-editor/blob/main/samples/browser-esm-webpack-monaco-plugin/webpack.config.js
const MonacoWebpackPlugin = require('monaco-editor-webpack-plugin');
const path = require('path');
// See https://github.com/microsoft/monaco-editor/blob/main/samples/browser-esm-webpack-monaco-plugin/webpack.config.js
module.exports = {
mode: 'production',
entry: './src/index.js',
output: {
path: path.resolve(__dirname, 'wwwroot/vendor/monaco-editor'),
filename: 'editor.js'
},
module: {
rules: [
{
test: /\.css$/,
use: ['style-loader', 'css-loader']
},
{
test: /\.ttf$/,
use: ['file-loader']
}
]
},
plugins: [
new MonacoWebpackPlugin({
languages: ['csharp' ]
})
]
};
- Create
./src/index.js
(but not sure about the content, what should go in here?):
import * as monaco from 'monaco-editor';
window.monaco = monaco;
-
Compile using
npx webpack
, creates the files inwwwroot/vendor/monaco-editor
-
Add this on the top of the page where the editor is used:
<script src="/assets/vendor/monaco-editor/editor.js"></script>
<script src="/assets/vendor/monaco-editor/editor.worker.js"></script>
<script src="_content/BlazorMonaco/jsInterop.js"></script>
from blazormonaco.
Related Issues (20)
- Unable to bind value to c# object. HOT 2
- Could not find 'blazorMonaco.editor.create' HOT 3
- Seeing "Attempting to reconnect to the server: 1 of 8" HOT 3
- Issue after upgrading HOT 1
- How to add/customize Suggestions?
- Please consider updating the embedded version of the Monaco Editor HOT 2
- Dotnet 8 Support HOT 4
- Not working when debugging, but works after publishing and running executable HOT 1
- Is there any way to clear the CompletionList for a CompletionItemProvider? HOT 3
- Other supported languages HOT 1
- Unable to editor.GetValue() with more than ~500 lines of code HOT 1
- Cannot access a disposed object HOT 4
- Problems with Mudblazor? "Found markup with unexpected name 'StandaloneCodeEditor' HOT 2
- Async CompletionItemProvider HOT 3
- onkeydown and onkeyup invalid cast HOT 1
- Sometimes not initialized correctly HOT 2
- Disposing wrong editor when multiple editors are on the screen
- .NET 8 FluentUIBlazor (Server-side)
- Component is not recreated/rendered HOT 6
- Diff Editor Merging
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from blazormonaco.