komodojp / tinyld

Simple and Performant Language detection library for NodeJS
https://komodojp.github.io/tinyld/
MIT License
415 stars 12 forks source link

ESM broken since version 1.2.1 #13

Closed diegone closed 2 years ago

diegone commented 2 years ago

CJS require works but ESM import throws an exception from version 1.2.1 to 1.2.3. Version 1.2.0 works fine.

kefniark commented 2 years ago

Can you explain more about the error you get and how you are using it?

I just tested the last version with a simple HTML code and <script type="module"> and it work without any trouble with the ESM file.

<!DOCTYPE html>
<html>
  <head>
    <meta charset="UTF-8">
  </head>
  <body>
    <script type="module">
      import { detect } from './dist/tinyld.esm.js'

      console.log(detect('test my text'))
    </script>
  </body>
</html>
diegone commented 2 years ago

Sorry, I should have been more specific. This happened to me using Node.js 16.13.1. If I do import('tinyld') from the REPL or import tinild from 'tinild' from my module, I get a dump of the source and a SyntaxError: Unexpected token 'export' exception. The same works fine with 1.2.0.

kefniark commented 2 years ago

This should be solved in last version 👍