I just can't seem to understand modules and paths. I'm writing a Chrome extension and trying to use typescript with angular2. I kinda got it working once, but I wanted to restructure my directories. It seems like every time I want to get a project setup or add files or pages I have this issue. Is there anywhere to go to learn the rules for locating modules and javascript/typescript files?
What I want to do is have a src folder with my html, css (or less/sass), and typescript files and a www folder with my html, css and compiled js files. I've setup my grunt tasks and they compile fine. Since I'm using Angular 2 and in an extension I can't have inline scripts, I have two separate scripts for each page I'm creating, a src/pages/index-page.ts script that has the System setup and is loaded directly from www/index.html with <script src="js/pages/index-page.js"></script>:
declare var System : any;
System.config({
packages: {
appScripts: {
defaultExtension: 'js'
}
}
});
System.import('js/pages/index-boot')
.then(null, console.error.bind(console));
And the src/pages/index-boot.ts script that it should load
import {provide} from 'angular2/core';
import {bootstrap} from 'angular2/platform/browser';
import {ROUTER_PROVIDERS, APP_BASE_HREF, LocationStrategy, HashLocationStrategy} from 'angular2/router';
import {IndexApp} from './index-app';
bootstrap(IndexApp, [
ROUTER_PROVIDERS,
provide(LocationStrategy, { useClass: HashLocationStrategy })
]);
Of course I get a network failure trying to load /www/js/pages/index-boot. If I add the js, then it loads that file, but then I get errors finding router and index-app.
Why is index-page trying to load index-boot in the browser without the extension? Do I need to organize my files differently? Is there a site somewhere to explain all of this? I don't get why I have to have three separate code files for one page (System config and import boot, boot, and app).