diff --git a/packages/schematics/angular/workspace/files/pnpm-workspace.yaml.template b/packages/schematics/angular/workspace/files/pnpm-workspace.yaml.template new file mode 100644 index 000000000000..90a89a59b109 --- /dev/null +++ b/packages/schematics/angular/workspace/files/pnpm-workspace.yaml.template @@ -0,0 +1,8 @@ +packages: + - '.' + +allowBuilds: + '@parcel/watcher': false + esbuild: false + lmdb: false + msgpackr-extract: false diff --git a/packages/schematics/angular/workspace/index.ts b/packages/schematics/angular/workspace/index.ts index 85205042f3e3..60dd9ac7d0a6 100644 --- a/packages/schematics/angular/workspace/index.ts +++ b/packages/schematics/angular/workspace/index.ts @@ -18,7 +18,7 @@ import { } from '@angular-devkit/schematics'; import { execSync } from 'node:child_process'; import { latestVersions } from '../utility/latest-versions'; -import { Schema as WorkspaceOptions } from './schema'; +import { PackageManager, Schema as WorkspaceOptions } from './schema'; export default function (options: WorkspaceOptions): Rule { return () => { @@ -48,6 +48,9 @@ export default function (options: WorkspaceOptions): Rule { return mergeWith( apply(url('./files'), [ options.minimal ? filter((path) => !path.endsWith('editorconfig.template')) : noop(), + packageManager !== PackageManager.Pnpm + ? filter((path) => !path.endsWith('pnpm-workspace.yaml.template')) + : noop(), applyTemplates({ utils: strings, ...options, diff --git a/packages/schematics/angular/workspace/index_spec.ts b/packages/schematics/angular/workspace/index_spec.ts index a13a7d3e1bb7..fbd2643b4052 100644 --- a/packages/schematics/angular/workspace/index_spec.ts +++ b/packages/schematics/angular/workspace/index_spec.ts @@ -9,7 +9,7 @@ import { SchematicTestRunner } from '@angular-devkit/schematics/testing'; import { parse as parseJson } from 'jsonc-parser'; import { latestVersions } from '../utility/latest-versions'; -import { Schema as WorkspaceOptions } from './schema'; +import { PackageManager, Schema as WorkspaceOptions } from './schema'; describe('Workspace Schematic', () => { const schematicRunner = new SchematicTestRunner( @@ -38,6 +38,17 @@ describe('Workspace Schematic', () => { '/tsconfig.json', ]), ); + expect(files).not.toContain('/pnpm-workspace.yaml'); + }); + + it('should create pnpm-workspace.yaml with allowBuilds when packageManager is pnpm', async () => { + const tree = await schematicRunner.runSchematic('workspace', { + ...defaultOptions, + packageManager: PackageManager.Pnpm, + }); + expect(tree.exists('/pnpm-workspace.yaml')).toBeTrue(); + const content = tree.readContent('/pnpm-workspace.yaml'); + expect(content).toContain('allowBuilds:'); }); it('should set the name in package.json', async () => {