Skip to content

Commit

Permalink
Remove process.env.NODE_ENV
Browse files Browse the repository at this point in the history
  • Loading branch information
ai committed Feb 16, 2022
1 parent ee7dee3 commit 368a6e7
Show file tree
Hide file tree
Showing 5 changed files with 3 additions and 49 deletions.
5 changes: 1 addition & 4 deletions README.id-ID.md
Original file line number Diff line number Diff line change
Expand Up @@ -313,15 +313,12 @@ import { nanoid } from 'nanoid'

### Rollup

Untuk Rollup, dibutuhkan [`@rollup/plugin-node-resolve`](https://github.com/rollup/plugins/tree/master/packages/node-resolve) untuk versi browser dan [`@rollup/plugin-replace`](https://github.com/rollup/plugins/tree/master/packages/replace) untuk menggantikan `process.env.NODE_ENV`.
Untuk Rollup, dibutuhkan [`@rollup/plugin-node-resolve`](https://github.com/rollup/plugins/tree/master/packages/node-resolve) untuk versi browser.

```js
plugins: [
nodeResolve({
browser: true
}),
replace({
'process.env.NODE_ENV': JSON.stringify(process.env.NODE_ENV)
})
]
```
Expand Down
7 changes: 1 addition & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -405,22 +405,17 @@ import { nanoid } from 'nanoid'
### Rollup

For Rollup you will need [`@rollup/plugin-node-resolve`] to bundle browser version
of this library and [`@rollup/plugin-replace`] to replace
`process.env.NODE_ENV`:
of this library.:

```js
plugins: [
nodeResolve({
browser: true
}),
replace({
'process.env.NODE_ENV': JSON.stringify(process.env.NODE_ENV)
})
]
```

[`@rollup/plugin-node-resolve`]: https://github.com/rollup/plugins/tree/master/packages/node-resolve
[`@rollup/plugin-replace`]: https://github.com/rollup/plugins/tree/master/packages/replace


### PouchDB and CouchDB
Expand Down
7 changes: 1 addition & 6 deletions README.ru.md
Original file line number Diff line number Diff line change
Expand Up @@ -392,22 +392,17 @@ import { nanoid } from 'nanoid'

### Rollup

Для Rollup понадобятся плагины [`@rollup/plugin-node-resolve`]
и [`@rollup/plugin-replace`].
Для Rollup понадобятся плагины [`@rollup/plugin-node-resolve`].

```js
plugins: [
nodeResolve({
browser: true
}),
replace({
'process.env.NODE_ENV': JSON.stringify(process.env.NODE_ENV)
})
]
```

[`@rollup/plugin-node-resolve`]: https://github.com/rollup/plugins/tree/master/packages/node-resolve
[`@rollup/plugin-replace`]: https://github.com/rollup/plugins/tree/master/packages/replace


### PouchDB и CouchDB
Expand Down
5 changes: 0 additions & 5 deletions README.zh-CN.md
Original file line number Diff line number Diff line change
Expand Up @@ -383,21 +383,16 @@ import { nanoid } from 'nanoid'
### Rollup

对于 Rollup 来说,你需要 [`@rollup/plugin-node-resolve`] 来绑定浏览器版本。
除了这个库,还需要 [`@rollup/plugin-replace`] 来替换 `process.env.NODE_ENV`

```js
plugins: [
nodeResolve({
browser: true
}),
replace({
'process.env.NODE_ENV': JSON.stringify(process.env.NODE_ENV)
})
]
```

[`@rollup/plugin-node-resolve`]: https://github.com/rollup/plugins/tree/master/packages/node-resolve
[`@rollup/plugin-replace`]: https://github.com/rollup/plugins/tree/master/packages/replace


### PouchDB and CouchDB
Expand Down
28 changes: 0 additions & 28 deletions index.browser.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,34 +3,6 @@

let { urlAlphabet } = require('./url-alphabet')

if (process.env.NODE_ENV !== 'production') {
// All bundlers will remove this block in the production bundle.
if (
typeof navigator !== 'undefined' &&
navigator.product === 'ReactNative' &&
typeof crypto === 'undefined'
) {
throw new Error(
'React Native does not have a built-in secure random generator. ' +
'If you don’t need unpredictable IDs use `nanoid/non-secure`. ' +
'For secure IDs, import `react-native-get-random-values` ' +
'before Nano ID.'
)
}
if (typeof msCrypto !== 'undefined' && typeof crypto === 'undefined') {
throw new Error(
'Import file with `if (!window.crypto) window.crypto = window.msCrypto`' +
' before importing Nano ID to fix IE 11 support'
)
}
if (typeof crypto === 'undefined') {
throw new Error(
'Your browser does not have secure random generator. ' +
'If you don’t need unpredictable IDs, you can use nanoid/non-secure.'
)
}
}

let random = bytes => crypto.getRandomValues(new Uint8Array(bytes))

let customRandom = (alphabet, defaultSize, getRandom) => {
Expand Down

0 comments on commit 368a6e7

Please sign in to comment.