Skip to content

Commit

Permalink
Use webpack externals to exclude dependencies (#3036)
Browse files Browse the repository at this point in the history
  • Loading branch information
absidue authored Jan 7, 2023
1 parent dd40493 commit fe85a17
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 11 deletions.
8 changes: 4 additions & 4 deletions _scripts/webpack.renderer.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,10 @@ const config = {
path: path.join(__dirname, '../dist'),
filename: '[name].js',
},
externals: {
// ignore linkedom's unnecessary broken canvas import, as youtubei.js only uses linkedom to generate DASH manifests
canvas: '{}'
},
module: {
rules: [
{
Expand Down Expand Up @@ -122,10 +126,6 @@ const config = {
new MiniCssExtractPlugin({
filename: isDevMode ? '[name].css' : '[name].[contenthash].css',
chunkFilename: isDevMode ? '[id].css' : '[id].[contenthash].css',
}),
// ignore linkedom's unnecessary broken canvas import, as youtubei.js only uses linkedom to generate DASH manifests
new webpack.IgnorePlugin({
resourceRegExp: /^canvas$/
})
],
resolve: {
Expand Down
18 changes: 11 additions & 7 deletions _scripts/webpack.web.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,17 @@ const config = {
path: path.join(__dirname, '../dist/web'),
filename: '[name].js',
},
externals: {
electron: '{}'
},
externals: [
{
electron: '{}'
},
({ request }, callback) => {
if (request.startsWith('youtubei.js')) {
return callback(null, '{}')
}
callback()
}
],
module: {
rules: [
{
Expand Down Expand Up @@ -122,10 +130,6 @@ const config = {
new MiniCssExtractPlugin({
filename: isDevMode ? '[name].css' : '[name].[contenthash].css',
chunkFilename: isDevMode ? '[id].css' : '[id].[contenthash].css',
}),
// ignore all youtubei.js imports, even the ones with paths in them
new webpack.IgnorePlugin({
resourceRegExp: /^youtubei\.js/
})
],
resolve: {
Expand Down

0 comments on commit fe85a17

Please sign in to comment.