Skip to content

Commit 89b5f3a

Browse files
authored
chore(starters): add sideEffects: false to the lib template 🍟 (#7855)
1 parent 9d8d222 commit 89b5f3a

File tree

3 files changed

+15
-1
lines changed

3 files changed

+15
-1
lines changed
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'create-qwik': patch
3+
---
4+
5+
FIX: set sideEffects: false to the lib template, otherwise there might be some side effects imports when building a consumer project.

β€Žstarters/apps/library/README.mdβ€Ž

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,3 +45,11 @@ The production build should generate the production build of your component libr
4545
```
4646
npm run build
4747
```
48+
49+
## sideEffects: false
50+
51+
This package is configured with "sideEffects": false in its package.json.<br/>
52+
This tells bundlers that the module [has no side effects](https://webpack.js.org/guides/tree-shaking/#mark-the-file-as-side-effect-free) when imported.<br/>
53+
Consequently, to maintain the integrity of tree-shaking optimizations, please ensure your code truly contains no side effects (such as modifying global variables or the DOM upon import).<br/>
54+
If your module does introduce side effects, remove "sideEffects": false or specify the specific files with side effects.<br/>
55+
Be sure to only remove it from the specific file where the global is being set. Finally, verify that your build continues to function as expected after making any adjustments to the sideEffects setting.

β€Žstarters/apps/library/package.jsonβ€Ž

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,5 +53,6 @@
5353
"docs": [
5454
"https://qwik.dev/docs/getting-started/"
5555
]
56-
}
56+
},
57+
"sideEffects": false
5758
}

0 commit comments

Comments
Β (0)