-
Notifications
You must be signed in to change notification settings - Fork 156
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
ES6 modules proposal #705
Comments
I think it's the way to go for 1.X, though I'm more interested in LS 2.X. I'm willing to work on it, but I'm afraid I'll need some guidance. |
Another option would be a cli flag. |
Does 1.x really need it? I don't know of any runtime supporting es6-modules yet. |
@igl Ember is written in it (and ES6 modules are the only decent option for imports), and Angular 2.0 will be (actually, in straight ES6). Several transpilers exist. V8 is currently working on implementing it as I type this (I've seen a few recent commits). Multiple relevant transforms exist for Browserify. It's definitely coming. As for # ES6: import * as bar from 'foo';
# ES5: var bar = require('foo');
require! foo: {*: bar}
# ES6: import * as foo from 'foo'; var {bar} = foo;
# ES5: var foo = require('foo'), bar = foo.bar;
require! foo: {*, bar}
# ES6: import foo, {bar} from 'foo';
# ES5: Same as last example
require! foo: this, {bar} # or @, {bar}
# ES6: import bar, {baz} from 'foo';
# ES5: var bar = require('foo'), baz = bar.baz;
require! foo: bar, {baz}
# ES6: import bar from 'foo';
# ES5: var bar = require('foo');
require! foo: bar Haven't yet really thought about export syntax, though, but simply allowing |
Angular will be TypeScript, won't it be? |
Specifically AtScript, IIRC, but it transpiles to ES6 and Dart. On Mon, Apr 20, 2015, 11:05 ven [email protected] wrote:
|
nope. They "merged" AtScript into TypeScript. And I don't think it'll transpile to Dart :-). |
Never mind then. I haven't really been keeping up with that specific area On Mon, Apr 20, 2015, 11:42 ven [email protected] wrote:
|
I'm an Ember dev. I didn't use imports because I wanted to use LiveScript. ATM I just concatinate all class files with Gulp and transpile them to JavaScript. |
I think you can use |
Nice to know. Thank you 👍 |
I'm aware of I still find V8's recent module implementation work really exciting 1. Now, as for Angular 2, it is actually being written in AtScript, a literal On Mon, Apr 20, 2015, 13:33 ven [email protected] wrote:
|
as I said:
article here (which is good, imho) |
What if 1.4 is released, then breaking changes are included in a "1.5", but released as 2.0 (for the sake of semver) and "LS2" becomes "LS3"? |
@vendethiel Thank you for the link. I still miss some sort of export On Mon, Apr 20, 2015, 15:32 Rafael Belvederese [email protected]
|
Really appreciate ES6 module support since I'm developing an application with Ember.js. |
@gkz I like the idea of
-- These are okay, and even preferred, since being more point-free simplifies
-- them.
double = (* 2)
concat = foldr (++) []
-- (Pointful equivalents of above)
double x = x * 2
concat [] = []
concat (xs:xss) = xs ++ concat xss
-- This is not okay
import Data.Function (on)
a = ...
f = (((chr . (+ a) . (`mod` 26) . (flip (-)) (2 * a)) .) . (. ((+) `on` ord))
-- (More acceptable version of above)
a = ...
f k t = chr $ a + (ord k + ord t - 2*a) `mod` 26 Above in LiveScript: # These are okay, since being more point-free simplifies them.
double = (* 2)
concat = (.reduce (++), [])
# (Pointful equivalents of above)
double = (x) -> x * 2
concat = (list) ->
if list.length then list[0] ++ concat list[1 to] else []
mod = (x, y) --> x - y * Math.floor x / y
# This is not okay
a = ...
f = (((.<<. 16 .>>. 16) . (+ a) . (`mod` 26) . (- 2 * a)) .) . (. (+))
# (More acceptable version of above)
a = ...
chr = (.<<. 16 .>>. 16)
f = (k, t) -> chr a + mod k + t - 2*a, 26
|
Well, we can think of a syntax like |
I am not convinced that 1.x needs es6 modules at all. Do only i feel like this? Having |
2 years passed and still no body had time to implement import and export! |
this change doesnt matter in frontend. browsers have global space, so everything is accessible. i dont know why node.js (ops, error, ppl who use it) choose compiled language style to import/export functions. imo, it wont survive in implemented environment. ES6 doesn't fix 0.1 + 0.2 == 0.3 like problems, they do something good, something bad and something irrelevant. so, dont worry. |
@determin1st It's way more common and useful in browsers (Webpack and Rollup) than in Node (Babel and Reify. Node already has a working, fully functional, fully featured module loader that has nearly everything you would ever need in one, and they've had it since practically day 1. Browsers do not - all they had were |
@isiahmeadows i take what functions i need from favorite libraries and KISS - put them in one include file - that's all, no need to study how that zoo works and transpiles 8) MDN says, that this feature import/export is not working in any browser. so it lives in abstract transpilator world. sure, node had module loader from day 1, as browsers had <script> tag. |
Well...it's mildly out of date, then. Edit: Here's the Can I Use entry for it, which tells me that Chrome (as of 61) and Safari (as of 10.1) are shipping support for |
@determin1st |
@HosseinAgha I see it as a build environment, not a language itself. It will be cool if LiveScript (lsc) would be able to merge (.ls, .js) files into single (.js) file. @isiahmeadows And this seems to be an eval() with cookies 8) What about use case? Something dynamic dynamic? I'm not there yet.. |
@determin1st Read my edit, and please read up on ES6 modules and |
Question to people wanting es6 module support: I'm already using some plugins with my loader and in near future I'll code es6 modules plugin, if someone else beside me will use it I'll wait and gather some feedback about syntax. |
@bartosz-m I really liked your micros workaround. nice job! |
I didn't give up. Current version of livescript-next is good enough for my own projects, I'm happy with it now, and I have no spare time to work on it recently. Feel free to ask usage questions or report bugs / suggest features. Any feedback are welcome 😄 . |
@dk00 Cool thank you for clarification 😃 |
@HosseinAgha yes I'm going to implement |
It took me some time but finally I've got something to show:
Plugin enables usage of supercharged imports and exports: wildcards # main.ls
import 'modules/**' # inside of modules there are: foo.ls, Match.ls, Vector.ls // main.js
import foo from './modules/foo';
import Math from './modules/Math';
import Vector from './modules/Vector'; importing module into the scope # symbols.ls
export create = Symbol.for \create.core
export init = Symbol.for \initialize.core # main.ls
import ...
'./symbols' // main.js
import { init, create } from './symbols'; and other handy features. I'm waiting for some beta testers 😄 |
@bartosz-m livescript-plugin-loader not support vue , https://github.com/borestad/vue-livescript-loader supoort vue but not support livescript-transform-esm Is there any both support loader ? |
i write |
Unfortunately
import
andexport
are already used in LS, and I don't want to create a breaking change in the 1.X line.How would people feel if ES6 modules were supported using
import! ...
andexport! ...
?Sort of looks like
require! ...
and is the best alias I could think of.For 2.X, backwards compatibility will be broken and we can revert to using
import
andexport
The text was updated successfully, but these errors were encountered: