antonybudianto / angular-starter

:star: Gulp Angular Starter using TypeScript (Updated to 4.4.3)

Home Page:https://antonybudianto.github.io/angular-starter/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Compiling only ts into src/tmp seems to conflict with modularity practices

ndw opened this issue · comments

Issue Overview

Compiling into src/tmp breaks modularity using moduleId: module-id

Issue Description

One emerging school of thought on component modularity seems to be to use

@Component({
    moduleId: module.id,
   ...
})

to allow relative paths to templateUrls. Because this starter compiles into src/tmp,
that practice doesn't work. The absolute path formed by the module.id is in src/app but the code looking for it is in src/tmp and the HTML files cannot be found.

Reproducables

Insert any component using the aforementioned modularity design.

Information

Operating System Ubuntu
Node version 5.12.0
NPM Version 3.8.6
Environment Browser

I'm still pretty much a n00b in the Angular 2 space, so I'm not asserting that you should fix it, only that it seems like a design pattern that might be useful.

Since I had to separate transpiled files (along with sourcemaps) so that it didn't get messy with the original TypeScript files, I had to save the output to different directory.

You can try https://github.com/antonybudianto/angular-webpack-starter for relative path (and more features too)

Ok. I'll take a look. I wonder if the build process couldn't simply copy the HTML files into src/tmp as well as the transpiled files.

Sure you can copy them as separate gulp process, I'd love to accept a PR for that

Ok. I'll take that as a challenge :-); I couldn't get the angular-webpack-starter code to run at all.

Well, that turned into a #fail. Configuring html and watch-html tasks was reasonably straightforward. It fixes the bug I reported, but the relative path issue runs deeper than that. Unit tests and build environments don't work with the moduleId: module.id approach and I fear fixing those problems is well beyond my current skill level. C'est la vie.

@ndw , can you push your work? so I can check it out, thank you.

Sure, it's in the copyhtml branch here: https://github.com/ndw/angular2-starter/tree/copyhtml

I modified the todolist component to use the moduleId approach. Running it in develop works fine but attempting to build an actual release version fail.

@ndw I've cherry-picked your commit to my branch, it's now on #177, please try and test it out, thanks!

Yes, that seems to work. Thanks!

I pulled both feat-relativepath and feat-relative-path-1, FYI.

@ndw Ok, I need to improve the copying code first (copy only changed file), then merge it soon