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

denoify creates imports from comments #89

Open
hermann-p opened this issue Mar 13, 2023 · 3 comments
Open

denoify creates imports from comments #89

hermann-p opened this issue Mar 13, 2023 · 3 comments

Comments

@hermann-p
Copy link

hermann-p commented Mar 13, 2023

Denoifying a TypeScript file with a comment containing the word "Buffer" led to an output file importing the Buffer package, subsequently breaking our backend build.

See this commit for context.

Observed behaviour:

The word "Buffer" in a comment makes denoify create an import statement for Buffer.

Desired behaviour:

Denoify will not treat comments as code.

@garronej
Copy link
Owner

garronej commented Mar 13, 2023

Hi @hermann-p,
Damn, I know this day would come.
Denoifiy is using Regexp, instead of an actuall parser. Part because it's started as a toy project to convert my own libraries and grown from here and part because I didn't want to be worried about a new keyword breaking it. (We still can't use satisfies in many context).

I don't know, I could introduce yet another hack so that it wont happen.
Or maybe I should properly parse at least comments.

I ran across grubber the other day. Looks interesting.

What do you thing @Gin-Quin? Could Denoify be a good usecase for grubber?

@Gin-Quin
Copy link

Yep, it's exactly the kind of tasks Grubber has been designed for. Think of Grubber as something in-between a full parser and a basic search and replace system.

This is especially suited for top-level static declarations, like ESM imports. You'll have 100% safety with a very simple usage.

@garronej
Copy link
Owner

Ok thanks for the insight @Gin-Quin,
Grubber did seems like a well executed good offer.
I'll see if I can make it work

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