-
Notifications
You must be signed in to change notification settings - Fork 4
CS2 Discussion: Features: import/export #7
Comments
IMO, module syntax should be the import statement from ES6. I totally agree that some of the features in By dropping the It made sense that CoffeeScript had its own class implementation or could have its own module implementation in the old days of ES5, because back then every library or toolset had to cater for themselves anyway. Currently, with ES6, a lot of these features are being consolidated, and it makes sense to support it. |
Welcome @dadleyy and @carlmathisen ! Very happy to have both of you here. @dadleyy raises some interesting points and does so in a well-reasoned way. If nothing else, I certainly agree with this:
I also agree with this:
and expect to use it as a fall-back argument for other such features in the future. Given this effort is likely to result in a major-version-bump at the very least, folks uninterested in the new features are always welcome to use CS v1. |
I hope to respond with more depth later, but off the top of my head, the chief advantages of
Considering a better alternative to Thoughts? |
I would also like to throw out an additional proposal:
The primary motivation is situations when you have a long list of member imports, having the "from" at the end is a little weird: import {
MemberOne,
MemberTwo,
MemberThree,
} from 'my-module'; could instead be: from 'my-module' import
MemberOne
MemberTwo
MemberThree though we'd need to think about what to do when you I'm not convinced this proposal would be worth the departure from ES6 but wanted to share it. Thoughts? |
Full ES2015 module support is, in my mind, the top-priority most-pressing issue facing CoffeeScript today, and the No. 1 reason that people are abandoning it in favor of ES6. I’ve written documentation explaining how to use CommonJS I consider module support to be so urgent that I think it should be built into the current CoffeeScript 1.x, not put off until whenever this new project gets off the ground. The consensus from the various issues in the main repo is that we want to essentially support ES2015 syntax as is, seeing as it’s so coffee-like already; and we would output Someone made a slapdash attempt at implementation in this pull request; I’ve continued a conversation on that thread to try to scope out what a proper implementation would be. I haven’t had much time to work on it, but I’m hoping to get at least a rough draft up on GitHub for others to poke holes in and gradually get polished, and get merged into CoffeeScript 1.x. I wholeheartedly support the idea of CoffeeScript6 and revamping the language for ES2015+ more broadly, but I think module support is so important and so urgently needed that we should make the effort to implement it now in the CoffeeScript we have, even if it means reimplementing it in a new architecture later. |
I agree 100% with @GeoffreyBooth . While I'd love to see @GeoffreyBooth I hope you share your forthcoming PR here at an early stage so that members of this community can contribute. Personally I'd love to take part. |
I’ve been working here. It’s in the very, very early stages: I have failing tests, and I can handle |
This is awesome, @GeoffreyBooth and I can only second what @rattrayalex said. I'll have a look at it as well sometime this week. Side note: with working on this PR, we're basically agreeing to do initial work on the original coffeescript codebase and not redux or decaf. Is that correct? |
@JimPanic yes, that’s what I meant about potentially reimplementing this later. I have a hunch that the Redux codebase would likely make a better starting point for the CS6 effort (this is a topic for an entirely separate thread, so let’s please not get into it here) so this PR will likely be the last major new feature in CoffeeScript 1.x, and we’ll have to redo it in CS6. But I think the potential duplication of effort is worth it, to stanch the bleeding of developers abandoning CoffeeScript in the meantime until CS6 can get anywhere close to beta. |
Understood and I agree. 👍
|
@GeoffreyBooth Oh man, this is kind of a mess. I have the same problem as you: I don't understand how those three files play together. Maybe this is also what the redux codebase was trying to fix. :) I'll continue to try to wrap my head around how all this works… |
I managed to get the first two test cases working:
The rest and especially the next one ( |
I would also like to mention that currently Coffeescript/CommonJS and ES6 handle namespaces differently. There needs to be a common way of making sure that both require environments co-exist correctly. In addition to that, and something I've run into a lot with CommonJS loading, is how to handle circular references with require statements. See this issue in Meteor for a good breakdown of this problem: |
@mrmowgli, the plan at least for the PR I'm working on is for CoffeeScript to leave the module handling to downstream tools, just as it does now with _ = require 'lodash' gets output as var _;
_ = require('lodash'); An import statement like: import _ from 'lodash' would get output as import _ from 'lodash'; In other words, just as CoffeeScript relies on other tools to process the |
Just updated my original comment on this issue. I'd say its pretty clear we're going to have |
Now that jashkenas/coffeescript@7667cb2 has happened, I think we can cross this one off the list. One down! |
Thank you all for your hard work on getting import/export support into CoffeeScript! |
This issue was moved to jashkenas/coffeescript#4905 |
With the adoption of es6 by many, many, many popular javascript frameworks and libraries, supporting
import
/export
has become very relevant to the adoption of coffescript in the codebases that use those frameworks. This issue has been brought up several times in the original coffeescript repository - see also #3162.At the time of writing this, the
import
andexport
keywords are treated by the coffescript lexer as reserved words and throws a compile-time error when encountered.original comment
The text was updated successfully, but these errors were encountered: