Errors when importing multiple modes
a8a2cc68-d2aa-4415-8e0e-e9de7978ead3:1 Refused to execute script from 'http://localhost:3000/worker-css.js' because its MIME type ('text/html') is not executable.
(anonymous) @ a8a2cc68-d2aa-4415-8e0e-e9de7978ead3:1
a8a2cc68-d2aa-4415-8e0e-e9de7978ead3:1 Uncaught DOMException: Failed to execute 'importScripts' on 'WorkerGlobalScope': The script at 'http://localhost:3000/worker-css.js' failed to load.
at blob:http://localhost:3000/a8a2cc68-d2aa-4415-8e0e-e9de7978ead3:1:1
These errors dont mess anything up, everything works and it manages to change the mode successfully.
I am giving the user the ability to pick different modes(css, javascript, python, etc). So I am programatically importing the modes based on what the user asks for in a picker list.
// This runs whenever a new mode is selected by the user
const handleModeChange = (event) => {
var currentMode = event.target.value;
require(`ace-builds/src-noconflict/mode-${currentMode}`)
setState({...state, currentMode})
}
<AceEditor
mode={state.currentMode}
width="100%"
theme="twilight"
value={state.code}
onChange={onChange}
name="code_editor"
editorProps={{ $blockScrolling: true }}
/>
Getting the same error
import AceEditor from "react-ace"
import "ace-builds/src-noconflict/mode-javascript"
import "ace-builds/src-noconflict/theme-monokai"
//...
<AceEditor
name="Ace-editor"
mode="javascript"
fontSize={15}
wrapEnabled={true}
value={beautify(JSON.stringify(state.stepDetails))}
theme="monokai"
onChange={handleSchemaChange}
enableBasicAutocompletion={true}
enableLiveAutocompletion={true}
editorProps={{ $blockScrolling: true }}
/>
This was resolved after I added import "ace-builds/webpack-resolver"
See https://github.com/securingsincity/react-ace/issues/725#issuecomment-543109155
Thanks @pi0neerpat !
Most helpful comment
Solution:
This was resolved after I added
import "ace-builds/webpack-resolver"
See https://github.com/securingsincity/react-ace/issues/725#issuecomment-543109155