-
Notifications
You must be signed in to change notification settings - Fork 12k
Generate apps building with babel and @babel/preset-typescript instead of tsc. #13806
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
Comments
We're building angular.io with Angular CLI and we are quite certain that we haven't had problems with Google Search indexing the website. Would you give more examples what are your concerns with the TypeScript compiler and older browsers? |
Hi @mgechev, thanks for answering! I can indeed give you additional details. Here is a screenshot of a test result from an Angular app scanned using the google mobile friendly test: As you can see the arrow function built within the main.*.js file is triggering a syntax error, as the crawler does not support ES6. Now, the
There is technically a tweak allowing the TypeScript compiler to look into dependencies in node_modules with JS extension and process them just like ts files by adding the following properties to compilerOptions on the tsconfig file:
Unfortunately this approach wasn't successful in my case using Angular universal, as it threw an error: Considering that many third party packages are released in ES6, I thought that using babel to process dependencies would be a life saver for developers who heavily rely on third party packages released in ES6 only. You can get more information about this issue here, and here. By the way, I wrote a quick test to quickly see if my main.js file contains arrow functions, it may be useful, just add this in your package.json scripts: Thanks again for replying so fast, let me know if you have more questions :) |
@mgechev good morning! Let me know your thoughts when you have time. |
@glemiere, can you kindly provide a minimal repo where I can replicate the issue with Universal when using |
To be clear, there are two different and unrelated topics being discussed in this issue:
The answer to the first question is, as far as I can tell, no. The Angular AOT compiler is based on typescript, not on babel. The answer to the second question is "yeah, probably". I discussed this topic in #12975 (comment). The gist of it is that there are no official nor vaguely official guidelines for packaging libraries with different ES formats, and that more and more libraries are ES2015 only. As far as ES5 consumers are concerned, publishing a library in ES2015+ is similar to publishing a library in TypeScript or CoffeeScript really. For it to be used in ES5 browsers, it must be compiled, and the compilation options must be either provided or guessed. Just because the files have the I renamed #12975 to be more search friendly and added it to the FAQ. I think it should be the main issue where third party libs in ES2015 are discussed instead of having a fragmented discussion across multiple issues. Let's continue the discussion there instead. Given that the second topic is better covered elsewhere, and that the first topic has an answer in this comment, I am closing this issue. |
case is for imported modules, not angular and fancy app itself. Angular cli can't transpile imported modules like Web3js. But everyone here talk about es5 in target... Thing is people was hope that angular cli will build app for them correctly, but like always golden chick has to be paid twice. |
This issue has been automatically locked due to inactivity. Read more about our automatic conversation locking policy. This action has been performed automatically by a bot. |
🚀 Feature request
Command (mark with an
x
)Description
TypeScript compiler has been great so far, but showed some limitations especially when it comes to transpiling ES6 third party modules to ES5. This can be a pretty big issue when developers have requirements with older browsers, or simply want (or need) their website to pass the Google Crawler without any issue, such as "Unexpected token "=>"". This issue is also showing on older browsers.
Describe the solution you'd like
This is a problem that can be solved by using babel to transpile ES6 module to ES5, and @babel/preset-typescript to transpile TypeScript to ES5 as well.
Thanks!
The text was updated successfully, but these errors were encountered: