Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use webpack externals to exclude dependencies #3036

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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