Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
export function getTypescriptWorkerPlugin(wco: WebpackConfigOptions, workerTsConfigPath: string) {
const { buildOptions } = wco;
let pluginOptions: AngularCompilerPluginOptions = {
skipCodeGeneration: true,
tsConfigPath: workerTsConfigPath,
mainPath: undefined,
platform: PLATFORM.Browser,
sourceMap: buildOptions.sourceMap.scripts,
forkTypeChecker: buildOptions.forkTypeChecker,
contextElementDependencyConstructor: require('webpack/lib/dependencies/ContextElementDependency'),
logger: wco.logger,
// Run no transformers.
platformTransformers: [],
// Don't attempt lazy route discovery.
discoverLazyRoutes: false,
};
pluginOptions = _pluginOptionsOverrides(buildOptions, pluginOptions);
return new AngularCompilerPlugin(pluginOptions);
}
],
},
],
},
resolve: {
alias: {
images: rootRelativePath("images"),
},
},
plugins: [
new AngularCompilerPlugin({
entryModule: `${browserWindowAppPath("./app.module")}#AppModule`,
additionalLazyModules: {
["./_db-view/db-view.module#DbViewModule"]: browserWindowAppPath("./_db-view/db-view.module.ts"),
},
platform: PLATFORM.Browser,
skipCodeGeneration: !aot,
tsConfigPath: tsConfigFile,
compilerOptions: readConfiguration(tsConfigFile).options,
nameLazyFiles: true,
contextElementDependencyConstructor: require("webpack/lib/dependencies/ContextElementDependency"),
discoverLazyRoutes: true, // TODO disable "discoverLazyRoutes" once switched to Ivy renderer
directTemplateLoading: false,
}),
],
optimization: {
splitChunks: {
cacheGroups: {
commons: {
test: /[\\/]node_modules[\\/]|[\\/]vendor[\\/]/,
name: "vendor",
chunks: "all",
new DefinePlugin({
BUILD_ANGULAR_COMPILATION_FLAGS: JSON.stringify(angularCompilationFlags),
}),
new AngularCompilerPlugin({
contextElementDependencyConstructor: require("webpack/lib/dependencies/ContextElementDependency"),
tsConfigPath: tsConfigFile,
compilerOptions: {
preserveWhitespaces: false,
disableTypeScriptVersionCheck: true,
strictInjectionParameters: true,
fullTemplateTypeCheck: angularCompilationFlags.aot || angularCompilationFlags.ivy,
ivyTemplateTypeCheck: angularCompilationFlags.ivy,
enableIvy: angularCompilationFlags.ivy,
...readConfiguration(tsConfigFile).options,
},
platform: PLATFORM.Browser,
skipCodeGeneration: !angularCompilationFlags.aot,
nameLazyFiles: true,
discoverLazyRoutes: true, // TODO disable "discoverLazyRoutes" once switched to Ivy renderer
directTemplateLoading: false,
entryModule: `${browserWindowAppPath("./app.module")}#AppModule`,
additionalLazyModules: {
["./_db-view/db-view.module#DbViewModule"]: browserWindowAppPath("./_db-view/db-view.module.ts"),
},
}),
],
optimization: {
splitChunks: {
cacheGroups: {
commons: {
test: /[\\/]node_modules[\\/]|[\\/]vendor[\\/]/,
name: "vendor",
isDevEnv: metadata.env.isDevelopment(),
isProdEnv: metadata.env.isProduction(),
isHrm: hrmEnabled,
},
}),
new webpack.EnvironmentPlugin({
NODE_ENV_RUNTIME: metadata.env.value,
}),
new CircularDependencyPlugin({
exclude: /([\\\/])node_modules([\\\/])/,
failOnError: true,
}),
new AngularCompilerPlugin({
// compilerOptions: {},
entryModule: `${path.join(metadata.paths.src, "app/app.module")}#AppModule`,
platform: PLATFORM.Browser,
skipCodeGeneration: !aotEnabled,
tsConfigPath: metadata.paths.tsConfig,
}),
],
},
development: {
mode: "development",
devServer: {
port: metadata.devPort,
host: metadata.devHost,
hot: hrmEnabled,
inline: true,
stats: "minimal",
clientLogLevel: "error",
},