Skip to content

Commit 76e8bd5

Browse files
authored
fix(fuselage): development mode not being pruned (#1078)
1 parent 3e505b2 commit 76e8bd5

File tree

3 files changed

+26
-2
lines changed

3 files changed

+26
-2
lines changed

packages/fuselage/package.json

+2-1
Original file line numberDiff line numberDiff line change
@@ -135,7 +135,8 @@
135135
"typescript": "~5.0.4",
136136
"webpack": "~5.78.0",
137137
"webpack-bundle-analyzer": "~4.8.0",
138-
"webpack-cli": "~5.0.1"
138+
"webpack-cli": "~5.0.1",
139+
"wrapper-webpack-plugin": "~2.2.2"
139140
},
140141
"volta": {
141142
"extends": "../../package.json"

packages/fuselage/webpack.config.js

+14-1
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ const path = require('path');
44

55
const webpack = require('webpack');
66
const { BundleAnalyzerPlugin } = require('webpack-bundle-analyzer');
7+
const WrapperPlugin = require('wrapper-webpack-plugin');
78

89
const pkg = require('./package.json');
910

@@ -117,5 +118,17 @@ module.exports = (env, { mode = 'production' }) => ({
117118
reportFilename: '../bundle-report.html',
118119
openAnalyzer: false,
119120
}),
120-
],
121+
122+
mode !== 'production' &&
123+
new WrapperPlugin({
124+
test: /development\.js$/, // only wrap output of bundle files with '.js' extension
125+
header: `'use strict';
126+
127+
if (process.env.NODE_ENV !== "production") {
128+
(function() {
129+
`,
130+
footer: `\n})();
131+
}`,
132+
}),
133+
].filter(Boolean),
121134
});

yarn.lock

+10
Original file line numberDiff line numberDiff line change
@@ -5804,6 +5804,7 @@ __metadata:
58045804
webpack: ~5.78.0
58055805
webpack-bundle-analyzer: ~4.8.0
58065806
webpack-cli: ~5.0.1
5807+
wrapper-webpack-plugin: ~2.2.2
58075808
peerDependencies:
58085809
"@rocket.chat/fuselage-hooks": "*"
58095810
"@rocket.chat/fuselage-polyfills": "*"
@@ -27606,6 +27607,15 @@ fsevents@^1.2.7:
2760627607
languageName: node
2760727608
linkType: hard
2760827609

27610+
"wrapper-webpack-plugin@npm:~2.2.2":
27611+
version: 2.2.2
27612+
resolution: "wrapper-webpack-plugin@npm:2.2.2"
27613+
peerDependencies:
27614+
webpack: ">=2"
27615+
checksum: 1125a86c0cc0a043bbf9b51d340272b58aa5fc61758ba84faee9f05fe5024840ffda568d733ce4efc8b8523282a46cde3119e796823aa2047e45eafae4d5cc29
27616+
languageName: node
27617+
linkType: hard
27618+
2760927619
"wrappy@npm:1":
2761027620
version: 1.0.2
2761127621
resolution: "wrappy@npm:1.0.2"

0 commit comments

Comments
 (0)