mirror of
https://github.com/microsoft/monaco-editor.git
synced 2025-12-22 16:15:41 +01:00
Simplify code since alias is no longer used
This commit is contained in:
parent
5c82c65ae8
commit
8aa2205ff3
1 changed files with 2 additions and 15 deletions
17
index.js
17
index.js
|
|
@ -12,7 +12,6 @@ const EDITOR_MODULE = {
|
|||
output: 'editor.worker.js',
|
||||
fallback: undefined
|
||||
},
|
||||
alias: undefined,
|
||||
};
|
||||
const LANGUAGES = require('./languages');
|
||||
const FEATURES = require('./features');
|
||||
|
|
@ -21,11 +20,7 @@ function resolveMonacoPath(filePath) {
|
|||
return require.resolve(path.join('monaco-editor/esm', filePath));
|
||||
}
|
||||
|
||||
const languagesById = fromPairs(
|
||||
flatMap(toPairs(LANGUAGES), ([id, language]) =>
|
||||
[id].concat(language.alias || []).map((label) => [label, mixin({ label }, language)])
|
||||
)
|
||||
);
|
||||
const languagesById = mapValues(LANGUAGES, (language, id) => mixin({ label: id }, language));
|
||||
const featuresById = mapValues(FEATURES, (feature, key) => mixin({ label: key }, feature))
|
||||
|
||||
function getFeaturesIds(userFeatures, predefinedFeaturesById) {
|
||||
|
|
@ -66,7 +61,7 @@ class MonacoWebpackPlugin {
|
|||
const publicPath = getPublicPath(compiler);
|
||||
const modules = [EDITOR_MODULE].concat(languages).concat(features);
|
||||
const workers = modules.map(
|
||||
({ label, alias, worker }) => worker && (mixin({ label, alias }, worker))
|
||||
({ label, worker }) => worker && (mixin({ label }, worker))
|
||||
).filter(Boolean);
|
||||
const rules = createLoaderRules(languages, features, workers, output, publicPath);
|
||||
const plugins = createPlugins(workers, output);
|
||||
|
|
@ -156,10 +151,6 @@ function createPlugins(workers, outputPath) {
|
|||
);
|
||||
}
|
||||
|
||||
function flatMap(items, iteratee) {
|
||||
return items.map(iteratee).reduce((acc, item) => [].concat(acc).concat(item), []);
|
||||
}
|
||||
|
||||
function flatArr(items) {
|
||||
return items.reduce((acc, item) => {
|
||||
if (Array.isArray(item)) {
|
||||
|
|
@ -169,10 +160,6 @@ function flatArr(items) {
|
|||
}, []);
|
||||
}
|
||||
|
||||
function toPairs(object) {
|
||||
return Object.keys(object).map((key) => [key, object[key]]);
|
||||
}
|
||||
|
||||
function fromPairs(values) {
|
||||
return values.reduce((acc, [key, value]) => Object.assign(acc, { [key]: value }), {});
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue