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

Deno/ESM support #94

Open
prettykool opened this issue Mar 9, 2022 · 7 comments · May be fixed by #140
Open

Deno/ESM support #94

prettykool opened this issue Mar 9, 2022 · 7 comments · May be fixed by #140

Comments

@prettykool
Copy link

This is gonna be a quick one: I'm using Deno (version 1.19.2), and couldn't import the fuzzysort.js file as a module. One quick hack with the file (and by that, I mean I removed the UMD function, and added an export const fuzzysort declaration ) later, and it looked like the problem was (somewhat) resolved.

Of course, the hack I did was complete crap - But it could be a step in the right direction. Is proper support for ESM imports a possibility? Or is there something I'm missing, here?

@blq
Copy link

blq commented Mar 10, 2022

That is what I had to do too to get it loading using plain import. Remove UMD-wrapper and do export const fuzzysort = fuzzysortNew();
Don't think it's "crap", it's standard., but agree should be possible to get it to handle both UMD and import somehow I think.

@blynx
Copy link

blynx commented Jul 13, 2022

Yes please! A build like ... at fuse.js .... to target different module patterns would be nice. Otherwise just go for esm? As this is and will be the way to go anyway on any js runtime.

@farzher
Copy link
Owner

farzher commented May 12, 2024

i tried for days to understand how to properly distribute a js library but i can't figure it out without making a mess.

it seems like Deno works now though. they can just import a UMD module (as long as it's hosted on npm, i couldn't get it to import a local file successfully but i guess that's fine)

is an ESM build still needed? i don't like the complexity of multiple builds.

@hlysine
Copy link

hlysine commented May 18, 2024

ESM support is greatly appreciated. Loading fuzzysort via UMD is sometimes unreliable, especially when it collides with the Monaco Editor loader. Because of this, I published an ESM fork of fuzzysort. However, if you are interested in providing an ESM build upstream, I would gladly contribute.

@Socolin
Copy link

Socolin commented Jun 12, 2024

i tried for days to understand how to properly distribute a js library but i can't figure it out without making a mess.

it seems like Deno works now though. they can just import a UMD module (as long as it's hosted on npm, i couldn't get it too import a local file successfully but i guess that's fine)

is an ESM build still needed? i don't like the complexity of multiple builds.

Hello,

I woud be interested in this too.

I'm using tsup to package my packages to provide both (I'm using it with typescript project but I think it can support JS to)
Also I'm using https://publint.dev/ to validate that the package is correct, it's a great tool :)

@craiggoldstone
Copy link

+1 for native ESM support. We use Angular 17 and Typescript in our project and during compilation there's a waning message mentioning that CommonJS dependencies might increase bundle size and prevent optimisation: https://v17.angular.io/guide/build#configuring-commonjs-dependencies

@decanTyme
Copy link

is an ESM build still needed? i don't like the complexity of multiple builds.

I think the consensus is ESM moving forward.

i tried for days to understand how to properly distribute a js library but i can't figure it out without making a mess.

I was also in this situation when I published my first OS package where I wanted to dual emit CJS/ESM + UMD builds just for the sake of compatibility. I poured tons of hours trying to get it right (as well as the types) and I eventually settled with Rollup. It's simpler than you might think. You can just write the code in any fashion, make sure it has at least one public export, and just let the build tool do the bundling work for you. Here's my config for example in case you're interested.

Also, I do my type checks with Are the types wrong?.

hugo-vrijswijk added a commit to hugo-vrijswijk/fuzzysort that referenced this issue Nov 20, 2024
Fixes farzher#94

Adds a rollup config file to build ESM, CJS, and UMD bundles. Based on the source in src/fuzzysort.js.

Checks in the new esm file and the updated cjs and umd files.

Also updates the package.json to include `module` and `browser` fields for the ESM and UMD bundles.
@hugo-vrijswijk hugo-vrijswijk linked a pull request Nov 20, 2024 that will close this issue
hugo-vrijswijk added a commit to hugo-vrijswijk/fuzzysort that referenced this issue Nov 22, 2024
Fixes farzher#94

Adds a rollup config file to build ESM, CJS, and UMD bundles. Based on the source in src/fuzzysort.js.

Checks in the new esm file and the updated cjs and umd files.

Also updates the package.json to include `module` and `browser` fields for the ESM and UMD bundles.
hugo-vrijswijk added a commit to hugo-vrijswijk/fuzzysort that referenced this issue Nov 24, 2024
Fixes farzher#94

Adds a rollup config file to build ESM, CJS, and UMD bundles. Based on the source in src/fuzzysort.js.

Checks in the new esm file and the updated cjs and umd files.

Also updates the package.json to include `module` and `browser` fields for the ESM and UMD bundles.
hugo-vrijswijk added a commit to hugo-vrijswijk/fuzzysort that referenced this issue Nov 25, 2024
Fixes farzher#94

Adds a rollup config file to build ESM, CJS, and UMD bundles. Based on the source in src/fuzzysort.js.

Checks in the new esm file and the updated cjs and umd files.

Also updates the package.json to include `module` and `browser` fields for the ESM and UMD bundles.
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

Successfully merging a pull request may close this issue.

8 participants