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

ESM import works, but with warnings #9

Open
jschirrmacher opened this issue Oct 15, 2023 · 2 comments
Open

ESM import works, but with warnings #9

jschirrmacher opened this issue Oct 15, 2023 · 2 comments

Comments

@jschirrmacher
Copy link

When using esm (via vite) the following warning is printed:

▲ [WARNING] Converting "require" to "esm" is currently not supported [unsupported-require-call]

    node_modules/@maphubs/tokml/index.js:1:10:
      1 │ var esc = require('./lib/xml-escape')
        ╵           ~~~~~~~

I actually did import the package like documented in README:

import tokml from "@maphubs/tokml"

and it seem to work. However, I don't like warnings and would very much appreciate to use a really ESM compatible module.

@kriscarle
Copy link
Member

Hello @jschirrmacher a PR to fix the warnings would be much appreciated :) You may also want to check out https://github.com/placemark/tokml It is a full modern rewrite of tokml by the original author.

I'm not very familiar with Vite, but it is supposed to support pre-bundling https://vitejs.dev/guide/dep-pre-bundling.html Maybe try cleaning the cache or using the --force option?

@jschirrmacher
Copy link
Author

Thanks, @kriscarle, I'll give https://github.com/placemark/tokml a try.
Actually, I would choose Typescript as well to create a build compatible with both, esm and cjs.

When bundling, no problem occurs. One of the key features of vite is, however, to have a 'dev mode', which doesn't need bundling because modern browsers already support esm and so can load the modules one by one, which makes it way faster than bundling each change.

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

2 participants