Skip to content

Commit f065bb0

Browse files
committed
add minified js in dist.es5 and make it the default for AMD usage
1 parent ca1bea7 commit f065bb0

File tree

2 files changed

+18
-4
lines changed

2 files changed

+18
-4
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
"author": "The MessagePack community",
66
"license": "ISC",
77
"main": "./dist/index.js",
8-
"browser": "./dist.es5/msgpack.js",
8+
"browser": "./dist.es5/msgpack.min.js",
99
"types": "./dist/index.d.ts",
1010
"sideEffects": false,
1111
"scripts": {

webpack.config.ts

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,10 @@ const config = {
3434
new CheckEsVersionPlugin({
3535
esVersion: 5, // for IE11 support
3636
}),
37+
new webpack.DefinePlugin({
38+
"process.env.WASM": JSON.stringify(null), // use only MSGPACK_WASM
39+
"process.env.TEXT_ENCODING": JSON.stringify("null"),
40+
}),
3741
],
3842
externals: {
3943
"base64-js": {
@@ -55,14 +59,26 @@ const config = {
5559
};
5660

5761
export default [
62+
// default minified bundle does not includes wasm
63+
((config) => {
64+
config.output.filename = "msgpack.min.js";
65+
config.plugins.push(
66+
new webpack.DefinePlugin({
67+
"process.env.MSGPACK_WASM": JSON.stringify("never"),
68+
}),
69+
new webpack.IgnorePlugin(/\.\/dist\/wasm\/msgpack\.wasm\.js$/),
70+
);
71+
config.optimization.minimize = true;
72+
return config;
73+
})(_.cloneDeep(config)),
74+
5875
// default bundle does not includes wasm
5976
((config) => {
6077
config.output.filename = "msgpack.js";
6178
config.plugins.push(
6279
new webpack.DefinePlugin({
6380
// The default bundle does not includes WASM
6481
"process.env.MSGPACK_WASM": JSON.stringify("never"),
65-
"process.env.WASM": JSON.stringify(null),
6682
}),
6783
new webpack.IgnorePlugin(/\.\/dist\/wasm\/msgpack\.wasm\.js$/),
6884
);
@@ -74,9 +90,7 @@ export default [
7490
config.output.filename = "msgpack+wasm.js";
7591
config.plugins.push(
7692
new webpack.DefinePlugin({
77-
// The default bundle does not includes WASM
7893
"process.env.MSGPACK_WASM": JSON.stringify(null),
79-
"process.env.WASM": JSON.stringify(null),
8094
}),
8195
);
8296
return config;

0 commit comments

Comments
 (0)