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

Do not export default only from CJS packages, also because Typescript loose it's typenings #844

Closed
frederikhors opened this issue Sep 21, 2020 · 1 comment

Comments

@frederikhors
Copy link

I really love ❤️ ViteJS.

What makes me sad is something like this below.

I wanna use the amazing https://github.com/Nozbe/WatermelonDB for a project but I have problems with ES/CJS music.

Since they are using CJS export today (I opened this asking for ES) I'm using this in my vite.config.js:

module.exports = {
  optimizeDeps: {
    include: [
      '@nozbe/watermelondb',
      '@nozbe/watermelondb/adapters/lokijs',
      '@nozbe/watermelondb/decorators'
    ]
  }
}

What makes me sad now is:

  1. I cannot use this code:

    import { field } from '@nozbe/watermelondb/decorators'
    
      class Post extends Model {
      // ...
      @field('title') title
      @field('body') body
      // ... and so on
    }

    I need to use this instead:

    import allDecoratorsPackage from '@nozbe/watermelondb/decorators'
    
    class Post extends Model {
      // ...
      @allDecoratorsPackage.field('title') title
      @allDecoratorsPackage.field('body') body
      @allDecoratorsPackage.field('is_pinned') isPinned
      // ... and so on
    }
  2. I loose Typescript definitions in case like this:

    import LokiJSAdapter from '@nozbe/watermelondb/adapters/lokijs'
    
    const adapter = new LokiJSAdapter.default({})

    and Typescript doesn't show definitions because of:

    Property 'default' does not exist on type 'typeof LokiJSAdapter'.ts(2339)
    

Given that sooner or later everyone will export ESM,

given that I am doing everything to speed up this process (flatpickr is almost done merging PR!),

can we please find a way for fix these two "issues" that hinder rapid application development?

Thank you for your talent and your time.

@antfu
Copy link
Member

antfu commented Sep 21, 2020

Please keep track on #720 & #837. Thanks for the feedback.

@antfu antfu closed this as completed Sep 21, 2020
@github-actions github-actions bot locked and limited conversation to collaborators Jul 16, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants