mirror of
https://github.com/microsoft/monaco-editor.git
synced 2025-12-22 10:25:42 +01:00
fix(monaco-editor-webpack-plugin): load monaco-editor with webpack 4
Closes #2817
This commit is contained in:
parent
3e433551a9
commit
3ae92d5f1a
4 changed files with 21 additions and 14 deletions
2
webpack-plugin/src/loader-utils.d.ts
vendored
2
webpack-plugin/src/loader-utils.d.ts
vendored
|
|
@ -1,3 +1,5 @@
|
|||
declare module 'loader-utils' {
|
||||
export function interpolateName(loaderContext: any, name: string, options?: any): string;
|
||||
|
||||
export function stringifyRequest(loaderContext: any, resource: string): string;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,4 +1,5 @@
|
|||
import type { PitchLoaderDefinitionFunction } from 'webpack';
|
||||
import * as loaderUtils from 'loader-utils';
|
||||
|
||||
export interface ILoaderOptions {
|
||||
globals?: { [key: string]: string };
|
||||
|
|
@ -9,7 +10,7 @@ export interface ILoaderOptions {
|
|||
export const pitch: PitchLoaderDefinitionFunction<ILoaderOptions> = function pitch(
|
||||
remainingRequest
|
||||
) {
|
||||
const { globals = undefined, pre = [], post = [] } = this.getOptions() || {};
|
||||
const { globals = undefined, pre = [], post = [] } = (this.query as ILoaderOptions) || {};
|
||||
|
||||
// HACK: NamedModulesPlugin overwrites existing modules when requesting the same module via
|
||||
// different loaders, so we need to circumvent this by appending a suffix to make the name unique
|
||||
|
|
@ -19,7 +20,10 @@ export const pitch: PitchLoaderDefinitionFunction<ILoaderOptions> = function pit
|
|||
}
|
||||
|
||||
const stringifyRequest = (request: string) => {
|
||||
return JSON.stringify(this.utils.contextify(this.context || this.rootContext, request));
|
||||
if (this.utils) {
|
||||
return JSON.stringify(this.utils.contextify(this.context || this.rootContext, request));
|
||||
}
|
||||
return loaderUtils.stringifyRequest(this, request);
|
||||
};
|
||||
|
||||
return [
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue