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

Default imports for some modules behave differently when statically imported on client side vs server side #2696

Open
lionel-rowe opened this issue Oct 9, 2024 · 0 comments

Comments

@lionel-rowe
Copy link
Contributor

Default imports for some modules, such as npm:[email protected]/parser-html, behave differently when statically imported on the client side vs server side.

Repro:

  1. Bootstrap app with deno run -A -r https://fresh.deno.dev

  2. Replace content of islands/Counter.tsx with the following:

    import * as staticMod from 'npm:[email protected]/parser-html'
    import { assert } from "jsr:@std/[email protected]";
    
    const dynamicMod = await import('npm:[email protected]/parser-html')
    
    assert('default' in dynamicMod, 'No default prop (dynamic)!')
    console.log('ok (dynamic)')
    
    assert('default' in staticMod, 'No default prop! (static)')
    console.log('ok (static)')
    
    export default function() {
      return <div>...</div>
    }
  3. Observe output in CLI console:

    ok (dynamic)
    ok (static)
    
  4. Open server URL and observe output in browser console:

    ok (dynamic)
    assert.ts:21 Uncaught AssertionError: No default prop! (static)
        at assert (assert.ts:21:11)
        at Counter.tsx:9:1
    

On the server, both staticMod and dynamicMod are module objects with default props; however, on the client, staticMod is itself the default export (i.e. it doesn't have a default prop of its own).

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

No branches or pull requests

1 participant