dy / subscript

Fast and tiny expression evaluator with minimal syntax.
ISC License
109 stars 4 forks source link

Import doesn't work (node, jest) #16

Closed colorcube closed 12 months ago

colorcube commented 1 year ago

I have a Nx repository.

The import in TypeScript/Node code works, but the build is broken.

The import in Jest Scripts didn't work at all, no matter what I tried:

   /var/www/example/node_modules/subscript/justin.js:2
    import { skip, cur, idx, err, expr } from './parse.js'
    ^^^^^^

    SyntaxError: Cannot use import statement outside a module

    > 1 | import jstin from 'subscript/justin.js';
dy commented 1 year ago

Can you elaborate what you do to get broken build? As you see tests in repository pass fine. Also about jest - it seemingly expects cjs, but this module is esm, I'd suggest researching a bit how to use as esm, likely you just need to add type='module' to package.json

colorcube commented 1 year ago

Unfortunately, Nx is a bit complex and trying to use esm didn't work for me. Additionally, I have very limited knowledge of the whole modules topic.

Nevertheless, thanks for your suggestions. My workaround is to include the subscript code in my own package which is an ugly solution ... but it works for now.

dy commented 12 months ago

I hope you resolved the issue. Please reopen if didn't.