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

question: non typescript support #20

Closed
prescottprue opened this issue Dec 30, 2023 · 7 comments · Fixed by #28
Closed

question: non typescript support #20

prescottprue opened this issue Dec 30, 2023 · 7 comments · Fixed by #28

Comments

@prescottprue
Copy link

prescottprue commented Dec 30, 2023

Hey nice work! Had very similar thoughts about how this is needed. Wanted to ask if there is a plan support non TS files as well - feel free to close if out of scope (seems like it may be).

I ask because I created a jscodeshift transform to do this same thing for my projects (before I found ts2esm) which are mostly Typescript, but some are JS. Was thinking of just contributing here instead of maintaining a similar tool, but keeping JS support is unfortunately a must on my end.

If not no worries at all - In that case I'll keep a link to ts2esm in the transform docs so folks can be aware of their different options (we all just want to update to ESM at the end of the day 😆 )

@bennycode
Copy link
Owner

Hi @prescottprue and thank you for reaching out! the ts2esm tool is heavily based on ts-morph. It can manipulate TypeScript and JavaScript code, so it should be possible to adjust .js files. Do you want to give it a try with one of your sample projects?

@jason-ha
Copy link
Contributor

jason-ha commented Jan 8, 2024

I think the requested support means adding detection in convert.ts for

{newExtension: '.js', suffix: '.js'},
{newExtension: '/index.js', suffix: '/index.js'},

and maybe

{newExtension: '.js', suffix: '.jsx'},

I came across this in repo I am working with, but case was very narrow and I just fixed by hand.

@bennycode bennycode linked a pull request Jan 8, 2024 that will close this issue
@bennycode
Copy link
Owner

@prescottprue I just released v1.2.2 with the suggestions from @jason-ha. Can you please check if it fulfills your use-case?

@bennycode bennycode reopened this Jan 8, 2024
@jason-ha
Copy link
Contributor

I also found a case where .cjs was referenced. So .cjs and .mjs should probably be checked as well. Propose #30

@prescottprue
Copy link
Author

With the .cjs extension I'm looking good on the first project I tried, but I'll need to check the others. Thanks for the quick turnaround

@bennycode
Copy link
Owner

Cool, have you had the chance to check the others?

@bennycode
Copy link
Owner

Since there hasn't been any update, I am assuming that the testing went well. 🤞

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

Successfully merging a pull request may close this issue.

3 participants