Skip to content

Commit

Permalink
fix: change minimizer flags to follow AEgir
Browse files Browse the repository at this point in the history
This commit is a backport of ipfs/aegir#214

Default flags from webpack broke pubsub by removing 'unused'
experiments. This restores pubsub functionality and applies the fix for
entire build pipeline.
  • Loading branch information
lidel committed Jul 14, 2018
1 parent e19f231 commit 5e2c7bf
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 5 deletions.
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,8 @@
"web-ext": "2.7.0",
"webpack": "4.14.0",
"webpack-bundle-analyzer": "2.13.1",
"webpack-cli": "3.0.8"
"webpack-cli": "3.0.8",
"webpack-merge": "4.1.3"
},
"dependencies": {
"choo": "6.12.1",
Expand Down
23 changes: 19 additions & 4 deletions webpack.config.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
const path = require('path')
const webpack = require('webpack')
const merge = require('webpack-merge')
const SimpleProgressWebpackPlugin = require('simple-progress-webpack-plugin')
const UglifyJsPlugin = require('uglifyjs-webpack-plugin')
// const BundleAnalyzerPlugin = require('webpack-bundle-analyzer').BundleAnalyzerPlugin;

// common configuration shared by all targets
Expand All @@ -12,6 +14,19 @@ const commonConfig = {
publicPath: '/dist/bundles/',
filename: '[name].bundle.js'
},
optimization: {
minimizer: [
// Default flags breaks js-ipfs: https://github.com/ipfs-shipyard/ipfs-companion/issues/521
new UglifyJsPlugin({
parallel: true,
extractComments: true,
uglifyOptions: {
compress: { unused: false },
mangle: true
}
})
]
},
// plugins: [new BundleAnalyzerPlugin()]
plugins: [
new SimpleProgressWebpackPlugin({
Expand Down Expand Up @@ -47,7 +62,7 @@ const commonConfig = {
}

// background page bundle (with heavy dependencies)
const bgConfig = Object.assign({}, commonConfig, {
const bgConfig = merge(commonConfig, {
name: 'background',
entry: {
backgroundPage: './add-on/src/background/background.js'
Expand All @@ -71,7 +86,7 @@ const bgConfig = Object.assign({}, commonConfig, {
})

// user interface pages with shared common libraries
const uiConfig = Object.assign({}, commonConfig, {
const uiConfig = merge(commonConfig, {
name: 'ui',
entry: {
browserAction: './add-on/src/popup/browser-action/index.js',
Expand Down Expand Up @@ -100,7 +115,7 @@ const uiConfig = Object.assign({}, commonConfig, {
})

// content scripts injected into tabs
const contentScriptsConfig = Object.assign({}, commonConfig, {
const contentScriptsConfig = merge(commonConfig, {
name: 'contentScripts',
entry: {
ipfsProxyContentScriptPayload: './add-on/src/contentScripts/ipfs-proxy/page.js',
Expand All @@ -111,7 +126,7 @@ const contentScriptsConfig = Object.assign({}, commonConfig, {

// special content script that injects window.ipfs into REAL window object
// (by default scripts executed via tabs.executeScript get a sandbox version)
const proxyContentScriptConfig = Object.assign({}, commonConfig, {
const proxyContentScriptConfig = merge(commonConfig, {
name: 'proxyContentScript',
dependencies: ['contentScripts'],
entry: {
Expand Down
6 changes: 6 additions & 0 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -10726,6 +10726,12 @@ [email protected]:
v8-compile-cache "^2.0.0"
yargs "^11.1.0"

[email protected]:
version "4.1.3"
resolved "https://registry.yarnpkg.com/webpack-merge/-/webpack-merge-4.1.3.tgz#8aaff2108a19c29849bc9ad2a7fd7fce68e87c4a"
dependencies:
lodash "^4.17.5"

webpack-sources@^1.0.1, webpack-sources@^1.1.0:
version "1.1.0"
resolved "https://registry.yarnpkg.com/webpack-sources/-/webpack-sources-1.1.0.tgz#a101ebae59d6507354d71d8013950a3a8b7a5a54"
Expand Down

0 comments on commit 5e2c7bf

Please sign in to comment.