What use cases does this solve? From: es-discuss [mailto:es-discuss-boun...@mozilla.org] 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/file.js 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, bar.foo} from "other" /* option a) */ var api = { foo: a, fooOther: b, fooBar: bar.foo hello: function() { alert('module') }; } export default api /* option b) single module declaration module apiInternalName { import {foo} from "something" import {foo as fooOther, bar.foo as fooBar} from "other" function hello() { alert('module') }; } */ single/file.js module barInternalName { class foo {} } main.js 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 : index.html <script src="package/file.js"></script> <script> // import from package import {foo, bar} from "other"; </script>
_______________________________________________ es-discuss mailing list es-discuss@mozilla.org https://mail.mozilla.org/listinfo/es-discuss