Skip to content

Commit

Permalink
Only apply "sideEffects: false" to babel-loader; (#1671)
Browse files Browse the repository at this point in the history
* Only apply "sideEffects: false" to `babel-loader`;

Applying it as default breaks SASS imports because webpack thinks it can be tree-shaked

* Import "stop" from old-browsers-message to avoid cleaning it up by tree-shaking

* Add CHANGELOG entry for "sideEffect" story
  • Loading branch information
Andrey Skladchikov authored Feb 6, 2020
1 parent 47da176 commit 6afcd03
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 1 deletion.
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
## [2.1.20]

The JS part of Ring UI package is now marked as "sideEffect free". This means that webpack will [tree-shake](https://webpack.js.org/guides/tree-shaking/) unused imports of Ring UI files.
Theoretically this may be breaking change, but we don't know any real case yet. We consider advantages of this change are more important
than potential disadvantages.

## [2.0.2]

- Due to deprecation, `postcss-cssnext` has been replaced with `postcss-preset-env`.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import './old-browsers-message.css';
import './old-browsers-message';
import {stop} from './old-browsers-message';

export default {
title: 'Style-only/Old Browsers Message',
Expand All @@ -17,6 +17,7 @@ Once loaded, it attaches a global error handler. When your app finishes loading
export const basic = () => {
function triggerGlobalError() {
Object.unknownMethodToTriggerOldBrowsersMessage();
setTimeout(stop);
}

setTimeout(triggerGlobalError);
Expand Down
1 change: 1 addition & 0 deletions webpack.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,7 @@ const externalCssLoader = {

const babelLoader = {
test: /\.js$/,
sideEffects: false,
include: componentsPath,
loader: require.resolve('babel-loader'),
options: {
Expand Down

0 comments on commit 6afcd03

Please sign in to comment.