Dmitry Soshnikov (2013-09-09T18:32:14.000Z)
domenic at domenicdenicola.com (2013-09-25T01:29:30.392Z)
On Mon, Sep 9, 2013 at 6:26 AM, Sam Tobin-Hochstadt <samth at cs.indiana.edu>wrote: > There are no nested modules. Thanks, let me understand further: So, technically, if I have an external file "foo.js" like this: ```js export function foo() {}; module "bar" {} ``` then it's illegal (I have a nested module "bar" inside module "foo" represented by "foo.js")? What if "foo.js" doesn't contain "export" statements? ```js function foo() {}; module "bar" {} ``` Is it a bundled module collection now (with the only module "bar" inside)? And this file can be loaded only via module loader as you mention below, but not using "import" or "module" statement? > Bundled collections of modules are loaded primarily by loading them or > referencing them using a module loader, and then importing from the > individual modules they define. To double-check: File "foo.js": ```js export default function foo() {} ``` can be loaded as: ```js import foo from "foo"; ``` or: ```js module foo from "foo"; ``` But the file "bar.js": ```js module "bar" { export default function bar() {} } ``` Cannot be loaded as: ```js import bar from "bar"; ``` or: ```js module bar from "bar"; ``` ? In other words, everything we want to be loaded via "import" or "module" statements, _should_ be file-modules, not inner modules with "module" directive, correct? > In the browser (this is not intended to be part of the language > semantics), the default rule for going from a module name like "foo" > to a URL like "http://example.com/foo.js" will add ".js". OK. > No, you can't. The latter means the same as: > > ```js > import { foo } from "foo"; > export { foo }; > ``` > > except without adding `foo` to the local scope. It doesn't expose > anything unexported. > > I see, so it's just further propagation passing export of not my module through from my module, as it would be my export; thanks.