-
Notifications
You must be signed in to change notification settings - Fork 47
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
✨ add esm option. Add extension to imported file #311
Conversation
Hello @bencoveney |
Hi @Romakita Thanks for the contribution 👍 The code changes (syntax, tests) all look good to me. We have had some discussion previously about esm support - see:
A couple of points:
I've reopened #178 for discussion - I think it would be great to get a plan agreed there before we merge anything. For anything like this where we add new options that people will then add to their config files, it will create a maintenance cost in the future (and cause us some pain if we get it wrong) so hopefully it makes sense to be a bit careful and plan that feature correctly. |
Hello @bencoveney I understand your point. we can rename the option EDIT: Ok I see the new options
In fact, your tool always import .js file to create barrel file, right ? Today, I propose your awesome tool for any project based on the Ts.ED framework. But, the problem is around the ESM support, because your tool doesn't provide a way to generate barrels with extension, I could not keep Barreslby in the stack in the short term. And as the module works very well, I wanted to advance the subject with you rather than doing a fork. |
Sort of yes. My understanding at the moment is: it would be best to match the behaviour of the TypeScript compiler for determining whether a file should be treated as an ESM module, and that is roughly what the TypeScript compiler does: https://github.com/microsoft/TypeScript/blob/0ada54c006015bda2fd3b593607f58206168aa0b/src/compiler/program.ts#L845 I am open to working towards that solution incrementally - There's a note on #178 that proposes a halfway solution:
Would this work for your use case? I would prefer to take that route, instead of adding an experimental argument. @BitForger interested if you have any thoughts on this, now that's popped up again. |
@bencoveney I changed the option according to your latest comment. But I see you working on a v3 so maybe this PR isn't longer needed :) See you |
This PR add an option to generate the
.js
extension required by ESM Module. It works only if the project enable"type": "module"
in his package.json.