Using Node during asset compilation rails on heroku - javascript

Does anybody know if this issue of old node versions regarding using https://github.com/dockyard/es6_module_transpiler-rails on Heroku has been resolved.
https://gist.github.com/bcardarella/7384208
Copying the gist:
I have been working with Peter Wagenet from Tilde on getting support
for Ember Appkit on Heroku with a Rails app. First some background:
Ember Appkit will Transpile ES6 modules for use as AMDs. To that end I
wrote the es6_module_transpiler-rails gem which uses Node and Square's
es6-module-transpiler package. That package makes use of Esprima for
the parsing. There is an issue of a reserved keyword in older
JavaScript runtimes not being quoted properly:
https://code.google.com/p/esprima/issues/detail?id=469
On our local machines everything works OK and the transpiling does not
bomb out because our versions of Node are recent. However, when we
deploy to Heroku and Rails attempts to pre-compile its assets the
version of Node that Heroku uses is out of date. Based upon some
research it appears by default Heroku is using Node v0.4.7 which is
from April 2011. It is easy enough to force Heroku to use a more up to
date version of Node:
https://devcenter.heroku.com/articles/nodejs-support#versions however
it is currently unclear if this will run side-by-side with a Rails app
for pre-compilation. Furthermore, I do not think it is reasonable to
ask Rails developers to include Node configuration code for Heroku in
the apps.
I respectfully request that the default version of Node for Rails's
asset compilation get bumped up to a more recent version.

we support integration through node by using multi buildpack and by defining a package.json in your application. Here's the PR https://github.com/heroku/heroku-buildpack-ruby/pull/245
Make sure nodejs comes first in the .buildpacks file then you can get any version of Node you want.

Related

Is it possible to upgrade the underlying Node.js version used by Meteor without upgrading Meteor?

It seems that the only way to upgrade the version of Node used by Meteor is to upgrade Meteor, according to the following:
How to change or upgrade the version of Node.js in Meteor
Update Node version for Meteor app deployed to Heroku
You can run your production bundle with other node versions, it is just not guaranteed that it will work. In practice though, I've done this many times and have never run into any issues (always using newer versions of node).
In development meteor uses the node binary in
~/.meteor/packages/meteor-tool/METEOR_VERSION/mt-os.linux.x86_64/dev_bundle/bin/
where METEOR_VERSION is the version of meteor your project is using, e.g., 1.12.1. So you could go there and replace that binary with a symlink to another node executable if you want to and it will probably work for most newer versions of node.
In development: difficult. Your Meteor project uses its own embedded Node version, and trying to change it might also require reconfiguring the dev mode build and tooling...
In production: if you have control of the server environment, then yes, you can try another Node version, at your own risks regarding compatibility with Meteor code. However the latter checks that your Node major version is at least the one required by Meteor.
In Heroku: if you use the Meteor buildpack horse, then no. The buildpack configures your Heroku environment as required by the Meteor version of your project, including the Node version.

Why angular 2 need node.js

I don't have experience in front-end but I want to create a simple app using Angular 2.
Why do I need to install Node.js as a prerequisite step? Why does Angular use Node.js?
There are a couple of things that Angular uses Node.js for:
Installing and managing packages. From the Quickstart tutorial:
Angular application developers rely on the npm package manager to install the libraries and packages their apps require. The Angular team recommends the starter-set of packages specified in the dependencies and devDependencies sections.
Compiling the TypeScript used into JavaScript that the browser understands - browsers can't process TypeScript natively and the SystemJS imports used in your code aren't supported in browsers yet:
We strongly recommend transpiling (AKA compiling) to JavaScript during a build phase before running the application for several reasons including:
We see compiler warnings and errors that are hidden from us in the browser.
Precompilation simplifies the module loading process and it's much easier to diagnose problems when this is a separate, external step.
Precompilation means a faster user experience because the browser doesn't waste time compiling.
We iterate development faster because we only recompile changed files. We notice the difference as soon as the app grows beyond a handful of files.
Precompilation fits into a continuous integration process of build, test, deploy.
node.js is required in order to install the library using the node package manager (npm).
It is not required to run an app using angular2, only to build it.
For any modern JS based application, as the complexity grows, the app becomes difficult to manage.
In order to make developing and managing complex applications simpler, there are frameworks such as Angular, React etc. and they provide number of tools for the same.
These tools are linting, scaffolding, running unit test cases, starting web server for local development, minify and creating build for the production use etc.
These tools are based on NodeJS as it is JavaScript only and therefore can be customize as per developers needs.
And that's the reason you need Node.js for Angular2 development.

Meteor kadira no such package

we are developing our meteor application in a windows environment using the unsupported windows version of meteor. The latest release is 0.8.3. Ok in the windows environment we used meteor add for the packages. But if i write
meteor add meteorhacks:kadira
meteor add kadira
I always get the no such package message. mrt command doesnt work. Any ideas?Thanks
I think this question is duplicated. Please refer here
meteor add meteorhacks:kadira is available only in Meteor 0.9 and above.
For Meteor below 0.9 you have to use Meteorite which is currently not supported by windows.
I'm developing an application in Meteor 0.8.3 and I have to use mrt: https://github.com/oortcloud/meteorite
The command is:mrt add kadira
I highly recommend you to upgrade as soon as possible. If you application depends on atmosphere packages, you'll have a hard time try to upgrade it later. Today most packages are obsolete because the creators don't care about it anymore.
Having in consideration that you're using an unsupported windows version: I don't really know if this is going to work. It's work great for Meteor at version 0.8.3 today.

Typescript command line compilation without NodeJS

I was looking over Typescript and was a bit confused about how you could build your js files from the ts files via the command line.
It implies in the documentation that you can do it easily through nodeJS, which would be great if I wanted a dependency on nodeJS... So is there any way to compile it via the command line without having nodeJS or visual studio?
This may seem crazy to some, but I would just put a build script step to output the javascript at the end if possible then package it into my release, as I tend to do most of my javascript development with RubyMine and don't want a dependency on nodeJS or Visual Studio for my build server.
If you install the TypeScript Tools without Visual Studio installed on the machine, tsc.exe and its dependencies will still get installed.
You can also just xcopy deploy tsc.exe (I don't have a definitive list of its dependencies, but it's pretty straightforward to figure out, or just copy everything that gets installed to the SDK folder) to a build server. The only thing unexpected you would need is msvcr110.dll, which you may or may not need to copy to tsc.exe's path.
The link in Ryan's answer is now heavily outdated and if you use it will generate a TS1005 error.
Here's what you want https://www.microsoft.com/en-us/download/details.aspx?id=55258 and it is still put in the same Program files x86 / Microsoft SDKs directory, and for me at least was not added to my path.

Node.js on Heroku?

I wonder if all Heroku addons - that are currently working for Rails - will work for Node.js once the support is there?
And what is the ETA for the launch of Node.js support?
Node.js is now officially supported on Heroku.
Several addons currently require specific ruby gems to be installed so I think Node.js will have its own separate set of addons.
As for launch, to my knowledge there is no ETA yet.
Whether or not an addon will work with node is going to specific to the addon itself, probably whether the addon requires a Ruby lib to work.
I'm currently using Loggly, RedisToGo, Mongolab, and RabbitMQ via Addons all with node.
It is supported by CEDAR stack on heroku
All you have to do is put into .gitignore node_modules directory and create Procfile eg.
web: node web.js
This is just a command to startup your application.
Important thing is that you should layout your app as node_module i wrote a blog post about it
http://no-fucking-idea.com/blog/2012/04/23/building-node-dot-js-module-using-npm/
So you can look it up.
url explaining how to deploy is here:
https://devcenter.heroku.com/articles/nodejs
Have fun!

Categories

Resources