Skip to content
This repository has been archived by the owner on Apr 6, 2023. It is now read-only.

fix(bridge): default export detection #1774

Merged
merged 2 commits into from
Nov 8, 2021
Merged

Conversation

antfu
Copy link
Member

@antfu antfu commented Nov 8, 2021

πŸ”— Linked issue

vuejs/pinia#767

In @pinia/nuxt, it exports like this:

export { PiniaNuxtPlugin as default };

which causing

image

❓ 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)
  • ⚠️ Breaking change (fix or feature that would cause existing functionality to change)

πŸ“š Description

πŸ“ Checklist

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

@netlify
Copy link

netlify bot commented Nov 8, 2021

βœ”οΈ Deploy Preview for nuxt3-docs ready!

πŸ”¨ Explore the source changes: 4a2b687

πŸ” Inspect the deploy log: https://app.netlify.com/sites/nuxt3-docs/deploys/6188bd24e9e19f0008d933b6

😎 Browse the preview: https://deploy-preview-1774--nuxt3-docs.netlify.app

@netlify
Copy link

netlify bot commented Nov 8, 2021

βœ”οΈ Deploy Preview for nuxt3-docs canceled.

πŸ”¨ Explore the source changes: 9e7768a

πŸ” Inspect the deploy log: https://app.netlify.com/sites/nuxt3-docs/deploys/6188bd4d361ca600079020b4

Copy link
Member

@pi0 pi0 left a comment

Choose a reason for hiding this comment

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

LGTM. Few suggestions to improve:

  • We shall fix core issues (components/store) and start showing a warning when this fallback is auto injected
  • We might improve mlly to detect named export with default as type: default

@pi0 pi0 merged commit 39db33d into main Nov 8, 2021
@pi0 pi0 deleted the fix/bridge-default-exports-detect branch November 8, 2021 10:33
@jarmani
Copy link

jarmani commented Nov 8, 2021

This fix works for you ?

On my machine

const exports = findExports(code);
console.log(exports);

gives me :

...
[
  {
    type: 'named',
    exports: ' PiniaNuxtPlugin as default ',
    code: 'export { PiniaNuxtPlugin as default }',
    start: 841,
    end: 878,
    names: [
      'default'
    ]
  }
]
[
  {
    type: 'named',
    exports: ' PiniaNuxtPlugin as default ',
    code: 'export { PiniaNuxtPlugin as default }',
    start: 841,
    end: 878,
    names: [
      'default'
    ]
  }
]

so i.type === "default" || i.name === "default" is always false, and the error persist

[SSR] Error transforming defaultexport:[...]/node_modules/@pinia/nuxt/dist/plugin.mjs: Error: Parse failure: Duplicate export 'default' (36:7)
Contents of line 36: export default () => {}

looking at mlly, NamedExport only has names

export interface NamedExport extends ESMExport {
  type: 'named'
  exports: string
  names: string[]
}

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants