Giter Club home page Giter Club logo

ember-cli-coffees6's Introduction

Deprecation Notice

This addon is no longer needed, since version 1.16.0 of ember-cli-coffeescript.

ember-cli-coffees6 Ember Observer Score Build Status

ember-cli-coffeescript works great with ember-cli, but the syntax for module imports and exports is less than ideal:

`import Ember from 'ember'`

DummyController = Ember.Controller.extend()

`export default DummyController`

Enhance ember-cli-coffeescript with ember-cli-coffees6 and you can use a much more natural syntax:

import Ember from 'ember'

export default Ember.Controller.extend()

ember-cli-coffees6 depends on ember-cli-coffeescript, and does simple string substitution on the .coffee files before passing them through to the regular coffeescript compiler. It should work out of the box with anything that currently works with ember-cli-coffeescript, and changing to the new module syntax is option so it can be done one file at a time. If you find a case where this isn't true, please report an issue and it will be fixed!

Upgrading

If you are upgrading from a version before 0.3.0, you will need to add ember-cli-coffeescript to your package.json, as it's no longer included with ember-cli-coffees6

Installation

# if coffeescript is not already installed
ember install ember-cli-coffeescript

ember install ember-cli-coffees6

Supported syntax

This plugin aims to support all ES6 module syntax, see the tests for full examples.

Debugging

You can turn on verbose debugging output by adding the option in your Brocfile.js:

var app = new EmberApp({
  coffeeES6: {
    debug: true
  }
});

Running tests

npm test

Warnings / disclaimers

  1. export, default, and import are reserved words in coffeescript. It's possible that in future they will be implemented with a different meaning. You may have to refactor this code to work with possible future versions of coffeescript
  2. This currently works with ugly regex substitution and not a full parsing. It won't work for every possible expression or indentation etc.

Help us figure out more elegant ways to use new es6 features like imports and exports in coffeescript! It's a challenging ordeal.

ember-cli-coffees6's People

Contributors

alexspeller avatar devinrhode2 avatar ibroadfo avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

ember-cli-coffees6's Issues

File already exists error (ember-cli 0.1.3)

I get the below error when starting the bundled app server using ember-cli 0.1.3.

I've tried removing the tmp dir, no luck.

Everything works fine if I go back to ember-cli-coffeescript (0.4.0) and add back those ugly backticks ๐Ÿ˜ฟ

Happy to submit a PR rather than just an issue, just point me in the right direction. ๐Ÿ˜„

Serving on http://0.0.0.0:4200/app/
EEXIST, file already exists '/Users/nik/Projects/gelato/ember/tmp/coffee_script_filter-tmp_dest_dir-pCOOJXh5.tmp/gelato/app.js'
Error: EEXIST, file already exists '/Users/nik/Projects/gelato/ember/tmp/coffee_script_filter-tmp_dest_dir-pCOOJXh5.tmp/gelato/app.js'
  at Object.fs.openSync (fs.js:438:18)
  at Object.fs.writeFileSync (fs.js:977:15)
  at Object.copyPreserveSync (/Users/nik/Projects/gelato/ember/node_modules/broccoli-coffee/node_modules/broccoli-filter/node_modules/broccoli-kitchen-sink-helpers/index.js:150:8)
  at /Users/nik/Projects/gelato/ember/node_modules/broccoli-coffee/node_modules/broccoli-filter/index.js:41:19
  at promise.then.then.results.(anonymous function) (/Users/nik/Projects/gelato/ember/node_modules/broccoli-coffee/node_modules/broccoli-filter/node_modules/promise-map-series/index.js:8:27)
  at $$$internal$$tryCatch (/Users/nik/Projects/gelato/ember/node_modules/broccoli-coffee/node_modules/broccoli-filter/node_modules/rsvp/dist/rsvp.js:470:16)
  at $$$internal$$invokeCallback (/Users/nik/Projects/gelato/ember/node_modules/broccoli-coffee/node_modules/broccoli-filter/node_modules/rsvp/dist/rsvp.js:482:17)
  at $$$internal$$publish (/Users/nik/Projects/gelato/ember/node_modules/broccoli-coffee/node_modules/broccoli-filter/node_modules/rsvp/dist/rsvp.js:453:11)
  at $$rsvp$asap$$flush (/Users/nik/Projects/gelato/ember/node_modules/broccoli-coffee/node_modules/broccoli-filter/node_modules/rsvp/dist/rsvp.js:1531:9)
  at process._tickCallback (node.js:419:13)

ember-cli 0.2.0: Could not find module appname/app

After upgrading to ember-cli 0.2.0 I got the error Could not find module appname/app with my app here: https://github.com/devinrhode2/major-domo/tree/95cfed62b88c29f07c5f4f7ef1580f43d668f390

Because this module was using the latest ember-cli-coffeescript when the error occurred, I had raised the issue there first: kimroen/ember-cli-coffeescript#70 but after switching all import/exports to escaped js, and swapping the modules, thing bug went away. This means that the bug lies within coffees6 and/or how it invokes ember-cli-coffeescript.

But, switching just app.coffee to the default ember-init generated app.js fixes the issue. router.coffee has no issues and doesn't need to be touched. Therefore, coffees6 actually does work with ember-cli 0.2.0, if app.coffee is converted to app.js. (Also, escaping the import/exports in app.coffee doesn't sold the issue, with or without semicolons, it needs to be fully converted to javascript)

So, I'm just going to keep doing everything normally but with an app.js instead of an app.coffee.

And to be clear, cat node_modules/ember-cli-coffees6/node_modules/ember-cli-coffeescript/package.json shows coffees6 is using v0.10.0 of ember-cli-coffeescript.

I'm extremely certain of these statements which you can verify yourself, and I hope this saves you debugging time! Since this module is already a hack, I think forcing users to do an app.js instead of app.coffee is more than acceptable, and we should instead focus efforts on making a more elegant solution to using import/exports in coffeescript.

Fresh install: reserved word 'import'

Hi there, I've a fresh ember-cli app, I've added your lib with ember install:addon ember-cli-coffees6 and tried to compile this app.coffee:

import Ember from 'ember';
import Resolver from 'ember/resolver';
import loadInitializers from 'ember/load-initializers';
import config from './config/environment';

Ember.MODEL_FACTORY_INJECTIONS = true

App = Ember.Application.extend
  modulePrefix: config.modulePrefix
  podModulePrefix: config.podModulePrefix
  Resolver: Resolver

loadInitializers App, config.modulePrefix

export default App;

but I get in command line:

File: project/app.coffee (1)
reserved word 'import'
[stdin]:1:1: error: reserved word 'import'
import Ember from 'ember';
^^^^^^

I never had the original coffee package in package.json, what could be wrong?

.coffee tests no longer show up when using ember-cli 0.2.0

I'm just in the process of upgrading ember-cli to 0.2.0 and I've noticed that after updating the dependencies mentioned in the guide, my tests (which are all written in coffeescript) no longer get picked up by the test runner.

If I switch coffeescript compilation over to the ember-cli-coffeescript addon the tests get picked up but then everything breaks due to error: reserved word "import"

Has anyone ever seen this before? I'm going to keep digging but any guidance would be much appreciated.

ember g controller broken

I'm using ember-cli-coffees6 which relies on ember-cli-coffeescript, when I run

ember generate controller <foo>

I get this error:

version: 0.1.3
Could not find watchman, falling back to NodeWatcher for file system events
installing
Cannot call method 'call' of undefined
TypeError: Cannot call method 'call' of undefined
  at Class.module.exports.beforeInstall (/Users/bmckay/Ember/rew_mobile/node_modules/ember-cli-coffees6/node_modules/ember-cli-coffeescript/blueprints/controller/index.js:9:69)
  at $$$internal$$tryCatch (/Users/bmckay/Ember/rew_mobile/node_modules/ember-cli/node_modules/rsvp/dist/rsvp.js:470:16)
  at $$$internal$$invokeCallback (/Users/bmckay/Ember/rew_mobile/node_modules/ember-cli/node_modules/rsvp/dist/rsvp.js:482:17)
  at /Users/bmckay/Ember/rew_mobile/node_modules/ember-cli/node_modules/rsvp/dist/rsvp.js:1066:13
  at $$rsvp$asap$$flush (/Users/bmckay/Ember/rew_mobile/node_modules/ember-cli/node_modules/rsvp/dist/rsvp.js:1531:9)
  at process._tickCallback (node.js:419:13)

This is a repost of kimroen/ember-cli-coffeescript#40

Update ember-cli generators to generate coffeescript files without backticks

Hello,

I am using this library and while I can run e.g. ember generate route myroute and generate the route file as myroute.coffee, the actual contents include backticks.

It'd be nice if we could generate the coffeescript files without backticks (thats through ember-cli-coffeescript currently)

Any thoughts?

Handle named exports?

Running ember generate initializer foo for example generates the following file:

export function initialize(/* container, application */) {
  // application.inject('route', 'foo', 'service:foo');
};

export default {
  name: 'foo',
  initialize: initialize
};

Breaks ember-cli-rails exclude_ember_deps option

When using this library in conjunction with rwz/ember-cli-rails the latter's exclude_ember_deps option no longer has any effect. Can't tell exactly why yet, but my first guess is that they both munge legacyFilesToAppend. Going to dig into this further, but I'd appreciate any insight.

ember generate resource broken

Using ember generate resource <resource name> doesn't work correctly. It tries to build .JS files while the other blueprints use .COFFEE.

So I get this error:

version: 0.1.5
Could not find watchman, falling back to NodeWatcher for file system events
installing
  create app/pods/properties/search/model.js
installing
  create tests/unit/pods/properties/search/model-test.js
installing
  create app/pods/properties/search/route.js
  create app/pods/properties/search/template.hbs
ENOENT, no such file or directory '/Users/bmckay/Ember/rew_mobile/app/router.js'
Error: ENOENT, no such file or directory '/Users/bmckay/Ember/rew_mobile/app/router.js'
  at Object.fs.openSync (fs.js:438:18)
  at Object.fs.readFileSync (fs.js:289:15)
  at addRouteToRouter (/Users/bmckay/Ember/rew_mobile/node_modules/ember-cli/blueprints/route/index.js:106:19)
  at Class.module.exports.afterInstall (/Users/bmckay/Ember/rew_mobile/node_modules/ember-cli/blueprints/route/index.js:66:7)
  at $$$internal$$tryCatch (/Users/bmckay/Ember/rew_mobile/node_modules/ember-cli/node_modules/rsvp/dist/rsvp.js:490:16)
  at $$$internal$$invokeCallback (/Users/bmckay/Ember/rew_mobile/node_modules/ember-cli/node_modules/rsvp/dist/rsvp.js:502:17)
  at $$$internal$$publish (/Users/bmckay/Ember/rew_mobile/node_modules/ember-cli/node_modules/rsvp/dist/rsvp.js:473:11)
  at Object.$$rsvp$asap$$flush [as _onImmediate] (/Users/bmckay/Ember/rew_mobile/node_modules/ember-cli/node_modules/rsvp/dist/rsvp.js:1581:9)
  at processImmediate [as _immediateCallback] (timers.js:345:15)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.