TehShrike / deepmerge

A library for deep (recursive) merging of Javascript objects
MIT License
2.75k stars 216 forks source link

`is-mergeable-object` is a `devDependency` but used in `index.js` #245

Open tdeekens opened 2 years ago

tdeekens commented 2 years ago

When using pnpm and building using preconstruct I stumbled across noticing that is-mergeable-object is a devDep in this project while it's being used also in the index.js.

Should it be promoted to be a regular dependency?

RebeccaStevens commented 2 years ago

I believe this library bundles all it's dependencies.

tdeekens commented 2 years ago

Thanks for the quick response. The error I am receiving looks as follows

> preconstruct build

node:internal/modules/cjs/loader:936
  throw err;
  ^

Error: Cannot find module 'is-mergeable-object'
Require stack:
- /<path>/flopflip/node_modules/.pnpm/deepmerge@4.2.2/node_modules/deepmerge/index.js
- /<path>/flopflip/node_modules/.pnpm/@rollup+plugin-node-resolve@9.0.0_rollup@2.70.0/node_modules/@rollup/plugin-node-resolve/dist/cjs/index.js
- /<path>/flopflip/node_modules/.pnpm/@preconstruct+cli@2.1.5/node_modules/@preconstruct/cli/cli/dist/cli.cjs.dev.js
- /<path>/flopflip/node_modules/.pnpm/@preconstruct+cli@2.1.5/node_modules/@preconstruct/cli/cli/dist/cli.cjs.js
- /<path>/flopflip/node_modules/.pnpm/@preconstruct+cli@2.1.5/node_modules/@preconstruct/cli/bin.js
    at Function.Module._resolveFilename (node:internal/modules/cjs/loader:933:15)
    at Function.Module._load (node:internal/modules/cjs/loader:778:27)
    at Module.require (node:internal/modules/cjs/loader:999:19)
    at require (/<path>/flopflip/node_modules/.pnpm/v8-compile-cache@2.3.0/node_modules/v8-compile-cache/v8-compile-cache.js:159:20)
    at Object.<anonymous> (/<path>/flopflip/node_modules/.pnpm/deepmerge@4.2.2/node_modules/deepmerge/index.js:1:94)
    at Module._compile (/<path>/flopflip/node_modules/.pnpm/v8-compile-cache@2.3.0/node_modules/v8-compile-cache/v8-compile-cache.js:192:30)
    at Object.Module._extensions..js (node:internal/modules/cjs/loader:1151:10)
    at Module.load (node:internal/modules/cjs/loader:975:32)
    at Function.Module._load (node:internal/modules/cjs/loader:822:12)
    at Module.require (node:internal/modules/cjs/loader:999:19) {
  code: 'MODULE_NOT_FOUND',
  requireStack: [
    '/<path>/flopflip/node_modules/.pnpm/deepmerge@4.2.2/node_modules/deepmerge/index.js',
    '/<path>/flopflip/node_modules/.pnpm/@rollup+plugin-node-resolve@9.0.0_rollup@2.70.0/node_modules/@rollup/plugin-node-resolve/dist/cjs/index.js',
    '/<path>/flopflip/node_modules/.pnpm/@preconstruct+cli@2.1.5/node_modules/@preconstruct/cli/cli/dist/cli.cjs.dev.js',
    '/<path>/flopflip/node_modules/.pnpm/@preconstruct+cli@2.1.5/node_modules/@preconstruct/cli/cli/dist/cli.cjs.js',
    '/<path>/flopflip/node_modules/.pnpm/@preconstruct+cli@2.1.5/node_modules/@preconstruct/cli/bin.js'
  ]
}
RebeccaStevens commented 2 years ago

If you need a quick fix, I'd recommend deepmerge-ts

tdeekens commented 2 years ago

Ok. I moved over the merge-deep which works for me.

GongT commented 1 year ago

I confirm this issue(?)

to solve: (one of)

  1. rename index.d.ts to public.d.ts (or any other), and set "types": "./public.d.ts" in package.json
  2. add index.js to .npmignore

Why:

when "types" in package.json, TSLS will know "the package named deepmerge provides symbol deepmerge"

jorenbroekema commented 1 year ago

Erh yeah is-mergeable-object most definitely should be a depedency, not a devDependency... https://github.com/TehShrike/deepmerge/blob/master/index.js#L1

https://github.com/TehShrike/deepmerge/blob/master/index.js#L78

Dinhero21 commented 6 months ago

This generated a faulty bundle when building with Rollup.

Relevant logs:

(!) Missing global variable name
https://rollupjs.org/configuration-options/#output-globals
Use "output.globals" to specify browser global variable names corresponding to external modules:
is-mergeable-object (guessing "require$$0")

fixable by installing is-mergeable-object, but would have already been installed if included in package.json's dependencies (and not devDependencies)