2

(Followup to this answer)

Please can someone confirm that the following syntax is still valid in ES6?

module "javascripts/bar" {
    export function Bar() {}
}

I am thinking about the scenario where I use concatenation. Yes I know HTTP2 will make concatenation moot, but I would like to concatenate my modules today.

If this is not valid, how should I construct my modules so that they remain valid in the same file?

11
  • 1
    It cannot be parsed by esprima, or transpiled by 6to5, so probably not. Commented Dec 15, 2014 at 18:09
  • 1
    Similarly, module is not on the latest list of keywords. (It'd be nice if the spec were actually readable, though, eh? I thought the ES5 spec was bad, but it's got nothing on the ES6 spec...) Commented Dec 15, 2014 at 18:13
  • @Felix is there a forum where I can ask detailed ES6 questions other than S/O? Commented Dec 15, 2014 at 18:13
  • 1
    Maybe esdiscuss.org . Commented Dec 15, 2014 at 18:13
  • 1
    @T.J.Crowder: (my thoughts as well) Commented Dec 15, 2014 at 18:17

1 Answer 1

4

This is the old module syntax that was removed. The above is no longer valid since Rev28 of the ES6 draft. Do not use this syntax any more it is not valid ES6. (relevant esdiscuss with it being removed) (esdiscuss coming to the conclusion to remove it)

ES6 has a module-per-file module. If a file is imported using import it will be treated as a module.

Update: I just noticed that Alex has written about it that is probably a good read on the subject. His links are wrong though.

Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.