Skip to content

Commit

Permalink
Minor build fixes after tsup migration
Browse files Browse the repository at this point in the history
  • Loading branch information
mweststrate committed Apr 15, 2023
1 parent d5be8f2 commit 46cd1d5
Show file tree
Hide file tree
Showing 9 changed files with 17 additions and 19 deletions.
2 changes: 1 addition & 1 deletion jest.config.build.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
module.exports = {
moduleNameMapper: {
"src/.*": "<rootDir>/dist/immer.cjs.production.min.js"
"src/.*": "<rootDir>/dist/cjs/immer.cjs.production.js"
},
testEnvironmentOptions: {
url: "http://localhost"
Expand Down
3 changes: 0 additions & 3 deletions jest.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,6 @@ module.exports = {
testEnvironmentOptions: {
url: "http://localhost"
},
globals: {
__DEV__: true
},
preset: "ts-jest/presets/js-with-ts",
testEnvironment: "node",
testMatch: ["**/__tests__/**/*.[jt]s?(x)"]
Expand Down
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,11 @@
"types": "./dist/immer.d.ts",
"sideEffects": false,
"scripts": {
"pretest": "yarn build",
"test": "jest && yarn test:build && yarn test:flow",
"test:perf": "cd __performance_tests__ && node add-data.mjs && node todo.mjs && node incremental.mjs && node large-obj.mjs",
"test:flow": "yarn flow check __tests__/flow",
"test:build": "yarn build && NODE_ENV='production' yarn jest --config jest.config.build.js",
"test:build": "NODE_ENV='production' yarn jest --config jest.config.build.js",
"watch": "jest --watch",
"coverage": "jest --coverage",
"coveralls": "jest --coverage && cat ./coverage/lcov.info | ./node_modules/.bin/coveralls && rm -rf ./coverage",
Expand Down
2 changes: 1 addition & 1 deletion src/core/finalize.ts
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ function finalizeProperty(
rootPath?: PatchPath,
targetIsSet?: boolean
) {
if (process.env.NODE_ENV === "development" && childValue === targetObject)
if (process.env.NODE_ENV !== "production" && childValue === targetObject)
die(5)
if (isDraft(childValue)) {
const path =
Expand Down
4 changes: 2 additions & 2 deletions src/core/proxy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -221,14 +221,14 @@ each(objectTraps, (key, fn) => {
}
})
arrayTraps.deleteProperty = function(state, prop) {
if (process.env.NODE_ENV === "development" && isNaN(parseInt(prop as any)))
if (process.env.NODE_ENV !== "production" && isNaN(parseInt(prop as any)))
die(13)
// @ts-ignore
return arrayTraps.set!.call(this, state, prop, undefined)
}
arrayTraps.set = function(state, prop, value) {
if (
process.env.NODE_ENV === "development" &&
process.env.NODE_ENV !== "production" &&
prop !== "length" &&
isNaN(parseInt(prop as any))
)
Expand Down
2 changes: 1 addition & 1 deletion src/plugins/patches.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ import {

export function enablePatches() {
const errorOffset = 16
if (process.env.NODE_ENV === "development") {
if (process.env.NODE_ENV !== "production") {
errors.push(
'Sets cannot have "replace" patches.',
function(op: string) {
Expand Down
4 changes: 2 additions & 2 deletions src/utils/errors.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
export const errors =
process.env.NODE_ENV === "development"
process.env.NODE_ENV !== "production"
? [
// All error codes, starting by 0:
function(plugin: string) {
Expand Down Expand Up @@ -37,7 +37,7 @@ export const errors =
: []

export function die(error: number, ...args: any[]): never {
if (process.env.NODE_ENV === "development") {
if (process.env.NODE_ENV !== "production") {
const e = errors[error]
const msg = typeof e === "function" ? e.apply(null, args as any) : e
throw new Error(`[Immer] ${msg}`)
Expand Down
8 changes: 4 additions & 4 deletions website/docs/installation.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -63,10 +63,10 @@ Import size report for immer:
┌───────────────────────┬───────────┬────────────┬───────────┐
│ (index) │ just this │ cumulative │ increment │
├───────────────────────┼───────────┼────────────┼───────────┤
│ import * from 'immer' │ 5873 │ 0 │ 0 │
│ produce │ 34213421 │ 0 │
│ enableMapSet │ 483748451424
│ enablePatches │ 42405655810
│ import * from 'immer' │ 5033 │ 0 │ 0 │
│ produce │ 33243324 │ 0 │
│ enableMapSet │ 40304039 715
│ enablePatches │ 41124826787
└───────────────────────┴───────────┴────────────┴───────────┘
(this report was generated by npmjs.com/package/import-size)
```
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,10 +64,10 @@ Import size report for immer:
┌───────────────────────┬───────────┬────────────┬───────────┐
│ (index) │ just this │ cumulative │ increment │
├───────────────────────┼───────────┼────────────┼───────────┤
│ import * from 'immer' │ 5873 │ 0 │ 0 │
│ produce │ 34213421 │ 0 │
│ enableMapSet │ 483748451424
│ enablePatches │ 42405655810
│ import * from 'immer' │ 5033 │ 0 │ 0 │
│ produce │ 33243324 │ 0 │
│ enableMapSet │ 40304039 715
│ enablePatches │ 41124826787
└───────────────────────┴───────────┴────────────┴───────────┘
(this report was generated by npmjs.com/package/import-size)
```
Expand Down

0 comments on commit 46cd1d5

Please sign in to comment.