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

relative import path (modulePath) should contain .js extension #1668

Closed
2 of 4 tasks
christophe-g opened this issue Aug 28, 2024 · 3 comments
Closed
2 of 4 tasks

relative import path (modulePath) should contain .js extension #1668

christophe-g opened this issue Aug 28, 2024 · 3 comments

Comments

@christophe-g
Copy link

Ideally relative Import path should contain the .js extension in the auto-generated routes.js file.

This would avoid an [ERR_MODULE_NOT_FOUND] errors in context not allowing extensionless module reference.

Sorting

  • I'm submitting a ...

    • bug report
    • feature request
    • support request
  • I confirm that I

    • used the search to make sure that a similar issue hasn't already been submit

Current Behavior

Generated code fail to run in some restricted context.

Expected Behavior

Auto-generated routes.js is always able to load imported modules

Possible Solution

I can propose a PR i that make sense

Copy link

Hello there christophe-g 👋

Thank you for opening your very first issue in this project.

We will try to get back to you as soon as we can.👀

@mhammerc
Copy link

Hello,

By reading the configuration file documentation: https://github.com/lukeautry/tsoa/blob/master/packages/runtime/src/config.ts

I found that you can set

// tsoa.json
"routes": {
  "esm": true
}

The .js will be added automatically in the routes.ts file.

@christophe-g
Copy link
Author

Oh - merci beaucoup @mhammerc !

Don't know how I missed that.

Closing as resolved

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

2 participants