For setting up a Monaco editor instance I want to add a typings file for a custom lib. When mounting the editor I call:
    public componentDidMount(): void {
        languages.typescript.javascriptDefaults.addExtraLib(
            typings,
        );
    }
The variable typings is loaded by:
// eslint-disable-next-line @typescript-eslint/no-var-requires
const typings = require("../../../modules/scripting/typings/my-runtime.d.ts");
Side note: the eslint comment is necessary or it will mark the require call as failure.
I use react-app-rewired to allow editing my webpack config without ejecting the CRA based application. Now the config-overrides.js file contains:
const MonacoWebpackPlugin = require('monaco-editor-webpack-plugin');
module.exports = function override(config, env) {
    config.plugins.push(new MonacoWebpackPlugin({
        languages: ["typescript", "javascript", "mysql", "json", "markdown"]
    }));
    config.module.rules.push(
        {
            test: /\.(html|d\.ts)$/i,
            use: [
                {
                    loader: 'raw-loader',
                    options: {
                        esModule: false,
                    },
                },
            ],
        },
    );
    return config;
}
As you can see I actually handle 2 file types here: html and d.ts. The html part works nicely. A require call to load an .html file gives me the entire html file content (I need that to load an <iframe> with my custom runtime).
The require call for the typings file, however, returns an object (probably a module, hard to say as it appears empty in the debugger in vscode).
So the question is: how to change my config to make loading typings files (.d.ts) as text possible?
 
    