Skip to content

Commit

Permalink
[CHORE] Don't bundle elkjs
Browse files Browse the repository at this point in the history
- `elkjs` is a library that's imported by `mermaid`, although they have
seperated this package to it's own mermaid
package (mermaid-js/mermaid#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 510cbe2)
  • Loading branch information
Gusted authored Jul 25, 2024
1 parent c8b6e07 commit e362e08
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions webpack.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -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: [
Expand Down

0 comments on commit e362e08

Please sign in to comment.