Skip to content

Commit 0a7b2e7

Browse files
deyaaeldeenMaryGao
andauthored
Update tsconfig.browser.config.json (#3461)
Co-authored-by: Mary Gao <[email protected]>
1 parent 0821af8 commit 0a7b2e7

File tree

4 files changed

+33
-13
lines changed

4 files changed

+33
-13
lines changed

packages/autorest.typescript/src/generators/static/tsConfigBrowserFileGenerator.ts

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4,21 +4,27 @@
44
import { Project } from "ts-morph";
55
import { getAutorestOptions } from "../../autorestSession";
66

7-
const highLevelTsBrowserConfig: Record<string, any> = {
8-
"extends": [
9-
"./tsconfig.test.json",
10-
"../../../tsconfig.browser.base.json"
11-
]
12-
};
13-
147
export function generateTsBrowserConfig(project: Project) {
158
const {
9+
packageDetails,
1610
generateMetadata,
1711
} = getAutorestOptions();
1812

1913
if (!generateMetadata) {
2014
return;
2115
}
16+
17+
const highLevelTsBrowserConfig: Record<string, any> = {
18+
"extends": "../../../tsconfig.browser.base.json",
19+
"compilerOptions": {
20+
"paths": {
21+
[packageDetails.name]: ["./dist/browser/index.d.ts"],
22+
[`${packageDetails.name}/*`]: ["./dist/browser/*"],
23+
"$internal/*": ["./dist/browser/*"]
24+
}
25+
}
26+
};
27+
2228
project.createSourceFile("tsconfig.browser.config.json", JSON.stringify(highLevelTsBrowserConfig), {
2329
overwrite: true
2430
});

packages/rlc-common/src/metadata/buildBrowserConfig.ts

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33

44
import { Project } from "ts-morph";
55
import { RLCModel } from "../interfaces.js";
6+
import { getPackageName } from "./utils.js";
67

78
export function buildTsTestBrowserConfig(model: RLCModel) {
89
const isAzureSdkForJs = model.options?.azureSdkForJs ?? false;
@@ -16,9 +17,17 @@ export function buildTsTestBrowserConfig(model: RLCModel) {
1617

1718
const filePath = "tsconfig.browser.config.json";
1819
const project = new Project();
20+
const name = getPackageName(model);
1921

20-
const content = {
21-
extends: ["./tsconfig.test.json", "../../../tsconfig.browser.base.json"]
22+
const content: Record<string, any> = {
23+
extends: "../../../tsconfig.browser.base.json",
24+
compilerOptions: {
25+
paths: {
26+
[name]: ["./dist/browser/index.d.ts"],
27+
[`${name}/*`]: ["./dist/browser/*"],
28+
"$internal/*": ["./dist/browser/*"]
29+
}
30+
}
2231
};
2332

2433
const configFile = project.createSourceFile(

packages/rlc-common/src/metadata/buildPackageFile.ts

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ import { buildAzureMonorepoPackage } from "./packageJson/buildAzureMonorepoPacka
1515
import { buildAzureStandalonePackage } from "./packageJson/buildAzureStandalonePackage.js";
1616
import { buildFlavorlessPackage } from "./packageJson/buildFlavorlessPackage.js";
1717
import { getRelativePartFromSrcPath } from "../helpers/pathUtils.js";
18+
import { getPackageName } from "./utils.js";
1819

1920
interface PackageFileOptions {
2021
exports?: Record<string, any>;
@@ -141,10 +142,6 @@ function getDescription(model: RLCModel): string {
141142
return description;
142143
}
143144

144-
function getPackageName(model: RLCModel): string {
145-
return model.options?.packageDetails?.name ?? model.libraryName;
146-
}
147-
148145
function getClientFilePath(model: RLCModel) {
149146
const { srcPath } = model;
150147
const sdkReletivePart = getRelativePartFromSrcPath(srcPath);
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
// Copyright (c) Microsoft Corporation.
2+
// Licensed under the MIT License.
3+
4+
import { RLCModel } from "../interfaces.js";
5+
6+
export function getPackageName(model: RLCModel): string {
7+
return model.options?.packageDetails?.name ?? model.libraryName;
8+
}

0 commit comments

Comments
 (0)