Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 0bc89ef

Browse files
committed
refactor(@schematics/angular): replace devkit path functions with node:path
Continuing the effort to reduce dependencies on `@angular-devkit/core`, this commit replaces path manipulation functions (`join`, `normalize`) with their equivalents from the built-in `node:path/posix` module. This change affects the `service-worker`, `ssr`, and `web-worker` schematics. Unused imports from `@angular-devkit/core` and other modules were also removed as part of this cleanup.
1 parent f8d0ca9 commit 0bc89ef

File tree

5 files changed

+14
-16
lines changed

5 files changed

+14
-16
lines changed

‎packages/schematics/angular/component/index.ts‎

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,6 @@
99
import {
1010
FileOperator,
1111
Rule,
12-
SchematicsException,
13-
Tree,
1412
apply,
1513
applyTemplates,
1614
chain,

‎packages/schematics/angular/pipe/index.ts‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
* found in the LICENSE file at https://angular.dev/license
77
*/
88

9-
import { Rule,Tree,chain, strings } from '@angular-devkit/schematics';
9+
import { chain, strings } from '@angular-devkit/schematics';
1010
import { addDeclarationToNgModule } from '../utility/add-declaration-to-ng-module';
1111
import { findModuleFromOptions } from '../utility/find-module';
1212
import { generateFromFiles } from '../utility/generate-from-files';

‎packages/schematics/angular/service-worker/index.ts‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@
66
* found in the LICENSE file at https://angular.dev/license
77
*/
88

9-
import { join, normalize } from '@angular-devkit/core';
109
import {
1110
Rule,
1211
SchematicContext,
@@ -19,7 +18,8 @@ import {
1918
move,
2019
url,
2120
} from '@angular-devkit/schematics';
22-
import * as ts from '../third_party/github.com/Microsoft/TypeScript/lib/typescript';
21+
import { join } from 'node:path/posix';
22+
import ts from '../third_party/github.com/Microsoft/TypeScript/lib/typescript';
2323
import { addDependency, addRootProvider, writeWorkspace } from '../utility';
2424
import { addSymbolToNgModuleMetadata, insertImport } from '../utility/ast-utils';
2525
import { applyToUpdateRecorder } from '../utility/change';
@@ -116,7 +116,7 @@ export default createProjectSchematic<ServiceWorkerOptions>(
116116

117117
const buildOptions = buildTarget.options as Record<string, string | boolean>;
118118
const browserEntryPoint = await getMainFilePath(tree, options.project);
119-
const ngswConfigPath = join(normalize(project.root), 'ngsw-config.json');
119+
const ngswConfigPath = join(project.root, 'ngsw-config.json');
120120

121121
if (
122122
buildTarget.builder === Builders.Application ||

‎packages/schematics/angular/ssr/index.ts‎

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
* found in the LICENSE file at https://angular.dev/license
77
*/
88

9-
import { isJsonObject,join,normalize } from '@angular-devkit/core';
9+
import { isJsonObject } from '@angular-devkit/core';
1010
import {
1111
Rule,
1212
SchematicContext,
@@ -21,7 +21,7 @@ import {
2121
strings,
2222
url,
2323
} from '@angular-devkit/schematics';
24-
import { posix } from 'node:path';
24+
import { join } from 'node:path/posix';
2525
import { Schema as ServerOptions } from '../server/schema';
2626
import {
2727
DependencyType,
@@ -85,7 +85,7 @@ async function getApplicationBuilderOutputPaths(
8585

8686
let { outputPath } = architectTarget.options;
8787
// Use default if not explicitly specified
88-
outputPath ??= posix.join('dist', projectName);
88+
outputPath ??= join('dist', projectName);
8989

9090
const defaultDirs = {
9191
server: DEFAULT_SERVER_DIR,
@@ -123,7 +123,7 @@ function addScriptsRule({ project }: SSROptions, isUsingApplicationBuilder: bool
123123
if (isUsingApplicationBuilder) {
124124
const { base, server } = await getApplicationBuilderOutputPaths(host, project);
125125
pkg.scripts ??= {};
126-
pkg.scripts[`serve:ssr:${project}`] = `node ${posix.join(base, server)}/server.mjs`;
126+
pkg.scripts[`serve:ssr:${project}`] = `node ${join(base, server)}/server.mjs`;
127127
} else {
128128
const serverDist = await getLegacyOutputPaths(host, project, 'server');
129129
pkg.scripts = {
@@ -185,7 +185,7 @@ function updateApplicationBuilderWorkspaceConfigRule(
185185
if (outputPath.browser === '') {
186186
const base = outputPath.base as string;
187187
logger.warn(
188-
`The output location of the browser build has been updated from "${base}" to "${posix.join(
188+
`The output location of the browser build has been updated from "${base}" to "${join(
189189
base,
190190
DEFAULT_BROWSER_DIR,
191191
)}".
@@ -208,7 +208,7 @@ function updateApplicationBuilderWorkspaceConfigRule(
208208
outputPath,
209209
outputMode: 'server',
210210
ssr: {
211-
entry: join(normalize(projectSourceRoot), 'server.ts'),
211+
entry: join(projectSourceRoot, 'server.ts'),
212212
},
213213
};
214214
});
@@ -227,7 +227,7 @@ function updateWebpackBuilderWorkspaceConfigRule(
227227

228228
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
229229
const serverTarget = project.targets.get('server')!;
230-
(serverTarget.options ??= {}).main = posix.join(projectSourceRoot, 'server.ts');
230+
(serverTarget.options ??= {}).main = join(projectSourceRoot, 'server.ts');
231231

232232
const serveSSRTarget = project.targets.get(SERVE_SSR_TARGET_NAME);
233233
if (serveSSRTarget) {
@@ -365,7 +365,7 @@ export default createProjectSchematic<SSROptions>(async (options, { project, tre
365365
const isStandalone = isStandaloneApp(tree, browserEntryPoint);
366366

367367
const usingApplicationBuilder = isUsingApplicationBuilder(project);
368-
const sourceRoot = project.sourceRoot ?? posix.join(project.root, 'src');
368+
const sourceRoot = project.sourceRoot ?? join(project.root, 'src');
369369

370370
return chain([
371371
schematic('server', {

‎packages/schematics/angular/web-worker/index.ts‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@
66
* found in the LICENSE file at https://angular.dev/license
77
*/
88

9-
import { join, normalize } from '@angular-devkit/core';
109
import {
1110
Rule,
1211
SchematicContext,
@@ -21,6 +20,7 @@ import {
2120
strings,
2221
url,
2322
} from '@angular-devkit/schematics';
23+
import { join } from 'node:path/posix';
2424
import { parseName } from '../utility/parse-name';
2525
import { relativePathToWorkspaceRoot } from '../utility/paths';
2626
import { createProjectSchematic } from '../utility/project';
@@ -111,7 +111,7 @@ export default createProjectSchematic<WebWorkerOptions>((options, { project }) =
111111
throw new Error(`Build target is not defined for this project.`);
112112
}
113113

114-
const workerConfigPath = join(normalize(root), 'tsconfig.worker.json');
114+
const workerConfigPath = join(root, 'tsconfig.worker.json');
115115
(buildTarget.options ??= {}).webWorkerTsConfig ??= workerConfigPath;
116116
if (testTarget) {
117117
(testTarget.options ??= {}).webWorkerTsConfig ??= workerConfigPath;

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /