-
Notifications
You must be signed in to change notification settings - Fork 11.9k
Description
I think the docs for skipCodeGeneration are wrong? According to the docs,
skipCodeGeneration: Optional, defaults to false. Disable code generation and do not refactor the code to bootstrap. This replaces templateUrl: "string" with template: require("string") (and similar for styles) to allow for webpack to properly link the resources.
However, rewriting the Urls seems to be the responsibility of the @ngtools/webpack loader, which can be used standalone without the AngularCompiler as long as a tsConfigPath is specified.
const ngToolsLoader = {
loader: '@ngtools/webpack',
options: {
tsConfigPath: TS_CONFIG_FILE
}
};So it seems to me the @ngtools/webpack loader is equivalent to a typescript compiler plus the ability to rewrite templateUrl and syleUrls.
This brings me to 2 things,
-
In development it makes more sense to use the JIT compiler. Is there any reason you would want to use the compiler plugin in development with
skipCodeGenerationset totrueas opposed to just not using the plugin at all? -
If the
@ngtools/webpackloader is responsible for compiling the typescript then I think any options that affect the typescript compilation process should be moved to the loader. For example, if I am only using the loader in development then there is no way for me to enable type checking unless I also include the plugin and settypeCheckingtotruein the plugin options.
I believe it is good to use the same loaders for development and production builds because different loaders may behave slightly different. For example, I could use the ts-loader and the angular2-template-loader in development and not use the @ngtools/webpack loader at all but the angular2-template-loader is able to resolve files without a file extension (maybe using Webpack resolve config?) where as the @ngtools/webpack will fail without the file extension. All of a sudden when you build for production you will get an error like
Couldn't resolve resource foo.template from C:/path/to/project/app/components/foo/foo.component.ts
You can probably imagine how confusing this might be.
Also, I think the docs should mention that the generated code is held in memory along side the source code because this is something that could easily trip up people trying to use the plugin. It might also be good to include an option to write the generated factories to disk somewhere for debugging purposes.
One last thing, thank you to everyone working on these Webpack integrations!