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

TypeScript files are published and not transpiled to JavaScript before #2106

Open
jelhan opened this issue Feb 20, 2024 · 5 comments
Open

TypeScript files are published and not transpiled to JavaScript before #2106

jelhan opened this issue Feb 20, 2024 · 5 comments
Labels

Comments

@jelhan
Copy link
Contributor

jelhan commented Feb 20, 2024

I noticed that we are publishing the TypeScript files. They are not transpiled to JavaScript before publishing. See addon/components/bs-button.ts as an example. I think that's not what we intended and may break consumers not using TypeScript.

@jelhan jelhan added the bug label Feb 20, 2024
@SanderKnauff
Copy link
Contributor

SanderKnauff commented Feb 21, 2024

For V1 addons, the addon controls it's own build behavior.
JS apps will defer the transpilation of the addon's Typescript to addon itself.

I've just tested this by creating a new JS Ember project and adding ember-bootstrap to it. Adding a bs-button just works as expected.

For a live demo, check out the component docs for BsButton. https://www.ember-bootstrap.com/components/button
Our docs app does not use Typescript yet, but the pages for the converted components still work.

@jelhan
Copy link
Contributor Author

jelhan commented Feb 21, 2024

For V1 addons, the addon controls it's own build behavior.
JS apps will defer the transpilation of the addon's Typescript to addon itself.

Yes. But we don't have a dependency on ember-cli-typescript or typescript or any other package, which may handle the transpilation. That's why I'm surprised that it's working.

Even if we can delay transpilation to JS to build-time of consuming app with v1 addon, I don't think we should do so. It increases technical complexity and has a negative affect on build-time performance.

@SanderKnauff
Copy link
Contributor

SanderKnauff commented Feb 21, 2024

For V1 addons, the addon controls it's own build behavior.
JS apps will defer the transpilation of the addon's Typescript to addon itself.

Yes. But we don't have a dependency on ember-cli-typescript or typescript or any other package, which may handle the transpilation. That's why I'm surprised that it's working.

Even if we can delay transpilation to JS to build-time of consuming app with v1 addon, I don't think we should do so. It increases technical complexity and has a negative affect on build-time performance.

I think it's just using ember-cli-babel for that. I do see that we don't pull in @babel/plugin-typescript-transform through the dependencies (only through devDependencies), but that package is so widely used in Ember related packages, especially the core ones, that I think most apps have it available through those.

Even if we can delay transpilation to JS to build-time of consuming app with v1 addon, I don't think we should do so. It increases technical complexity and has a negative affect on build-time performance.

That is a valid concern. I do think that most V1 Typescript addons keep the TS in place though. Should we try to precompile the js files and remove the Typescript files from the build bundle?

I really should dive back into the V2 addon stuff. For that one atleast I'm sure we should only ship compiled js (except for the types, ofcourse).

@jelhan
Copy link
Contributor Author

jelhan commented Feb 21, 2024

Should we try to precompile the js files and remove the Typescript files from the build bundle?

I was surprised to see that this is not the standard. If it's not too much work, we should do it in my opinion. Maybe it's just about running tsc in prepack step and adding *.ts to .npmignore?

@simonihmig
Copy link
Contributor

I might get confused having only worked on v2 addons for a while, but I do think that our current setup is the "blessed" one as Sander pointed out.

Compare this to e-c-ts docs and its precompile compile command (run as part of prepublish), which only creates declaration files, but doesn't compile down to JS.

v2 addons do the compilation upfront, as they have to. But I don't think it's worth our time to try to do this as a v1 addon. Also not sure if there is really much benefit, because our v1 addon's code still has to go through ember-cli-babel, with or without TS, and stripping the types away shouldn't be much additional work I think?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants