Skip to content

Commit 46cd1d5

Browse files
committed
Minor build fixes after tsup migration
1 parent d5be8f2 commit 46cd1d5

File tree

9 files changed

+17
-19
lines changed

9 files changed

+17
-19
lines changed

jest.config.build.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
module.exports = {
22
moduleNameMapper: {
3-
"src/.*": "<rootDir>/dist/immer.cjs.production.min.js"
3+
"src/.*": "<rootDir>/dist/cjs/immer.cjs.production.js"
44
},
55
testEnvironmentOptions: {
66
url: "http://localhost"

jest.config.js

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,6 @@ module.exports = {
22
testEnvironmentOptions: {
33
url: "http://localhost"
44
},
5-
globals: {
6-
__DEV__: true
7-
},
85
preset: "ts-jest/presets/js-with-ts",
96
testEnvironment: "node",
107
testMatch: ["**/__tests__/**/*.[jt]s?(x)"]

package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,10 +17,11 @@
1717
"types": "./dist/immer.d.ts",
1818
"sideEffects": false,
1919
"scripts": {
20+
"pretest": "yarn build",
2021
"test": "jest && yarn test:build && yarn test:flow",
2122
"test:perf": "cd __performance_tests__ && node add-data.mjs && node todo.mjs && node incremental.mjs && node large-obj.mjs",
2223
"test:flow": "yarn flow check __tests__/flow",
23-
"test:build": "yarn build && NODE_ENV='production' yarn jest --config jest.config.build.js",
24+
"test:build": "NODE_ENV='production' yarn jest --config jest.config.build.js",
2425
"watch": "jest --watch",
2526
"coverage": "jest --coverage",
2627
"coveralls": "jest --coverage && cat ./coverage/lcov.info | ./node_modules/.bin/coveralls && rm -rf ./coverage",

src/core/finalize.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,7 @@ function finalizeProperty(
116116
rootPath?: PatchPath,
117117
targetIsSet?: boolean
118118
) {
119-
if (process.env.NODE_ENV === "development" && childValue === targetObject)
119+
if (process.env.NODE_ENV !== "production" && childValue === targetObject)
120120
die(5)
121121
if (isDraft(childValue)) {
122122
const path =

src/core/proxy.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -221,14 +221,14 @@ each(objectTraps, (key, fn) => {
221221
}
222222
})
223223
arrayTraps.deleteProperty = function(state, prop) {
224-
if (process.env.NODE_ENV === "development" && isNaN(parseInt(prop as any)))
224+
if (process.env.NODE_ENV !== "production" && isNaN(parseInt(prop as any)))
225225
die(13)
226226
// @ts-ignore
227227
return arrayTraps.set!.call(this, state, prop, undefined)
228228
}
229229
arrayTraps.set = function(state, prop, value) {
230230
if (
231-
process.env.NODE_ENV === "development" &&
231+
process.env.NODE_ENV !== "production" &&
232232
prop !== "length" &&
233233
isNaN(parseInt(prop as any))
234234
)

src/plugins/patches.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ import {
2525

2626
export function enablePatches() {
2727
const errorOffset = 16
28-
if (process.env.NODE_ENV === "development") {
28+
if (process.env.NODE_ENV !== "production") {
2929
errors.push(
3030
'Sets cannot have "replace" patches.',
3131
function(op: string) {

src/utils/errors.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
export const errors =
2-
process.env.NODE_ENV === "development"
2+
process.env.NODE_ENV !== "production"
33
? [
44
// All error codes, starting by 0:
55
function(plugin: string) {
@@ -37,7 +37,7 @@ export const errors =
3737
: []
3838

3939
export function die(error: number, ...args: any[]): never {
40-
if (process.env.NODE_ENV === "development") {
40+
if (process.env.NODE_ENV !== "production") {
4141
const e = errors[error]
4242
const msg = typeof e === "function" ? e.apply(null, args as any) : e
4343
throw new Error(`[Immer] ${msg}`)

website/docs/installation.mdx

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -63,10 +63,10 @@ Import size report for immer:
6363
┌───────────────────────┬───────────┬────────────┬───────────┐
6464
│ (index) │ just this │ cumulative │ increment │
6565
├───────────────────────┼───────────┼────────────┼───────────┤
66-
│ import * from 'immer' │ 5873 │ 0 │ 0 │
67-
│ produce │ 34213421 │ 0 │
68-
│ enableMapSet │ 483748451424
69-
│ enablePatches │ 42405655810
66+
│ import * from 'immer' │ 5033 │ 0 │ 0 │
67+
│ produce │ 33243324 │ 0 │
68+
│ enableMapSet │ 40304039 715
69+
│ enablePatches │ 41124826787
7070
└───────────────────────┴───────────┴────────────┴───────────┘
7171
(this report was generated by npmjs.com/package/import-size)
7272
```

website/i18n/zh-CN/docusaurus-plugin-content-docs/current/installation.mdx

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -64,10 +64,10 @@ Import size report for immer:
6464
┌───────────────────────┬───────────┬────────────┬───────────┐
6565
│ (index) │ just this │ cumulative │ increment │
6666
├───────────────────────┼───────────┼────────────┼───────────┤
67-
│ import * from 'immer' │ 5873 │ 0 │ 0 │
68-
│ produce │ 34213421 │ 0 │
69-
│ enableMapSet │ 483748451424
70-
│ enablePatches │ 42405655810
67+
│ import * from 'immer' │ 5033 │ 0 │ 0 │
68+
│ produce │ 33243324 │ 0 │
69+
│ enableMapSet │ 40304039 715
70+
│ enablePatches │ 41124826787
7171
└───────────────────────┴───────────┴────────────┴───────────┘
7272
(this report was generated by npmjs.com/package/import-size)
7373
```

0 commit comments

Comments
 (0)