I am using monaco-editor and I would like to include suggestions from multiple files. I am not sure what is the best way to do it but basically, I want that when I am exporting some functions in a file2.js, to be able to access that from another file1.js in the suggestions.
Any idea on how to achieve that ? Thank you !
file1
var express = require('express');
var pug = require('pug');
var config = require('./config');
var fs = require('fs');
var router = express.Router();
var utils = require('/utils');
// Here I would like to use the function newTest from the other file
but it does not show in the suggestions
router.get('/', function (req, res) {
console.log("ip - ", req.connection.remoteAddress)
res.send(pug.compileFile('views/main.pug')({
config
}))
});
module.exports = router;
file2
function newTest() {
}
module.exports.newTest = newTest;
editorFile
$(document).ready(function() {
// I prefetch my models, then I have a callback to create an instance of the editor
preFetchAllModels(function() {
var models = monaco.editor.getModels();
// I check that I have my models (file1 and file2) prefetched before creating the editor
console.log("models", models);
monaco.languages.typescript.javascriptDefaults.setEagerModelSync(true)
monacoEditor = monaco.editor.create(document.getElementById("editor"), {
value: "loading...",
language: "javascript",
theme: 'monokai',
lineHeight: 20,
fontSize: 16,
wordWrap: "bounded",
automaticLayout: true,
wrappingIndent: 'indent'
});
});
It looks like the following code did the trick:
monaco.languages.typescript.javascriptDefaults.setCompilerOptions({
allowNonTsExtensions: true
});