mirror of
https://github.com/microsoft/monaco-editor.git
synced 2025-12-22 12:45:39 +01:00
Merge remote-tracking branch 'origin/main' into pr/k15a/147
This commit is contained in:
commit
7462aef57b
3 changed files with 30 additions and 13 deletions
|
|
@ -71,6 +71,9 @@ Options can be passed in to `MonacoWebpackPlugin`. They can be used to generate
|
|||
* default value: <!-- FEATURES_BEGIN -->`['accessibilityHelp', 'anchorSelect', 'bracketMatching', 'caretOperations', 'clipboard', 'codeAction', 'codelens', 'colorPicker', 'comment', 'contextmenu', 'coreCommands', 'cursorUndo', 'dnd', 'documentSymbols', 'find', 'folding', 'fontZoom', 'format', 'gotoError', 'gotoLine', 'gotoSymbol', 'hover', 'iPadShowKeyboard', 'inPlaceReplace', 'indentation', 'inlineHints', 'inspectTokens', 'linesOperations', 'linkedEditing', 'links', 'multicursor', 'parameterHints', 'quickCommand', 'quickHelp', 'quickOutline', 'referenceSearch', 'rename', 'smartSelect', 'snippets', 'suggest', 'toggleHighContrast', 'toggleTabFocusMode', 'transpose', 'unusualLineTerminators', 'viewportSemanticTokens', 'wordHighlighter', 'wordOperations', 'wordPartOperations']`<!-- FEATURES_END -->.
|
||||
* excluded features: It is also possible to exclude certain default features prefixing them with an exclamation mark '!'.
|
||||
|
||||
* `globalAPI` (`boolean`) - specify whether the editor API should be exposed through a global `monaco` object or not. This option is applicable to `0.22.0` and newer version of `monaco-editor`. Since `0.22.0`, the ESM version of the monaco editor does no longer define a global `monaco` object unless `global.MonacoEnvironment = { globalAPI: true }` is set ([change log](https://github.com/microsoft/monaco-editor/blob/main/CHANGELOG.md#0220-29012021)).
|
||||
* default value: `false`.
|
||||
|
||||
## Version Matrix
|
||||
|
||||
| `monaco-editor-webpack-plugin` | `monaco-editor` |
|
||||
|
|
|
|||
22
package-lock.json
generated
22
package-lock.json
generated
|
|
@ -789,12 +789,6 @@
|
|||
"integrity": "sha512-q+CP5zMR/aFiMTE9QlIavGyGicKnG2v/H8qVvybLzeFsARM8f6G9fL0sMST2tyVYCwDKkGamZUI6647A0jR/Lg==",
|
||||
"dev": true
|
||||
},
|
||||
"nanoid": {
|
||||
"version": "3.1.20",
|
||||
"resolved": "https://registry.npmjs.org/nanoid/-/nanoid-3.1.20.tgz",
|
||||
"integrity": "sha512-a1cQNyczgKbLX9jwbS/+d7W8fX/RfgYR7lVWwWOGIPNgK2m0MWvrGF6/m4kk6U3QcFMnZf3RIhL0v2Jgh/0Uxw==",
|
||||
"dev": true
|
||||
},
|
||||
"neo-async": {
|
||||
"version": "2.6.2",
|
||||
"resolved": "https://registry.npmjs.org/neo-async/-/neo-async-2.6.2.tgz",
|
||||
|
|
@ -903,14 +897,22 @@
|
|||
}
|
||||
},
|
||||
"postcss": {
|
||||
"version": "8.2.7",
|
||||
"resolved": "https://registry.npmjs.org/postcss/-/postcss-8.2.7.tgz",
|
||||
"integrity": "sha512-DsVLH3xJzut+VT+rYr0mtvOtpTjSyqDwPf5EZWXcb0uAKfitGpTY9Ec+afi2+TgdN8rWS9Cs88UDYehKo/RvOw==",
|
||||
"version": "8.2.15",
|
||||
"resolved": "https://registry.npmjs.org/postcss/-/postcss-8.2.15.tgz",
|
||||
"integrity": "sha512-2zO3b26eJD/8rb106Qu2o7Qgg52ND5HPjcyQiK2B98O388h43A448LCslC0dI2P97wCAQRJsFvwTRcXxTKds+Q==",
|
||||
"dev": true,
|
||||
"requires": {
|
||||
"colorette": "^1.2.2",
|
||||
"nanoid": "^3.1.20",
|
||||
"nanoid": "^3.1.23",
|
||||
"source-map": "^0.6.1"
|
||||
},
|
||||
"dependencies": {
|
||||
"nanoid": {
|
||||
"version": "3.1.23",
|
||||
"resolved": "https://registry.npmjs.org/nanoid/-/nanoid-3.1.23.tgz",
|
||||
"integrity": "sha512-FiB0kzdP0FFVGDKlRLEQ1BgDzU87dy5NnzjeW9YZNt+/c3+q82EQDUwniSAUxp/F0gFNI1ZhKU1FqYsMuqZVnw==",
|
||||
"dev": true
|
||||
}
|
||||
}
|
||||
},
|
||||
"postcss-modules-extract-imports": {
|
||||
|
|
|
|||
18
src/index.ts
18
src/index.ts
|
|
@ -99,6 +99,15 @@ interface IMonacoEditorWebpackPluginOpts {
|
|||
* Use e.g. '/' if you want to load your resources from the current origin.
|
||||
*/
|
||||
publicPath?: string;
|
||||
|
||||
/**
|
||||
* Specify whether the editor API should be exposed through a global `monaco` object or not. This
|
||||
* option is applicable to `0.22.0` and newer version of `monaco-editor`. Since `0.22.0`, the ESM
|
||||
* version of the monaco editor does no longer define a global `monaco` object unless
|
||||
* `global.MonacoEnvironment = { globalAPI: true }` is set ([change
|
||||
* log](https://github.com/microsoft/monaco-editor/blob/main/CHANGELOG.md#0220-29012021)).
|
||||
*/
|
||||
globalAPI?: boolean;
|
||||
}
|
||||
|
||||
interface IInternalMonacoEditorWebpackPluginOpts {
|
||||
|
|
@ -106,6 +115,7 @@ interface IInternalMonacoEditorWebpackPluginOpts {
|
|||
features: IFeatureDefinition[];
|
||||
filename: string;
|
||||
publicPath: string;
|
||||
globalAPI: boolean;
|
||||
}
|
||||
|
||||
class MonacoEditorWebpackPlugin implements webpack.WebpackPluginInstance {
|
||||
|
|
@ -121,11 +131,12 @@ class MonacoEditorWebpackPlugin implements webpack.WebpackPluginInstance {
|
|||
features: coalesce(features.map(id => featuresById[id])),
|
||||
filename: options.filename || "[name].worker.js",
|
||||
publicPath: options.publicPath || '',
|
||||
globalAPI: options.globalAPI || false,
|
||||
};
|
||||
}
|
||||
|
||||
apply(compiler: webpack.Compiler): void {
|
||||
const { languages, features, filename, publicPath } = this.options;
|
||||
const { languages, features, filename, publicPath, globalAPI } = this.options;
|
||||
const compilationPublicPath = getCompilationPublicPath(compiler);
|
||||
const modules = [EDITOR_MODULE].concat(languages).concat(features);
|
||||
const workers: ILabeledWorkerDefinition[] = [];
|
||||
|
|
@ -138,7 +149,7 @@ class MonacoEditorWebpackPlugin implements webpack.WebpackPluginInstance {
|
|||
});
|
||||
}
|
||||
});
|
||||
const rules = createLoaderRules(languages, features, workers, filename, publicPath, compilationPublicPath);
|
||||
const rules = createLoaderRules(languages, features, workers, filename, publicPath, compilationPublicPath, globalAPI);
|
||||
const plugins = createPlugins(compiler, workers, filename);
|
||||
addCompilerRules(compiler, rules);
|
||||
addCompilerPlugins(compiler, plugins);
|
||||
|
|
@ -176,7 +187,7 @@ function getCompilationPublicPath(compiler: webpack.Compiler): string {
|
|||
return '';
|
||||
}
|
||||
|
||||
function createLoaderRules(languages: IFeatureDefinition[], features: IFeatureDefinition[], workers: ILabeledWorkerDefinition[], filename: string, pluginPublicPath: string, compilationPublicPath: string): webpack.RuleSetRule[] {
|
||||
function createLoaderRules(languages: IFeatureDefinition[], features: IFeatureDefinition[], workers: ILabeledWorkerDefinition[], filename: string, pluginPublicPath: string, compilationPublicPath: string, globalAPI: boolean): webpack.RuleSetRule[] {
|
||||
if (!languages.length && !features.length) {
|
||||
return [];
|
||||
}
|
||||
|
|
@ -215,6 +226,7 @@ function createLoaderRules(languages: IFeatureDefinition[], features: IFeatureDe
|
|||
return str.replace(/\\/$/, '');
|
||||
}
|
||||
return {
|
||||
globalAPI: ${globalAPI},
|
||||
getWorkerUrl: function (moduleId, label) {
|
||||
var pathPrefix = ${pathPrefix};
|
||||
var result = (pathPrefix ? stripTrailingSlash(pathPrefix) + '/' : '') + paths[label];
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue