package keyword reserved?

Domenic Denicola domenic at
Fri Apr 11 14:25:54 PDT 2014

What use cases does this solve?

From: es-discuss [mailto:es-discuss-bounces at] On Behalf Of Jonathan Bond-Caron
Sent: Friday, April 11, 2014 16:56
To: es-discuss
Subject: package keyword reserved?

What's the history of the unused keyword "package", is it from Java?

Been thinking about this lately, could an external module be called a package?

package "something" {
  export class foo {}

package "other" {
  export class foo {}

 export module bar {
        export class foo {}

import {foo as a} from "something"
import {foo as b,} from "other"

/* option a) */
var api = {
   foo: a,
   fooOther: b,
   hello: function() {  alert('module') };

export default api

/*  option b) single module declaration
module apiInternalName {
  import {foo} from "something"
  import {foo as fooOther, as fooBar} from "other"
  function hello() {  alert('module') };

module barInternalName {
  class foo {}

module api from 'package/file'
module bar from 'single/file'

Some thoughts:

-          Literal modules are allowed only within packages (no module nesting) or a single module per file

-          import() semantics don't change too much (I think)

-          The subtle difference is an internal module is the declaration mechanism for exporting an api, a package is used for code organisation.

-          The module pattern is optional, can import from packages directly :

<script src="package/file.js"></script>
    // import from package
    import {foo, bar} from "other";

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <>

More information about the es-discuss mailing list