-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #415 from soramitsu/fix-tree-shaking
Fix tree shaking
- Loading branch information
Showing
75 changed files
with
1,423 additions
and
1,364 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
--- | ||
'@soramitsu-ui/ui': minor | ||
--- | ||
|
||
**feat**: make library tree-shakeable, e.g. free from side-effects! |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
--- | ||
'@soramitsu-ui/ui': patch | ||
--- | ||
|
||
**refactor**(`SModal`): use `StyleValue` type for style props (`rootStyle`, `modalStyle` etc) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
--- | ||
'@soramitsu-ui/ui': minor | ||
--- | ||
|
||
**BREAKING**(`SModal`): drop opinionated usage of `body-scroll-lock`, provide an unopinionated solution. | ||
|
||
**What is the change:** there is a new component - `SBodyScrollLockProvider`: | ||
|
||
```vue | ||
<script setup> | ||
import { SModal, SBodyScrollLockProvider, BodyScrollLockApi } from '@soramitsu-ui/ui' | ||
import { enableBodyScroll, disableBodyScroll } from 'body-scroll-lock' | ||
const lockApi: BodyScrollLockApi = { | ||
lock: (el) => { | ||
disableBodyScroll(el) | ||
}, | ||
unlock: (el) => { | ||
enableBodyScroll(el) | ||
}, | ||
} | ||
</script> | ||
<template> | ||
<SBodyScrollLockProvider :api="lockApi"> | ||
<!-- Modal uses provided API --> | ||
<SModal /> | ||
</SBodyScrollLockProvider> | ||
</template> | ||
``` | ||
|
||
`SModal` prop `lockScroll` now is just a boolean which _reactively_ controls whether it should use provided API (if there is some) or not. | ||
|
||
**Why the change was made:** `body-scroll-lock` has little side-effects, thus it is not fully tree-shakeable. | ||
|
||
**How to migrate:** if you use `SModal`, you should now use `SBodyScrollLockProvider` if you need to lock the scroll. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
--- | ||
'@soramitsu-ui/ui': minor | ||
--- | ||
|
||
**BREAKING**: change exported enums format. | ||
|
||
**What is the change.** Previously enums was defined as plain TypeScript enums: | ||
|
||
```ts | ||
enum Status { | ||
Info = 'info', | ||
} | ||
``` | ||
|
||
Now we define enums as follows: | ||
|
||
```ts | ||
const Status = { | ||
Info: 'info', | ||
} as const | ||
|
||
type Status = typeof Status[keyof typeof Status] | ||
``` | ||
**Why the change was made:** it turned out that TypeScript enums are not tree-shakeable because they are compiled into IIFE. | ||
**How to migrate** - you don't need to do anything except of some cases: | ||
- If you use some enum variant as a type, e.g. | ||
```ts | ||
function acceptOnlyInfo(status: Status.Info) {} | ||
``` | ||
|
||
then you should add `typeof`: | ||
|
||
```ts | ||
function acceptOnlyInfo(status: typeof Status.Info) {} | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
--- | ||
'@soramitsu-ui/ui': minor | ||
--- | ||
|
||
**BREAKING**: exclude `SJsonInput` from the library bundle | ||
|
||
**Why.** It has dirty dependencies (`jsoneditor`, `lodash`) which prevented the library from being side-effect-free. Anyway, `SJsonInput` seems to be unused and out of our Design System. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,3 +2,4 @@ node_modules | |
dist | ||
dist-ts | ||
storybook-static | ||
/packages/ui/test/after-build/esm-tree-shaken-dist |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,7 @@ | ||
**/dist/** | ||
**/node_modules/** | ||
packages/ui/etc | ||
/packages/ui/etc | ||
/packages/ui/test/after-build/esm-tree-shaken-dist | ||
/packages/ui/cypress/screenshots | ||
CHANGELOG.md | ||
storybook-static |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.