Skip to content

Commit 1bec8ff

Browse files
committed
Update utils.ts
1 parent ca32259 commit 1bec8ff

File tree

1 file changed

+5
-2
lines changed
  • packages/@apphosting/adapter-angular/src

1 file changed

+5
-2
lines changed

packages/@apphosting/adapter-angular/src/utils.ts

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,11 +11,13 @@ import {
1111
buildManifestSchema,
1212
ValidManifest,
1313
} from "./interface.js";
14+
import { createRequire } from "node:module";
1415
import stripAnsi from "strip-ansi";
1516

1617
// fs-extra is CJS, readJson can't be imported using shorthand
1718
export const { writeFile, move, readJson, mkdir, copyFile } = fsExtra;
1819

20+
const require = createRequire(import.meta.url);
1921
const __filename = fileURLToPath(import.meta.url);
2022
const __dirname = dirname(__filename);
2123
const SIMPLE_SERVER_FILE_PATH = join(__dirname, "simple-server", "bundled_server.mjs");
@@ -31,10 +33,11 @@ export const REQUIRED_BUILDER = "@angular-devkit/build-angular:application";
3133
export async function checkStandaloneBuildConditions(cwd: string): Promise<void> {
3234
// dynamically load Angular so this can be used in an NPX context
3335
const { NodeJsAsyncHost }: typeof import("@angular-devkit/core/node") = await import(
34-
`${cwd}/node_modules/@angular-devkit/core/node/index.js`
36+
//TODO (sijinli): resolve paths under cwd to be safer later
37+
require.resolve("@angular-devkit/core/node/index.js")
3538
);
3639
const { workspaces }: typeof import("@angular-devkit/core") = await import(
37-
`${cwd}/node_modules/@angular-devkit/core/src/index.js`
40+
require.resolve("@angular-devkit/core/src/index.js")
3841
);
3942

4043
const host = workspaces.createWorkspaceHost(new NodeJsAsyncHost());

0 commit comments

Comments
 (0)