I'm trying to use coffeescript for my client-side code in Meteor, but it doesn't seem to work..
I've created client/views/welcome/index.coffee with the following content:
console.log 'this is welcome index'
But the console isn't logging anything and I don't see the file being loaded at the client.
Run the following command to add the coffeescript package to Meteor, which will enable the transpiling of coffeescript source:
meteor add coffeescript
Otherwise, coffeescript files will be silently ignored (there was a suggestion to improve this behavior). For now, you can make sure the package is added by checking for it in .meteor/packages.
Related
We are trying to create a code editor(IDE) in Angular 11. We mainly use java code in it. We need to show lint errors while typing and also beautifier in it. Is there any package or solution already available?
I just want to know how SystemJS works. My idea is that it executes modules transpiled for it, but I really don't know how it gets a System.import-ed module executed.
For instance, I have my Angular2 app transpiled with Gulp and Typescript to a bundle and load it via SystemJS. The app is loaded perfectly: I get no console errors in my browser, but the application doesn't start.
Do I need special prerequisites for transpiling and running Typescript code?
I followed this,
Go download and install VS Web Essentials
Add a new Item to your project, pick CoffeeScript as the item type
Write your CoffeeScript code, when you build the project or Solution, it will create the JavaScript code.
But, it does not create any compiled JS file.
How can I compile coffeescript? Do I need to install node.js?
I haven't tried Web Essentials for VS yet because it's easier for me to just include the coffee-script.js file using a script tag and compile it using the browser. I also console.log the compiled JavaScript output to the browser to see what it is generating. Here are a few examples using this technique:
https://github.com/jabdal/coffee-script-examples
Remarkably, it will sometimes find errors in the resultant JavaScript and go to the line with the error.
I'm guessing you could then send the JS back to the server and save that to a JS file (along with a checksum of the original coffeescript file). Then instead of compiling next time, you could include the JS file that is on the server if it is the same version (compare checksum before compiling on client).
I've read somewhere there is a .NET implementation of JavaScript that might work with the coffeescript compiler so that you could compile on the server without having to use Node but I don't think it would hurt to offload it on the client. A nice way would be a runat="server" tag for script type="text/coffeescript" tag so that the server would replace the coffeescript tags with javascript tags along with the compiled code and also generate corresponding js files where there are coffee files.
I'm keen to use coffeescript within Trigger.io and to do so I am following the details as described at http://docs.trigger.io/en/latest/tools/hooks.html
I've placed my coffeescript.js file in the hooks/prebuild directory as required but the build now fails. I've commented out everything in the coffeescript.js file to ensure it's not the file's contents.
It detects the coffeescript.js file in the prebuild directory as shown in the log output but then it can't find some file. Anyone else have this problem? I'm using version 1.4 of the Trigger Toolkit.
[INFO] Running (node) hook: coffeescript.js
[DEBUG] Running: 'node' '/Users/Will/forge-workspace/alpha-timing/hooks/prebuild/coffeescript.js' 'ios'
[ERROR] [Errno 2] No such file or directory
A slight tangent... but you might want to have a look at Brunch.io
I've recently started using it for building the JS for my trigger.io app and it works great. It can compile your coffeescript, js, css and more automatically. Comes with a watcher and auto-reload, so when you are developing and testing in browser it's very fast.
We use Node.js to transform the coffeescript into JS at the prebuild stage - it looks like you don't have it installed: go to http://nodejs.org/ to grab it.
Note you'll also need coffee-script to run that hook!
I've used Yeoman to make a quick project skeleton using the yo webapp generator command. In the resulting Gruntfile I see that it's setup to compile CoffeeScript but it seems like its just sticking compiled files in a tmp folder.
coffee: {
dist: {
files: {
'.tmp/scripts/coffee.js': '<%= yeoman.app %>/scripts/*.coffee'
}
},
},
How do these get included in the project during development. I'm not using RequireJS.
The yeoman docs are unclear on how to use coffeescript. They only mention that it gets automatically compiled.
Using yeomen 1.0.0-rc1.4. I use:
$ yo angular --coffee
The resulting project has controller and app scripts in CoffeeScript.
grunt configuration file remains in js (what is not really a problem).
Running
$ grunt test
runs tests and all seems fine.
$ grunt server
is also doing what one expects (build the app, test it, starts server, opens the app in web browser and starts watching for changes, so if I change a coffee script file, it is quickly reflected in the web broser.
Documentation also states, one can use yo to add particular pieces like
angular:controller
angular:directive
angular:filter
angular:route
angular:service
angular:decorator
angular:view
each can be called with a --coffee switch and get the script in CoffeeScript, e.g.:
yo angular:controller user --coffee
I just found an issue in the github repo referencing this problem. https://github.com/yeoman/generator-webapp/issues/12
It offers a temporary solution: https://github.com/yeoman/generator-webapp/issues/12#issuecomment-13731929