guybedford / es-module-lexer

Low-overhead lexer dedicated to ES module parsing for fast analysis
MIT License
926 stars 46 forks source link

parse error #81

Closed davidmarkclements closed 3 years ago

davidmarkclements commented 3 years ago

hey there, great work!

when attempting to parse https://github.com/pinojs/pino/blob/master/lib/tools.js the following error occurs:

Error: Parse error /example/node_modules/pino/lib/tools.js:1:1
    at Module.parse (file:///node_modules/es-module-lexer/dist/lexer.js:2:356)

If there's a way I can give you more info than this let me know

I realise it's a CJS file, but I'm parsing any file that may contain a dynamic import (which includes CJS files)

guybedford commented 3 years ago

@davidmarkclements thanks, nice to finally meet :) Just ran a quick test of this by pasting the source into the unit test file and running a parse. I needed to escape the backslashes and multiline comments to get it to parse correctly but that is standard literal string conversion. So it's defiitely working for me. Make sure you're passing a string and handling escaping correctly.

If you're still not able to get it to work, post a PR with a replication in test/_unit.cjs and I'll take another look.

davidmarkclements commented 3 years ago

hey thanks for checking this, this was totally my fault (trying to lex a chunk of a stream without realising it). Sorry for the time drain!

great to meet you too, would love to meet in person at some point