package keyword reserved?

Jonathan Bond-Caron jbondc at
Fri Apr 11 13:56:07 PDT 2014

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