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

#imports does not works with imports: false option #1288

Open
danielroe opened this issue Jun 7, 2023 · 5 comments
Open

#imports does not works with imports: false option #1288

danielroe opened this issue Jun 7, 2023 · 5 comments
Labels
bug Something isn't working

Comments

@danielroe
Copy link
Member

An equivalent of nuxt/framework#6768.

cc: @antfu

@danielroe danielroe added the enhancement New feature or request label Jun 7, 2023
@pi0
Copy link
Member

pi0 commented Jun 7, 2023

AFAIK we already support imports: false

@danielroe
Copy link
Member Author

Does that still work with importing from #imports?

@pi0
Copy link
Member

pi0 commented Jun 7, 2023

Nah, seems a regression...

@pi0 pi0 changed the title allow disabling auto importing behaviour for server utilities #imports does not works with imports: false option Jun 7, 2023
@pi0 pi0 added bug Something isn't working and removed enhancement New feature or request labels Jun 7, 2023
@danielroe
Copy link
Member Author

We only initialise unimport when imports is not false:

nitro/src/nitro.ts

Lines 110 to 116 in 0fdadd1

if (nitro.options.imports) {
nitro.unimport = createUnimport(nitro.options.imports);
// Support for importing from '#imports'
nitro.options.virtual["#imports"] = () => nitro.unimport.toExports();
// Backward compatibility
nitro.options.virtual["#nitro"] = 'export * from "#imports"';
}

I think we need a middle ground - where unimport is initialised but it does not transform anything but '#imports'. This requires more than just configuring unimport at the moment - in Nuxt, we have to add a separate transform plugin (see linked PR).

Perhaps we could support this as an option passed directly to unimport? (cc: @antfu)

@antfu
Copy link
Member

antfu commented Jun 9, 2023

I think we might need to add this option as Nuxt:

https://github.com/nuxt/nuxt/blob/3059a65b32352d07529b9e1ae57e3f04385995e4/packages/nuxt/src/core/nitro.ts#L40

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants