deepmerge
deepmerge copied to clipboard
`is-mergeable-object` is a `devDependency` but used in `index.js`
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?
I believe this library bundles all it's dependencies.
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/[email protected]/node_modules/deepmerge/index.js
- /<path>/flopflip/node_modules/.pnpm/@[email protected][email protected]/node_modules/@rollup/plugin-node-resolve/dist/cjs/index.js
- /<path>/flopflip/node_modules/.pnpm/@[email protected]/node_modules/@preconstruct/cli/cli/dist/cli.cjs.dev.js
- /<path>/flopflip/node_modules/.pnpm/@[email protected]/node_modules/@preconstruct/cli/cli/dist/cli.cjs.js
- /<path>/flopflip/node_modules/.pnpm/@[email protected]/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/[email protected]/node_modules/v8-compile-cache/v8-compile-cache.js:159:20)
at Object.<anonymous> (/<path>/flopflip/node_modules/.pnpm/[email protected]/node_modules/deepmerge/index.js:1:94)
at Module._compile (/<path>/flopflip/node_modules/.pnpm/[email protected]/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/[email protected]/node_modules/deepmerge/index.js',
'/<path>/flopflip/node_modules/.pnpm/@[email protected][email protected]/node_modules/@rollup/plugin-node-resolve/dist/cjs/index.js',
'/<path>/flopflip/node_modules/.pnpm/@[email protected]/node_modules/@preconstruct/cli/cli/dist/cli.cjs.dev.js',
'/<path>/flopflip/node_modules/.pnpm/@[email protected]/node_modules/@preconstruct/cli/cli/dist/cli.cjs.js',
'/<path>/flopflip/node_modules/.pnpm/@[email protected]/node_modules/@preconstruct/cli/bin.js'
]
}
If you need a quick fix, I'd recommend deepmerge-ts
Ok. I moved over the merge-deep which works for me.
I confirm this issue(?)
to solve: (one of)
- rename
index.d.tstopublic.d.ts(or any other), and set"types": "./public.d.ts"inpackage.json - add
index.jsto.npmignore
Why:
- typescript language server index symbols, it found symbol
deepmergeindeepmerge/index.d.ts - because there is a "index.js", it remember "index.js provides symbol deepmerge", which is wrong
- when someone type "deepmerge" and call auto-complate in their editor, it emits
import deepmerge from 'deepmerge/index';
when "types" in package.json, TSLS will know "the package named deepmerge provides symbol deepmerge"
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
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)