Comments (7)
angular2-template-loader is great for JiT builds along with awesome-typescript-loader, also great for testing, but JiT builds are no longer acceptable production solutions given their longer than reasonable render times.
For AoT, @ngtools/webpack is used in place of the combination of awesome-typescript-loader and angular2-template-loader, and the AoTPlugin (shipped within @ngtools/webpack) takes care of your ngc compilation (ngc is a wrapper around tsc that a) transpiles your typescript, and b) does the Ahead-Of-Time compilation that is the namesake of AoT).
For example, here's my loader configuration for JiT builds and AoT builds:
exports.ts_JiT = {
test: /\.ts$/,
loaders: [
'awesome-typescript-loader',
'angular2-template-loader'
],
exclude: [ /\.(spec|e2e|async)\.ts$/ ]
};
exports.ts_AoT = {
test: /\.ts$/,
loader: '@ngtools/webpack'
};
And my plugin configuration for the AoTPlugin:
const AotPlugin = require('@ngtools/webpack').AotPlugin;
...
exports.aot = new AotPlugin({
tsConfigPath: path.resolve('./tsconfig-aot.json'),
mainPath: path.resolve('./src/main.ts'),
entryModule: path.resolve('./src/app/app.module') + '#AppModule'
});
from angular2-template-loader.
Should be noted though that apparently @ngtools/webpack can also handle JiT builds, I'm just used to this particular toolchain and it's been good to me. :) Much respect, @TheLarkInn.
from angular2-template-loader.
Oh and I wasn't suggesting you were giving the LarkInn any grief, I just felt it was time for me to give him some props. :)
from angular2-template-loader.
Hi yes this project is actively used in different places however the angular AOT plugin and @ngtools ships with its own template inlining feature. When I first created this project, I was not a maintainer of the webpack org. Since joining the webpack core team, this repo has been neglected a bit but I am open to PRs and features.
from angular2-template-loader.
I'm not up-to-date with angular-cli and @ngtools, so here I'm asking: what would be the alternative path to not use this loader anymore? Of course, still remaining with angular 2, webpack 2, typescript 2, ...
Thanks
from angular2-template-loader.
Hi @nikolasleblanc and thanks for your info!
My bad for not being clear: @TheLarkInn is doing a great job, was just asking him what is he suggesting, given the current "work overload" and progress in angular-cli .
Also (my bad again), I'm aware of JIT Vs AOT, and before some recent issues I had with awesome-typescript-loader and some I'm now having with angular2-template-loader, my team was happy bundling both a dev JIT build as well as an AOT production build, the latter also with angular-router-loader and lazy-loading (also waiting on next angular 4 to see some more improvements on tree shaking).
Now, it's a couple of days that we're stuck with these weird issues, in particular #50 and other similar listed here.
Back to your experience, if I got it right: angular-cli and/or @ngtools/webpack can take the place of awesome-typescript-loader + angular2-template-loader, both for JIT and AOT builds.
Q1: Is that right?
Q2: What happens to lazy-loading in that case?
Thanks for your help
from angular2-template-loader.
Back to your experience, if I got it right: angular-cli and/or @ngtools/webpack can take the place of awesome-typescript-loader + angular2-template-loader, both for JIT and AOT builds.
Yup. Just, personally, I stick to angular2-template-loader and awesome-typescript-loader for my JiT stuff, which is really just for e2e and testing since they compile faster.
Q2: What happens to lazy-loading in that case?
Pretty sure you can bring in angular-router-loader as part of your JiT build, and @ngtools/webpack handles lazy loaded routes for you when building AoT. See https://www.npmjs.com/package/@ngtools/webpack#features.
Recognizing the use of loadChildren in the router, and bundling those modules separately so that any dependencies of those modules are not going to be loaded as part of your main bundle. These separate bundles will be pulled out of the critical path of your application, making your total application bundle much smaller and loading it much more performant.
Re your issue #50, I commented there.
from angular2-template-loader.
Related Issues (20)
- templateUrl and styleUrl, order, existence, shouldn't matter HOT 3
- [Help Wanted] Transition from String to AST parsing. HOT 3
- 0.6.2 Can't have comments between Component decorator and class definition HOT 2
- Bug: space after templateUrl and : causes No ResourceLoader error HOT 1
- templateUrl Regex fails to capture when comment follows HOT 11
- option to prefix the require url (for example with !to-string-loader!raw-loader!) HOT 1
- Is your documentation right? HOT 4
- Adding module loaders when webpack.config.js is not present in Angular-cli project HOT 1
- Angular 4 compatibility? HOT 3
- [Resolve problem] Deal with absolute path
- Angular 4 loader compatibility
- TemplateURL and StyleURL not loaded for couple of component
- No template specified for component with `template: require('./templates/my.tpl.html'),` when running `ngc -p tsconfig.json` HOT 3
- Please update to latest version of loader-utils HOT 3
- Rename this plugin
- HTML file content gets into the URL HOT 1
- Parsing doesn't support quoted JSON field names
- DeprecationWarning from loaderUtils HOT 3
- Doesn't work with raw-loader v2.0.0 HOT 8
- Template is loaded as a es module object instead of a string in modern Webpack HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from angular2-template-loader.