Minor questions on new module BNF

Domenic Denicola domenic at domenicdenicola.com
Sun Jun 2 20:59:13 PDT 2013


Sam was saying that http://wiki.ecmascript.org/doku.php?id=harmony:modules is up to date. If so, I'm seeing a few things missing from the BNF. It would be great to get these clarified so people can start writing accurate transpilers.

1. It looks like `ExportDeclaration` can only occur inside `ModuleBody`, which itself can only occur as part of the named `ModuleDeclaration` production. I thought we would be able to export things without explicit named module declaration, so shouldn't `ExportDeclaration` be added to `ScriptElement`? Or perhaps to `Statement`? At http://wiki.ecmascript.org/doku.php?id=harmony:modules_examples the "compiler/Lexer.js" example contains such a situation, which seems invalid from the current grammar.

2. Is there any way to simply "execute" a module that does not export anything? This is a common technique in both client and server-side JavaScript today, e.g.

```js
// initSubsystem1.js
console.log("initializing subsystem 1...");

// initSubsystem2.js
console.log("initializing subsystem 2...");

// init.js
require("./initSubsystem1");
require("./initSubsystem2");
```

On the client side this is common for e.g. plugins:

```js
var Backbone = require("backbone");
require("backbone.layoutmanager");

// now `Backbone` has been augmented with a `Backbone.LayoutView` property we can use.
```

I don't see any way to do this, except perhaps via

```js
import defaultExportWillBeUndefinedSoThisBindingIsPointless from "./initSubsystem1";
import thisOneTooOhMyPoorScopeIsBeingPolluted from "./initSubsystem2";
```

A production of the form `"import" ModuleSpecifier ";"` would probably help this.


More information about the es-discuss mailing list