Skip to content

Commit 31820b9

Browse files
committed
fix: Added sideEffects field to package.json
See: https://webpack.js.org/guides/tree-shaking/ Summary, new sideEffects field helps with dead code elimination with webpack and helps build performance since it doesn't need to parse it with terser. I tested a really simple example in CRA that was just: ```diff import React from "react"; import logo from "./logo.svg"; +import { Button } from "react-md"; import "./App.css"; function App() { return ( <div className="App"> <header className="App-header"> <img src={logo} className="App-logo" alt="logo" /> <p> Edit <code>src/App.js</code> and save to reload. </p> + <Button>Hello</Button> ``` ```diff import React from "react"; import ReactDOM from "react-dom"; +import "react-md/dist/css/react-md.blue-teal-400-dark.min.css"; import "./index.css"; ``` Where I'd build with and without the react-md styles being imported. I think these stats will be negligible once more components are being used, but here's the few results with my MacBook. Current build stats: ```sh # without css # average build time ~12s File sizes after gzip: 205.54 KB build/static/js/2.646bee91.chunk.js 777 B build/static/js/runtime-main.b9cd606a.js 682 B build/static/js/main.909a8f83.chunk.js 547 B build/static/css/main.5f361e03.chunk.css ``` ```sh # with css # average build time ~13s File sizes after gzip: 205.54 KB build/static/js/2.06a718b5.chunk.js 15.84 KB build/static/css/2.c416ebf1.chunk.css 777 B build/static/js/runtime-main.b9cd606a.js 685 B build/static/js/main.5a2d7e96.chunk.js 547 B build/static/css/main.5f361e03.chunk.css ``` With `"sideEffects": ["dist/**/*"]`: ```sh # without css # average build time ~8s File sizes after gzip: 45.79 KB (-159.75 KB) build/static/js/2.5e21dda9.chunk.js 777 B build/static/js/runtime-main.b9cd606a.js 672 B (-10 B) build/static/js/main.5c471371.chunk.js 547 B build/static/css/main.5f361e03.chunk.css # stats compared to previous without css build ``` ```sh # with css # average build time ~9 File sizes after gzip: 45.8 KB (-159.75 KB) build/static/js/2.043fb57c.chunk.js 15.84 KB build/static/css/2.c416ebf1.chunk.css 777 B build/static/js/runtime-main.b9cd606a.js 673 B (-12 B) build/static/js/main.5e1aaad3.chunk.js 547 B build/static/css/main.5f361e03.chunk.css # stats compared to previous with css build ```
1 parent d0efc59 commit 31820b9

File tree

34 files changed

+34
-0
lines changed

34 files changed

+34
-0
lines changed

packages/alert/package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
"main": "./lib/index.js",
1010
"module": "./es/index.js",
1111
"types": "./types/index.d.ts",
12+
"sideEffects": ["dist/**/*"],
1213
"files": [
1314
"es/*",
1415
"lib/*",

packages/app-bar/package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
"main": "./lib/index.js",
1010
"module": "./es/index.js",
1111
"types": "./types/index.d.ts",
12+
"sideEffects": ["dist/**/*"],
1213
"files": [
1314
"es/*",
1415
"lib/*",

packages/autocomplete/package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
"main": "./lib/index.js",
1010
"module": "./es/index.js",
1111
"types": "./types/index.d.ts",
12+
"sideEffects": ["dist/**/*"],
1213
"files": [
1314
"es/*",
1415
"lib/*",

packages/avatar/package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
"main": "./lib/index.js",
1010
"module": "./es/index.js",
1111
"types": "./types/index.d.ts",
12+
"sideEffects": ["dist/**/*"],
1213
"files": [
1314
"es/*",
1415
"lib/*",

packages/badge/package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
"main": "./lib/index.js",
1010
"module": "./es/index.js",
1111
"types": "./types/index.d.ts",
12+
"sideEffects": ["dist/**/*"],
1213
"files": [
1314
"es/*",
1415
"lib/*",

packages/button/package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
"main": "./lib/index.js",
1010
"module": "./es/index.js",
1111
"types": "./types/index.d.ts",
12+
"sideEffects": ["dist/**/*"],
1213
"files": [
1314
"es/*",
1415
"lib/*",

packages/card/package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
"main": "./lib/index.js",
1010
"module": "./es/index.js",
1111
"types": "./types/index.d.ts",
12+
"sideEffects": ["dist/**/*"],
1213
"files": [
1314
"es/*",
1415
"lib/*",

packages/chip/package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
"main": "./lib/index.js",
1010
"module": "./es/index.js",
1111
"types": "./types/index.d.ts",
12+
"sideEffects": ["dist/**/*"],
1213
"files": [
1314
"es/*",
1415
"lib/*",

packages/dialog/package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
"main": "./lib/index.js",
1010
"module": "./es/index.js",
1111
"types": "./types/index.d.ts",
12+
"sideEffects": ["dist/**/*"],
1213
"files": [
1314
"es/*",
1415
"lib/*",

packages/divider/package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
"main": "./lib/index.js",
1010
"module": "./es/index.js",
1111
"types": "./types/index.d.ts",
12+
"sideEffects": ["dist/**/*"],
1213
"files": [
1314
"es/*",
1415
"lib/*",

0 commit comments

Comments
 (0)