Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add ESM, support for module and browser #250

Open
kopax-polyconseil opened this issue Aug 5, 2022 · 5 comments
Open

add ESM, support for module and browser #250

kopax-polyconseil opened this issue Aug 5, 2022 · 5 comments

Comments

@kopax-polyconseil
Copy link

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?

@RebeccaStevens
Copy link

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

@kopax-polyconseil
Copy link
Author

kopax-polyconseil commented Aug 5, 2022

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'),

@jorenbroekema
Copy link

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.

@agrohs
Copy link

agrohs commented Nov 14, 2023

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

@jorenbroekema
Copy link

jorenbroekema commented Dec 19, 2023

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants