mirror of
https://github.com/microsoft/monaco-editor.git
synced 2025-12-22 18:32:56 +01:00
Use compiler.webpack if available
This will use compiler.webpack if it is available. Otherwise, it will fall back to require webpack lazily. This will make the plugin compatible with NextJS 10. Closes https://github.com/microsoft/monaco-editor-webpack-plugin/issues/141
This commit is contained in:
parent
c124699f22
commit
3e40369a31
2 changed files with 15 additions and 12 deletions
|
|
@ -1,5 +1,5 @@
|
|||
import type * as webpack from 'webpack';
|
||||
import * as path from 'path';
|
||||
import * as webpack from 'webpack';
|
||||
import * as loaderUtils from 'loader-utils';
|
||||
import * as fs from 'fs';
|
||||
import { AddWorkerEntryPointPlugin } from './plugins/AddWorkerEntryPointPlugin';
|
||||
|
|
@ -139,7 +139,7 @@ class MonacoEditorWebpackPlugin implements webpack.WebpackPluginInstance {
|
|||
}
|
||||
});
|
||||
const rules = createLoaderRules(languages, features, workers, filename, publicPath, compilationPublicPath);
|
||||
const plugins = createPlugins(workers, filename);
|
||||
const plugins = createPlugins(compiler, workers, filename);
|
||||
addCompilerRules(compiler, rules);
|
||||
addCompilerPlugins(compiler, plugins);
|
||||
}
|
||||
|
|
@ -247,7 +247,9 @@ function createLoaderRules(languages: IFeatureDefinition[], features: IFeatureDe
|
|||
];
|
||||
}
|
||||
|
||||
function createPlugins(workers: ILabeledWorkerDefinition[], filename: string): AddWorkerEntryPointPlugin[] {
|
||||
function createPlugins(compiler: webpack.Compiler, workers: ILabeledWorkerDefinition[], filename: string): AddWorkerEntryPointPlugin[] {
|
||||
const webpack = compiler.webpack ?? require('webpack');
|
||||
|
||||
return (
|
||||
(<AddWorkerEntryPointPlugin[]>[])
|
||||
.concat(workers.map(({ id, entry }) =>
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue