deepmerge icon indicating copy to clipboard operation
deepmerge copied to clipboard

add ESM, support for module and browser

Open kopax-polyconseil opened this issue 1 year ago • 5 comments

Hello and thanks for sharing,

As I can see when working on this matter, you don't have any module field in package.json for serving ESM, the most recent version of JS modules.

You also don't have a browser field for serving the umd.

Do you have any plan to add those or is this module obselete?

kopax-polyconseil avatar Aug 05 '22 16:08 kopax-polyconseil

For version 4 there are no plans to add this (see #194). If version 5 every comes out (see #241) it should have this.

In the meantime you can use https://github.com/RebeccaStevens/deepmerge-ts

RebeccaStevens avatar Aug 05 '22 16:08 RebeccaStevens

We do not use deepmerge, it is used by one of our dependency, see https://github.com/callstack/react-theme-provider/search?q=deepmerge

As you can see from that link, they only do import deepmerge from 'deepmerge', but for some reason, the UMD module gets selected.

Could you at least concider to fix that? So they import the right module? This module is widely use and no doubt a lot of people don't know about this non optimization.

We fixed the import to CJS in our webpack.resolve.alias

        // remove when issue is resolved https://github.com/callstack/react-theme-provider/issues/141
        'deepmerge': path.join(paths.appNodeModules, 'deepmerge/dist/cjs.js'),

kopax-polyconseil avatar Aug 05 '22 16:08 kopax-polyconseil

https://www.npmjs.com/package/@bundled-es-modules/deepmerge feel free to use ESM bundled fork of this project.

I felt I had no choice but to do this, since the author seems reluctant to add ESM-first support, and deepmerge-ts is almost 4 times as large as original deepmerge.. Of course, you can also commit yourself to a compile-step like @rollup/plugin-commonjs or webpack/esbuild equivalent but for projects that are otherwise compile-step-free, that's not a great option either.

I will deprecate my fork as soon as the author of this package publishes an ESM version.

jorenbroekema avatar Jun 27 '23 08:06 jorenbroekema

Is there a fork in github w/ the actual changes in your npm package @jorenbroekema??

agrohs avatar Nov 14 '23 19:11 agrohs

Is there a fork in github w/ the actual changes in your npm package @jorenbroekema??

yes https://github.com/bundled-es-modules/deepmerge , sorry must have forgotten to put this info in the pkg json

all I do is run esbuild (bundler) over the exported deepmerge pkg and format as ESM, then dual publish both ESM / CJS.

jorenbroekema avatar Dec 19 '23 10:12 jorenbroekema