-
Notifications
You must be signed in to change notification settings - Fork 41
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
Converted to ES modules #135
Conversation
I've taken some time to read through the article you contributed, and I wanted to thank you for the thorough analysis. As we're moving forward, I've encountered a hiccup with our JSFiddle example. It's currently not operating as expected with the updated library. fulltext.ts:23 Uncaught TypeError: o.default is not a function
at new t (fulltext.ts:23:17)
at index.ts:27:36
at (index):188:11 The example is accessible here: https://jsfiddle.net/cigol/0ef9qeos/196/. In addition, I'm proposing a small tweak for the clone function to maintain compatibility with Node.js 16, presented here: export function clone<T>(val: T): T {
try {
// Try to use structuredClone if available.
return structuredClone(val);
} catch (e) {
// If structuredClone is not available or fails, use JSON-based cloning as a fallback.
return JSON.parse(JSON.stringify(val));
}
} Including this fallback in the PR would help us ensure a wider compatibility range. Your input and contribution are very much valued, and I'm looking forward to any suggestions you might have. |
To be sure we're on the same side. This PR doesn't use TypeScript. Maybe you checked out main branch of my fork. You want to check I didn't pushed TS-version as PR, because thought it would be way too much changes at once
Microbundle can't resolve properly
Sure |
One way would be to convert |
There are 3 options (which I can think of):
|
Yes, I was testing the TypeScript branch before (with vitest as testing environment) Thank you for the suggestions on how to address the issue we're facing. Fixing the issue in microbundle: This would be the ideal solution, as it directly addresses the root of the problem. However, this is also the option with the least predictability since it relies on external maintainers. Refusing from UMD distribution to use ES modules in the browser: It's worth noting that while modern browsers support ES modules, a complete shift might not accommodate a significant segment of developers who continue to use UMD. Many libraries still support UMD, which suggests that it remains a considerable part of the JavaScript ecosystem. Without exact market data, it's challenging to quantify this, but it's clear that UMD usage is still extensive. Switching to an alternative library: I propose Minisearch. It's is a lightweight library that supports ES modules and has come up multiple times in our issue tracker. It seems to offer the functionalities we need for our search capabilities. |
Kind people from microbundle helped me to understand issue. microbundle doesn't "pack"
still smaller than it was, though |
Excellent work! The size of the compressed file is now two times smaller than before, which is a fantastic improvement. |
Not sure if you are interested (if not feel free to close).
As the result build size reduced from 100kb to 10kb
Some speed improvements:
{}
toObject.create(null)
(I guess,Map
would be even faster, but I didn't want to change interface)structuredClone
instead forJSON.stringify
/JSON.parse
PS recently wrote an article about front-end faceted search and apparently there are only 3 options