Fix webpack compile warning for editor_lite
webpack-internal:///2CTa 125:8 "[WDS] Warnings while compiling."
webpack-internal:///2CTa 134:10 "./editor/editor_lite.js 59:13-29\nCritical dependency: the request of a dependency is an expression"
This refers to the following line in source_editor.js:
static pushToImportsArray(arr, toImport) {
arr.push(import(toImport));
}
Webpack throws a warning here because it cannot statically analyze this import. Literally any string could be assigned to toImport and webpack cannot create a dynamically loadable chunk to represent all possible values.
See: https://webpack.js.org/api/module-methods/#dynamic-expressions-in-import
Webpack is smart enough to allow dynamically generated import() paths if you give it some hints. I would recommend something like:
import(`./extensions/${extension}`);
Or you could use the webpackInclude magic comment with something like:
arr.push(import(
/* webpackInclude: /^.\/extensions\// */
toImport
));
(I have not tested this)
/cc @dmishunov @leipert
Edited by Lukas Eipert