web
web copied to clipboard
Feature request: Default exports in individual files
What is the new or updated feature that you are suggesting?
It would be useful if hooks were provided as default exports when importing directly from a given file.
For example, currently to directly import useUnmountEffect I have to use a statement like:
import { useUnmountEffect } from '@react-hookz/web/cjs/useUnmountEffect/useUnmountEffect';
It would help if I could also use an import like this:
import useUnmountEffect from '@react-hookz/web/cjs/useUnmountEffect/useUnmountEffect';
Why should this feature be included?
There's various build tooling, intended for cases like this library, Lodash, etc, that can rewrite imports like this...
import {
thingA,
thingB,
thingC
} from 'some-library'
to look like this at build time, using string matching.
import thingA from 'some-library/thingA'
import thingB from 'some-library/thingB'
import thingC from 'some-library/thingA'
This tooling generally assumes that any individual exports will be the default export in the specific file, since that's the pattern followed by major libraries like Lodash. Having default exports would allow using that tooling.