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

fix: remove duplicate import in generated code #1043

Merged
merged 3 commits into from
Mar 13, 2023
Merged

Conversation

danielroe
Copy link
Member

@danielroe danielroe commented Mar 11, 2023

πŸ”— Linked issue

❓ Type of change

  • πŸ“– Documentation (updates to the documentation or readme)
  • 🐞 Bug fix (a non-breaking change that fixes an issue)
  • πŸ‘Œ Enhancement (improving an existing functionality like performance)
  • ✨ New feature (a non-breaking change that adds functionality)
  • 🧹 Chore (updates to the build process or auxiliary tools and libraries)
  • ⚠️ Breaking change (fix or feature that would cause existing functionality to change)

πŸ“š Description

Small regression from #1012. We now have an import generated below:

https://github.com/unjs/nitro/blob/d8ebc8cbf1825ce12d99c98697f8a487479d4a08/src/rollup/plugins/storage.ts#L45

We can avoid the double import, which will cause a build failure whenever bundled storage is in use (e.g. nuxt/content).

 ERROR  RollupError: Identifier 'prefixStorage' has already been declared (Note that you need plugins to import files that are not JavaScript)


12: 
13: 
14: import { prefixStorage } from 'unstorage'
             ^
15: import overlay from 'unstorage/drivers/overlay'
16: import memory from 'unstorage/drivers/memory'


 ERROR  Identifier 'prefixStorage' has already been declared (Note that you need plugins to import files that are not JavaScript)              23:23:40

  at error (node_modules/.pnpm/rollup@3.19.1/node_modules/rollup/dist/es/shared/node-entry.js:2125:30)
  at Module.error (node_modules/.pnpm/rollup@3.19.1/node_modules/rollup/dist/es/shared/node-entry.js:13316:16)
  at Module.tryParse (node_modules/.pnpm/rollup@3.19.1/node_modules/rollup/dist/es/shared/node-entry.js:13993:25)
  at Module.setSource (node_modules/.pnpm/rollup@3.19.1/node_modules/rollup/dist/es/shared/node-entry.js:13603:39)
  at ModuleLoader.addModuleSource (node_modules/.pnpm/rollup@3.19.1/node_modules/rollup/dist/es/shared/node-entry.js:23569:20)

πŸ“ Checklist

  • I have linked an issue or discussion.
  • I have updated the documentation accordingly.

@danielroe danielroe added the bug Something isn't working label Mar 11, 2023
@danielroe danielroe requested a review from pi0 March 11, 2023 23:27
@danielroe danielroe self-assigned this Mar 11, 2023
@codecov
Copy link

codecov bot commented Mar 11, 2023

Codecov Report

Merging #1043 (d8ebc8c) into main (b27d246) will decrease coverage by 0.12%.
The diff coverage is n/a.

❗ Current head d8ebc8c differs from pull request most recent head 82d52ad. Consider uploading reports for the commit 82d52ad to get more accurate results

@@            Coverage Diff             @@
##             main    #1043      +/-   ##
==========================================
- Coverage   67.30%   67.19%   -0.12%     
==========================================
  Files          62       62              
  Lines        6280     6286       +6     
  Branches      706      707       +1     
==========================================
- Hits         4227     4224       -3     
- Misses       2038     2049      +11     
+ Partials       15       13       -2     
Impacted Files Coverage Ξ”
src/rollup/plugins/storage.ts 98.61% <ΓΈ> (-0.02%) ⬇️

... and 3 files with indirect coverage changes

Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.

@@ -24,7 +24,6 @@ export function storage(nitro: Nitro) {
const driverImports = [...new Set(mounts.map((m) => m.driver))];

const bundledStorageCode = `
import { prefixStorage } from 'unstorage'
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we might remove from other place as only prefixStorage usage is now here

@danielroe danielroe requested a review from pi0 March 13, 2023 11:05
@pi0 pi0 merged commit 452f750 into main Mar 13, 2023
@pi0 pi0 deleted the fix/duplicate-import branch March 13, 2023 13:13
@pi0
Copy link
Member

pi0 commented Mar 13, 2023

Thanks!

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 this pull request may close these issues.

2 participants