it is possible to span namespaces in multiple files.
// namespaces.tsnamespaceApp{exportconstmyVariable="hello";}// app.ts/// <reference path="./path-to-name-space/namespace.ts"/>namespaceApp{console.log(myVariable);// my variable is available in the app.ts file}
exported members from any namespace file, can be accessed in any other file in the same namespace.
every file that has import/export statements, is a module, modules have module scope.
files with no import/export statements, are not scripts, scripts are available in the global scope.
when importing something from a module, the module loader will look into the imported module, grab the variable, and define it in the importing module scope.
popular module loaders are: amd, system, commonjs, umd.
js config necessary to use the ES6 modules:
{"compilerOptions":{"module":"es2015"}}
namespaces and ES6 modules are not compatible.
bundlers like webpack, rollup, etc. can bundle namespaces and ES6 modules.
bundlers can also bundle multiple files into a single file.
bundlers convert modules to bundles (non-model, single file) so that modules can work in older browsers.
if models are bundled, the browser needs to make a request to get every single imported file (in browser environments).