-
-
Notifications
You must be signed in to change notification settings - Fork 30
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
Possible to import one function at a time? (✨ Feature request) #18
Comments
hello @mittnavnermike 👋 all import { A } from '@mobily/ts-belt I have already double-checked this by adding
the
you can import functions explicitly from each namespace but it requires some config changes, here's the example: import { pipe } from '@mobily/ts-belt/pipe'
import { flatMap,mapWithDefault } from '@mobily/ts-belt/Option'
import { dropExactly, head } from '@mobily/ts-belt/Array'
const value = pipe(
[1, 2, 3],
dropExactly(2),
flatMap(head),
mapWithDefault(0, x => x * 3)
) Configure path mapping in "paths": {
"@mobily/ts-belt/*": ["./node_modules/@mobily/ts-belt/dist/esm/*"]
} Add ['transform-imports', {
"@mobily\/ts-belt\/((?!dist)\\w+)": {
transform: function(importName, matches) {
return path.resolve(__dirname, './node_modules/@mobily/ts-belt/dist/esm', matches[1])
},
"skipDefaultConversion": true,
}
}] let me know if this is what you wanted to achieve 😊 |
Thank you for a very detailed answer! I'll try your approach |
Love your lib! Though I'd share one of my thoughts. Didn't see anything about this in the docs. Sorry if I'm reraising a question.
As a person with bundle phobia, it would be nice if I could only import the functions that I need. To my understanding, the current way of importing is to import the whole function set for a given type i.e array.
import { A } from '@mobily/ts-belt'
What about something like this:
LoDash approach
import shuffle from '@mobily/ts-belt/a/shuffle'
import shuffle from '@mobily/ts-belt/array/shuffle'
Tree-shaking
I have mixed feelings about this one because in some libraries it doesn't really only give you the one function. Not to sure about how all this works, but it might have something to do with your compiler setup. Even though ergonomic to use I fear that in some cases it might not work as expected.
import { shuffle } from '@mobily/ts-belt/a'
The text was updated successfully, but these errors were encountered: