-
Notifications
You must be signed in to change notification settings - Fork 2.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(angular): add support for incremental builds to the webpack-serv…
…er executor
- Loading branch information
1 parent
a097997
commit c3ab94d
Showing
12 changed files
with
174 additions
and
51 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
49 changes: 49 additions & 0 deletions
49
packages/angular/src/builders/webpack-server/lib/configure-buildable-libs-support.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
import { BuilderContext } from '@angular-devkit/architect'; | ||
import { executeDevServerBuilder } from '@angular-devkit/build-angular'; | ||
import { AngularWebpackPlugin } from '@ngtools/webpack'; | ||
import { joinPathFragments } from '@nrwl/devkit'; | ||
import { WebpackNxBuildCoordinationPlugin } from '@nrwl/web/src/plugins/webpack-nx-build-coordination-plugin'; | ||
import { | ||
createTmpTsConfig, | ||
DependentBuildableProjectNode, | ||
} from '@nrwl/workspace/src/utilities/buildable-libs-utils'; | ||
import { isNpmProject } from 'nx/src/project-graph/operators'; | ||
|
||
type Transforms = Parameters<typeof executeDevServerBuilder>[2]; | ||
type WebpackConfiguration = Parameters<Transforms['webpackConfiguration']>[0]; | ||
|
||
export function configureBuildableLibsSupport( | ||
baseWebpackConfig: WebpackConfiguration, | ||
context: BuilderContext, | ||
projectRoot: string, | ||
buildTargetName: string, | ||
buildTargetTsConfigPath: string, | ||
dependencies: DependentBuildableProjectNode[] | ||
) { | ||
const tsConfig = createTmpTsConfig( | ||
joinPathFragments(context.workspaceRoot, buildTargetTsConfigPath), | ||
context.workspaceRoot, | ||
projectRoot, | ||
dependencies | ||
); | ||
process.env.NX_TSCONFIG_PATH = tsConfig; | ||
|
||
// We can't just pass the tsconfig path in memory to the angular builder | ||
// function because we can't pass the build target options to it, the build | ||
// targets options will be retrieved from the project configuration. | ||
// Therefore, we overwrite the tsconfig path that comes in the webpack | ||
// configuration for the AngularWebpackPlugin to use the temporary tsconfig. | ||
const angularWebpackPlugin = baseWebpackConfig.plugins.find( | ||
(plugin) => plugin.constructor.name === AngularWebpackPlugin.name | ||
) as unknown as AngularWebpackPlugin; | ||
angularWebpackPlugin.options.tsconfig = tsConfig; | ||
|
||
const deps = dependencies | ||
.filter((dep) => !isNpmProject(dep.node)) | ||
.map((dep) => dep.node.name); | ||
baseWebpackConfig.plugins.push( | ||
new WebpackNxBuildCoordinationPlugin( | ||
`nx run-many --target=${buildTargetName} --projects=${deps.join(',')}` | ||
) | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,2 @@ | ||
export * from './configure-buildable-libs-support'; | ||
export * from './normalize-options'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -17,4 +17,5 @@ export interface Schema { | |
hmr?: boolean; | ||
watch?: boolean; | ||
poll?: number; | ||
buildLibsFromSource?: boolean; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3969,7 +3969,7 @@ | |
dependencies: | ||
tslib "^2.0.0" | ||
|
||
"@ngtools/[email protected]": | ||
"@ngtools/[email protected]", "@ngtools/webpack@~14.0.0": | ||
version "14.0.0" | ||
resolved "https://registry.yarnpkg.com/@ngtools/webpack/-/webpack-14.0.0.tgz#13a37933f13a8aa587697b7db7be6f1f20a360c1" | ||
integrity sha512-lUcJ5DiRCY+Xj01R38bDbAlELbO+0yT3n4zshBeiuzo/Lc+yQM2XhVe9stsI5I+SwH6YsCU9kp+jb7iaZh7L7w== | ||
|