exophunk
Disable auto-import "utils/" folder, but keep others folders
I can completely disable auto-import with
https://nuxt.com/docs/guide/concepts/auto-imports#disabling-auto-imports
I can also specify other paths to auto-import :
but it seems I have no option to disable "utils" or "composables" to be auto-imported. the "dirs" folder config is extending - not replacing - the directories.
I would like to just auto-import configs, types as above, but disable importing utils?
is there a way to configure that?
2 replies
Group auto-imported utils without disabling tree-shaking
The utils/ folder is auto-imported. I do have a lot of utilities. For example
dateUtils.ts
or
passengerUtils.ts
this is just simplified, there are more. The auto-import makes this function available everywhere. While this is cool, its hard to understand where they come from. I would prefer having
passengerUtils.isToddler()
or dateUtils.formatDateTimeISO()
(with a prefix).
I think that would be possible by doing this:
passengerUtils.ts
But I am afraid by doing that, I would lose all benefits of Tree-Shaking. (same like import _ from 'lodash"
instead of specific). I think having import * as passengerUtils from "~/utils/dateUtils"
would theoretically be tree-shaked as far as I understand (https://stackoverflow.com/questions/45735534/is-using-an-es6-import-to-load-specific-names-faster-than-importing-a-namespace)
But it seems there is no way that Nuxt auto-import would use * as xy
I dont want to lose tree-shaking, but also I want to avoid cluttering global name-spacing with function names. And avoid competely disabling auto-imports.
Does anyone see a possibility?3 replies