-
-
Notifications
You must be signed in to change notification settings - Fork 197
Enable transpilers support in NativeScript projects #493
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
Hey @ligaz, I like what you have here. I agree that each transpiler should be opt in and as generic as possible. I have two questions:
|
Straight to the points:
|
Babel does indeed, it has the babelrc. |
I really love the generic approach - this is the architectural way to go. Having specific implementations for specific transpilers was my major concern when we discussed this internally. |
I think it's not such a good idea, to have a compiler, or a command such @ligaz says. I think it's best to use the hooks of NPM, which are
This way you can make use of any javascript compiler, since only one command is required. And Hooks are being used, which serve to make many more features, such use Jade-Lang to build XML |
Is there a point in spending resources on reinventing the build pipeline? I've set mine up with Browserify and Jade's CLI through a no-frills Makefile outside of I'd rather ask why is |
Hey @moll, I completely agree that there are multiple way you can accomplish the same using whatever tools make sense for your scenario. However many newcomers are "afraid" of the learning curve of setting up those asset pipelines and would prefer something to get them started easily and without much hassle. Nevertheless whatever we do here will not be re-inventing the tools that are already there. We would just try to provide sane defaults that work great out of the box. |
Babel contrib here, if you need anything from us, feel free to let me know. Happy to help! |
TypeScript and Babel support is now available through hooks:
and
The above commands will install nativescript-dev-typescript and nativescript-dev-babel which in turn install the necessary hooks into your project. Check it out! |
I just checked out the TypeScript support and noticed that the |
Yes, that's not yet implemented. The relevant issue is #887 . |
For any issues and further discussions please refer to #1117. |
The original issue specifically discussed support for SASS and LESS, too. Are there still plans to make those two additional CSS transpilers available "out of the box" similar to Babel/TypeScript today? EDIT:
EDIT 2:
There are also now compiler plugins for Jade, CoffeeScript and XML-XSD. For future reference, growing list of available compiler plugins that work with |
For writing complex Javascript applications, where code readability is important, I use Python as main language, compiling to Javascript using Transcrypt (https://www.transcrypt.org/). Generally this means development of single page applications. It would be great if NativeScript can use such generated Javascript (single file), so that one can develop native apps using Python. |
A common request we have received in the last couple of months is the ability to enable (or start with) JavaScript transpilers for a given NativeScript project. The usual suspects are TypeScript and Babel which recently became quite popular with the approaching ratification of ES6.
Guiding principles
There a couple of guiding principles we want to follow when we enable this functionality.
Making it generic
We want to design this feature so we can accommodate any transpiler, not just ones for JavaScript. What if you want to use LESS or Sass instead of CSS? Fan of Jade instead of XML we should have you covered.
Per project configuration
This feature should allow usage of different version of the transpiler in different projects. For example you can use TypeScript 1.4 for your production app but switch to the cutting edge TypeScript 1.5 in your new project.
Ability to to start with transpiler or enable it on the go
We believe that the barrier to entry for NativeScript should be as low as the one of the Web. We shouldn't force the users to learn all the cool ES6 features or TypeScript's types system. Users should be able to enable a transpiler for an already existing project or start a new project with given transpiler if this is what they want.
The Command
The support will boil down to a single command that users will have to execute:
or
As you can see we have not settled on the command name 😄 We did a little brainstorming sessions internally and we come up withenable
(ex.$ tns enable babel
) however this sounds too broad and we are not totally sold on it. If you have ideas how we can better name this command please file them in the comments.Implementation details
Here are some internal and more technical implementation details:
devDependencies
to the project'spackage.json
.Work breakdown
v1.5
TypeScript support
tns install typescript
command. The compiler should be added asdevDependency
.tns-core-modules
package.tsconfig.json
if not present.Babel support
Future ideas
TypeScript support for NativeScript plugins
The text was updated successfully, but these errors were encountered: