From 97e25d10b84bdf52b2841ae619fc60cd8d6e7c0d Mon Sep 17 00:00:00 2001 From: Gusted Date: Wed, 24 Jul 2024 23:22:05 +0200 Subject: [PATCH] [CHORE] Don't bundle `elkjs` - `elkjs` is a library that's imported by `mermaid`, although they have seperated this package to it's own mermaid package (https://github.com/mermaid-js/mermaid/pull/5654), the stable version doesn't have this patch. - `elkjs` is licensed under the EPL-2.0 license (copyleft), which isn't compatible with GPL unless the license author explcitly allow this via a so called "secondary license". At the end of the day it cannot be released under a MIT or GPL license. - Use webpack's `externals` option to avoid bundling `elkjs` and instead leave it as a `require` code. - This is a 'dirty' way to ensure elkjs isn't bundled and has to be tested manually to ensure this for every release (via the `webpack-bundle-analyzer` plugin). If someone tries to use the elkjs render, it will result in a non-descriptive error being shown. (cherry picked from commit 510cbe2c92d1b7d6ace6ea0ca3ea44fd4a3904a1) --- webpack.config.js | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/webpack.config.js b/webpack.config.js index b6ecb29421..bc9b6ea9a5 100644 --- a/webpack.config.js +++ b/webpack.config.js @@ -73,6 +73,14 @@ const filterCssImport = (url, ...args) => { /** @type {import("webpack").Configuration} */ export default { + externals: [ + function ({request}, callback) { + if (/elkjs/.test(request)) { + return callback(null, `commonjs ${request}`); + } + callback(); + }, + ], mode: isProduction ? 'production' : 'development', entry: { index: [