bubble-dev / _

🍱 metarepo of many packages and various monorepos
52 stars 6 forks source link

♻️ update nanoid to v3 #339

Closed renovate[bot] closed 4 years ago

renovate[bot] commented 4 years ago

This PR contains the following updates:

Package Type Update Change
nanoid dependencies major ^2.1.7 -> ^3.0.0

Release Notes

ai/nanoid ### [`v3.0.0`](https://togithub.com/ai/nanoid/releases/3.0.0) [Compare Source](https://togithub.com/ai/nanoid/compare/2.1.11...3.0.0) Nano ID 3.0 is the biggest release in the project history. Unfortunately, you will need to change the code of your application. But the changes are very small in most cases. In return, you will have better performance, smaller size, ES modules and TypeScript support. #### Simple Case In simple cases, you just need to change default import to named import. ```diff - import nanoid from 'nanoid' + import { nanoid } from 'nanoid' nanoid() //=> "sSAi9F8yakJZPxOCr_WFb" nanoid(5) //=> "ISe9l" ``` If you support IE, you need to [transpile `node_modules` by Babel](https://developer.epages.com/blog/coding/how-to-transpile-node-modules-with-babel-and-webpack-in-a-monorepo/). Non-secure and asynchronous Nano ID need only import changes as well. ```diff - import nanoid from 'nanoid/non-secure' + import { nanoid } from 'nanoid/non-secure' nanoid() //=> "sSAi9F8yakJZPxOCr_WFb" ``` ```diff - import nanoid from 'nanoid/async' + import { nanoid } from 'nanoid/async' nanoid().then(id => { id //=> "sSAi9F8yakJZPxOCr_WFb" }) ``` #### React Native 1. Change polyfill for hardware random generator from `expo-random` to `react-native-get-random-values`. 2. Use sync Nano ID instead of async. ```diff + import 'react-native-get-random-values' - import nanoid from 'nanoid/async' + import { nanoid } from 'nanoid' async function createUser () { const user = new User() - user.id = await nanoid() + user.id = nanoid() return await user.save() } ``` ##### URL-Safe Alphabet Our default URL-safe alphabet was moved as named export to `nanoid` path: ```diff - import url from 'nanoid/url' + import { urlAlphabet } from 'nanoid' ``` #### Custom Alphabet Now we use the [currying API](https://blog.bitsrc.io/understanding-currying-in-javascript-ceb2188c339) to change the alphabet. It improves performance by pre-calculating some caches for a new alphabet. We hope the new API will be more readable compare to the old unclear “generate” word. ```diff - import nanoidGenerate from 'nanoid/generate' + import { customAlphabet } from 'nanoid' + const nanoid = customAlphabet(alphabet, 10) - nanoidGenerate(alphabet, 10) //=> "0476921501" + nanoid() //=> "0476921501" ``` Non-secure and asynchronous APIs were also changed: ```diff - import nanoidGenerate from 'nanoid/async/generate' + import { customAlphabet } from 'nanoid/async' + const nanoid = customAlphabet(alphabet, 10) ``` #### Custom Random Generator Custom random generator API now is based on [currying](https://blog.bitsrc.io/understanding-currying-in-javascript-ceb2188c339) as well. ```diff - import nanoidFormat from 'nanoid/format' - import url from 'nanoid/url' + import { customRandom, urlAlphabet } from 'nanoid' + const nanoid = customRandom(urlAlphabet, 10, seedRandom) - nanoidGenerate(seedRandom, url, 10) //=> "sSAi9F8yak" + nanoid() //=> "sSAi9F8yak" ``` We removed a custom random generator from asynchronous API because we didn’t see that somebody used it. #### New Features A few good reasons, why you should migrate to Nano ID 3.0: - The size was decreased by 10% from **119** to **108 bytes**. - We got full **TypeScript** support. We use [check-dts](https://togithub.com/ai/check-dts) to test out `.d.ts` files. ```ts id: number = nanoid() // throws Type 'string' is not assignable to type 'number'. ``` - Nano ID now has out-of-the-box **ES modules** support and extra file to load Nano ID from jsDelivr (use it only for experiments, because of the bad loading performance). Dual ESM/CommonJS packaging is provided by [dual-publish](https://togithub.com/ai/dual-publish/) and will work in Node.js ≥12, webpack, Parcel, Rollup, and React Native. ```js import { nanoid } from 'https://cdn.jsdelivr.net/npm/nanoid/nanoid.js' ```

Renovate configuration

:date: Schedule: At any time (no schedule defined).

:vertical_traffic_light: Automerge: Disabled by config. Please merge this manually once you are satisfied.

:recycle: Rebasing: Whenever PR becomes conflicted, or you tick the rebase/retry checkbox.

:no_bell: Ignore: Close this PR and you won't be reminded about this update again.



This PR has been generated by WhiteSource Renovate. View repository job log here.

renovate[bot] commented 4 years ago

Renovate Ignore Notification

As this PR has been closed unmerged, Renovate will ignore this upgrade and you will not receive PRs for any future 3.x releases. However, if you upgrade to 3.x manually then Renovate will then reenable updates for minor and patch updates automatically.

If this PR was closed by mistake or you changed your mind, you can simply rename this PR and you will soon get a fresh replacement PR opened.