From 8aa2205ff3e685015c071347cfaeee9d92657ab9 Mon Sep 17 00:00:00 2001 From: Alexandru Dima Date: Wed, 18 Dec 2019 12:09:59 +0100 Subject: [PATCH] Simplify code since alias is no longer used --- index.js | 17 ++--------------- 1 file changed, 2 insertions(+), 15 deletions(-) diff --git a/index.js b/index.js index 905e6b47..92dcf809 100644 --- a/index.js +++ b/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 }), {}); }