Skip to content

Commit

Permalink
fix: scanoss bundling
Browse files Browse the repository at this point in the history
scanoss depends on node-fetch <3. node-fetch in that version fails
their instance checks, as it relies on constructor/class names which
are removed by the backend bundling.

Customizes the webpack configurations to keep the class name for
'AbortSignal' as this is the one failing the check.
  • Loading branch information
sdirix authored and jfaltermeier committed Dec 19, 2024
1 parent b71db15 commit bf1a479
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 3 deletions.
18 changes: 18 additions & 0 deletions applications/browser/webpack.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ const configs = require('./gen-webpack.config.js');
const nodeConfig = require('./gen-webpack.node.config.js');
const path = require('path');
const CopyWebpackPlugin = require('copy-webpack-plugin');
const TerserPlugin = require('terser-webpack-plugin');

/**
* Expose bundled modules on window.theia.moduleName namespace, e.g.
Expand All @@ -31,6 +32,23 @@ configs[0].plugins.push(
})
);

/**
* Do no run TerserPlugin with parallel: true
* Each spawned node may take the full memory configured via NODE_OPTIONS / --max_old_space_size
* In total this may lead to OOM issues
*/
if (nodeConfig.config.optimization) {
nodeConfig.config.optimization.minimizer = [
new TerserPlugin({
parallel: false,
exclude: /^(lib|builtins)\//,
terserOptions: {
keep_classnames: /AbortSignal/
}
})
];
}

module.exports = [
...configs,
nodeConfig.config
Expand Down
9 changes: 6 additions & 3 deletions applications/electron/webpack.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,16 +16,19 @@ configs[0].module.rules.push({
loader: require.resolve('@theia/application-manager/lib/expose-loader')
}); */

/**
/**
* Do no run TerserPlugin with parallel: true
* Each spawned node may take the full memory configured via NODE_OPTIONS / --max_old_space_size
* In total this may lead to OOM issues
*/
*/
if (nodeConfig.config.optimization) {
nodeConfig.config.optimization.minimizer = [
new TerserPlugin({
parallel: false,
exclude: /^(lib|builtins)\//
exclude: /^(lib|builtins)\//,
terserOptions: {
keep_classnames: /AbortSignal/
}
})
];
}
Expand Down

0 comments on commit bf1a479

Please sign in to comment.