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

Support Native ESM in order to work properly in vitejs and TypeScript #23

Open
achmadk opened this issue Oct 13, 2021 · 6 comments
Open

Comments

@achmadk
Copy link

achmadk commented Oct 13, 2021

Hello. I have issue with void-elements library inside vite-based web application project.

This library is used by html-parse-stringify. I got error like this.
Screenshot from 2021-10-13 12-16-59

Although this library has support ESM with jsnext:main, unfortunately this library doesn't support native ESM, which required for vite in order to work properly.

Moreover, I hope this library also have built-in support TypeScript definition because definition file from @types/void-elements needs improvement to be stricter.

achmadk added a commit to achmadk/void-elements that referenced this issue Oct 13, 2021
add `module` and `exports` attribute into `package.json` file

fix pugjs#23
achmadk added a commit to achmadk/void-elements that referenced this issue Oct 13, 2021
add typescript definition which has stricter type than `@types/void-elements`

fix pugjs#23
@francesc79
Copy link

please @pugjs merge the PR

@emab
Copy link

emab commented Feb 18, 2023

Is there anything else we can do to get this merged? Would be great if we can get this one in.

@achmadk
Copy link
Author

achmadk commented Feb 18, 2023

Is there anything else we can do to get this merged? Would be great if we can get this one in.

You can use this module as workaround.

@emab
Copy link

emab commented Feb 19, 2023

Is there anything else we can do to get this merged? Would be great if we can get this one in.

You can use this module as workaround.

For me this is being used by html-parse-stringify which in turn is a dependency of react-i18next - is there an easy way to use your version instead?

I was hoping I could use the overrides property like this:

{
  "overrides": {
    "react-i18next": {
      "html-parse-stringify": {
        "void-elements": "@achmadk/void-elements"
      }
    }
  }
}

Is that correct?

@achmadk
Copy link
Author

achmadk commented Feb 19, 2023

I have the same issue as yours. Although void-elements is deep inside react-i18next, all modules will be processed as flattened 1-level tree by vite.

import { defineConfig } from 'vite'

export default defineConfig({
  // rest of your vite configuration 
  resolve: {
    alias: [
      // another aliases 
      {
        find: 'void-elements',
        replacement: '@achmadk/void-elements'
      }
    ]
  }
})

That config works for me.

@emab
Copy link

emab commented Feb 20, 2023

Nice thanks for that. Will give it a go 👍

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

3 participants