@azure-tools/rlc-common 0.52.3 → 0.53.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.turbo/turbo-build.log +1 -1
- package/CHANGELOG.md +17 -0
- package/dist/buildIndexFile.js +9 -0
- package/dist/buildIndexFile.js.map +1 -1
- package/dist/metadata/buildPackageFile.js +44 -9
- package/dist/metadata/buildPackageFile.js.map +1 -1
- package/dist/metadata/buildTestConfig.js +28 -60
- package/dist/metadata/buildTestConfig.js.map +1 -1
- package/dist/metadata/buildTsConfig.js +120 -93
- package/dist/metadata/buildTsConfig.js.map +1 -1
- package/dist/metadata/buildVitestConfig.js +5 -21
- package/dist/metadata/buildVitestConfig.js.map +1 -1
- package/dist/metadata/buildWarpConfig.js +18 -18
- package/dist/metadata/buildWarpConfig.js.map +1 -1
- package/dist/metadata/packageJson/buildAzureMonorepoPackage.js +9 -3
- package/dist/metadata/packageJson/buildAzureMonorepoPackage.js.map +1 -1
- package/dist/metadata/packageJson/packageCommon.js +9 -0
- package/dist/metadata/packageJson/packageCommon.js.map +1 -1
- package/dist/package.json +1 -1
- package/dist-esm/buildIndexFile.js +9 -0
- package/dist-esm/buildIndexFile.js.map +1 -1
- package/dist-esm/metadata/buildPackageFile.js +41 -6
- package/dist-esm/metadata/buildPackageFile.js.map +1 -1
- package/dist-esm/metadata/buildTestConfig.js +28 -59
- package/dist-esm/metadata/buildTestConfig.js.map +1 -1
- package/dist-esm/metadata/buildTsConfig.js +115 -90
- package/dist-esm/metadata/buildTsConfig.js.map +1 -1
- package/dist-esm/metadata/buildVitestConfig.js +5 -21
- package/dist-esm/metadata/buildVitestConfig.js.map +1 -1
- package/dist-esm/metadata/buildWarpConfig.js +18 -18
- package/dist-esm/metadata/buildWarpConfig.js.map +1 -1
- package/dist-esm/metadata/packageJson/buildAzureMonorepoPackage.js +8 -3
- package/dist-esm/metadata/packageJson/buildAzureMonorepoPackage.js.map +1 -1
- package/dist-esm/metadata/packageJson/packageCommon.js +9 -0
- package/dist-esm/metadata/packageJson/packageCommon.js.map +1 -1
- package/dist-esm/package.json +1 -1
- package/package.json +1 -1
- package/src/buildIndexFile.ts +10 -0
- package/src/metadata/buildPackageFile.ts +49 -7
- package/src/metadata/buildTestConfig.ts +36 -75
- package/src/metadata/buildTsConfig.ts +146 -99
- package/src/metadata/buildVitestConfig.ts +6 -23
- package/src/metadata/buildWarpConfig.ts +19 -19
- package/src/metadata/packageJson/buildAzureMonorepoPackage.ts +8 -3
- package/src/metadata/packageJson/packageCommon.ts +9 -0
- package/test/integration/packageJson.spec.ts +154 -8
- package/test/integration/vitestConfig.spec.ts +1 -1
- package/test/integration/warpConfig.spec.ts +97 -0
- package/types/metadata/buildPackageFile.d.ts +7 -2
- package/types/metadata/buildTestConfig.d.ts +6 -4
- package/types/metadata/buildTsConfig.d.ts +35 -3
- package/types/metadata/buildVitestConfig.d.ts +1 -1
- package/types/metadata/buildWarpConfig.d.ts +7 -3
- package/types/metadata/packageJson/packageCommon.d.ts +8 -0
|
@@ -1,25 +1,9 @@
|
|
|
1
1
|
// Copyright (c) Microsoft Corporation.
|
|
2
2
|
// Licensed under the MIT License.
|
|
3
3
|
|
|
4
|
-
import { Project } from "ts-morph";
|
|
5
4
|
import { RLCModel } from "../interfaces.js";
|
|
6
5
|
import { getPackageName } from "./utils.js";
|
|
7
6
|
|
|
8
|
-
const highLevelTsTestConfig: Record<string, any> = {
|
|
9
|
-
references: [
|
|
10
|
-
{
|
|
11
|
-
path: "./tsconfig.test.node.json"
|
|
12
|
-
},
|
|
13
|
-
{
|
|
14
|
-
path: "./tsconfig.browser.config.json"
|
|
15
|
-
}
|
|
16
|
-
],
|
|
17
|
-
compilerOptions: {
|
|
18
|
-
composite: true
|
|
19
|
-
},
|
|
20
|
-
files: []
|
|
21
|
-
};
|
|
22
|
-
|
|
23
7
|
function shouldGenerateTestConfig(model: RLCModel): boolean {
|
|
24
8
|
const isAzureSdkForJs = model.options?.azureSdkForJs ?? false;
|
|
25
9
|
return !(
|
|
@@ -29,83 +13,60 @@ function shouldGenerateTestConfig(model: RLCModel): boolean {
|
|
|
29
13
|
);
|
|
30
14
|
}
|
|
31
15
|
|
|
16
|
+
/**
|
|
17
|
+
* Builds config/tsconfig.test.browser.json — extends eng/tsconfigs/test.browser.json
|
|
18
|
+
*/
|
|
32
19
|
export function buildTestBrowserTsConfig(model: RLCModel) {
|
|
33
20
|
if (!shouldGenerateTestConfig(model)) {
|
|
34
21
|
return;
|
|
35
22
|
}
|
|
36
23
|
|
|
37
|
-
const browserFilePath = "tsconfig.browser.config.json";
|
|
38
|
-
const project = new Project();
|
|
39
24
|
const name = getPackageName(model);
|
|
40
25
|
|
|
41
|
-
const browserContent: Record<string, any> = {
|
|
42
|
-
extends: "../../../tsconfig.browser.base.json",
|
|
43
|
-
compilerOptions: {
|
|
44
|
-
paths: {
|
|
45
|
-
[name]: ["./dist/browser/index.d.ts"],
|
|
46
|
-
[`${name}/*`]: ["./dist/browser/*"],
|
|
47
|
-
"$internal/*": ["./dist/browser/*"]
|
|
48
|
-
}
|
|
49
|
-
}
|
|
50
|
-
};
|
|
51
|
-
|
|
52
|
-
const browserConfigFile = project.createSourceFile(
|
|
53
|
-
browserFilePath,
|
|
54
|
-
JSON.stringify(browserContent, null, 2),
|
|
55
|
-
{
|
|
56
|
-
overwrite: true
|
|
57
|
-
}
|
|
58
|
-
);
|
|
59
|
-
|
|
60
26
|
return {
|
|
61
|
-
path:
|
|
62
|
-
content:
|
|
27
|
+
path: "config/tsconfig.test.browser.json",
|
|
28
|
+
content: JSON.stringify(
|
|
29
|
+
{
|
|
30
|
+
extends: "../../../../eng/tsconfigs/test.browser.json",
|
|
31
|
+
compilerOptions: {
|
|
32
|
+
paths: {
|
|
33
|
+
[name]: ["../src/index.ts"],
|
|
34
|
+
[`${name}/*`]: ["../src/*"],
|
|
35
|
+
"$internal/*": ["../src/*"]
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
},
|
|
39
|
+
null,
|
|
40
|
+
2
|
|
41
|
+
)
|
|
63
42
|
};
|
|
64
43
|
}
|
|
65
44
|
|
|
45
|
+
/**
|
|
46
|
+
* Builds config/tsconfig.test.node.json — extends eng/tsconfigs/test.node.json
|
|
47
|
+
*/
|
|
66
48
|
export function buildTestNodeTsConfig(model: RLCModel) {
|
|
67
49
|
if (!shouldGenerateTestConfig(model)) {
|
|
68
50
|
return;
|
|
69
51
|
}
|
|
70
52
|
|
|
71
|
-
const testNodeFilePath = "tsconfig.test.node.json";
|
|
72
|
-
const project = new Project();
|
|
73
53
|
const name = getPackageName(model);
|
|
74
54
|
|
|
75
|
-
const testNodeContent: Record<string, any> = {
|
|
76
|
-
extends: "../../../tsconfig.test.node.base.json",
|
|
77
|
-
compilerOptions: {
|
|
78
|
-
paths: {
|
|
79
|
-
[name]: ["./src/index.ts"],
|
|
80
|
-
[`${name}/*`]: ["./src/*"],
|
|
81
|
-
"$internal/*": ["./src/*"]
|
|
82
|
-
}
|
|
83
|
-
}
|
|
84
|
-
};
|
|
85
|
-
|
|
86
|
-
const testNodeConfigFile = project.createSourceFile(
|
|
87
|
-
testNodeFilePath,
|
|
88
|
-
JSON.stringify(testNodeContent, null, 2),
|
|
89
|
-
{
|
|
90
|
-
overwrite: true
|
|
91
|
-
}
|
|
92
|
-
);
|
|
93
|
-
|
|
94
|
-
return {
|
|
95
|
-
path: testNodeFilePath,
|
|
96
|
-
content: testNodeConfigFile.getFullText()
|
|
97
|
-
};
|
|
98
|
-
}
|
|
99
|
-
|
|
100
|
-
export function buildTestMainTsConfig(model: RLCModel) {
|
|
101
|
-
if (!shouldGenerateTestConfig(model)) {
|
|
102
|
-
return;
|
|
103
|
-
}
|
|
104
|
-
|
|
105
|
-
const testFilePath = "tsconfig.test.json";
|
|
106
|
-
|
|
107
55
|
return {
|
|
108
|
-
path:
|
|
109
|
-
content: JSON.stringify(
|
|
56
|
+
path: "config/tsconfig.test.node.json",
|
|
57
|
+
content: JSON.stringify(
|
|
58
|
+
{
|
|
59
|
+
extends: "../../../../eng/tsconfigs/test.node.json",
|
|
60
|
+
compilerOptions: {
|
|
61
|
+
paths: {
|
|
62
|
+
[name]: ["../src/index.ts"],
|
|
63
|
+
[`${name}/*`]: ["../src/*"],
|
|
64
|
+
"$internal/*": ["../src/*"]
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
},
|
|
68
|
+
null,
|
|
69
|
+
2
|
|
70
|
+
)
|
|
110
71
|
};
|
|
111
72
|
}
|
|
@@ -4,112 +4,87 @@
|
|
|
4
4
|
import { Project } from "ts-morph";
|
|
5
5
|
import { RLCModel } from "../interfaces.js";
|
|
6
6
|
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
}
|
|
14
|
-
]
|
|
15
|
-
};
|
|
16
|
-
};
|
|
17
|
-
const tsSrcConfigInAzureSdkForJs = `{
|
|
18
|
-
extends: "../../../tsconfig.lib.json"
|
|
19
|
-
}`;
|
|
20
|
-
|
|
21
|
-
const tsSampleConfigInAzureSdkForJs: (clientPackageName: string) => string =
|
|
22
|
-
function (clientPackageName) {
|
|
23
|
-
return `{
|
|
24
|
-
extends: "../../../tsconfig.samples.base.json",
|
|
25
|
-
compilerOptions: {
|
|
26
|
-
paths: {
|
|
27
|
-
"${clientPackageName}": ["./dist/esm"]
|
|
28
|
-
}
|
|
29
|
-
}
|
|
30
|
-
}`;
|
|
31
|
-
};
|
|
32
|
-
|
|
33
|
-
const tsTestConfigInAzureSdkForJs = `{
|
|
34
|
-
extends: ["./tsconfig.src.json", "../../../tsconfig.test.base.json"]
|
|
35
|
-
}`;
|
|
36
|
-
|
|
37
|
-
const restLevelTsConfigNotInAzureSdkForJs: (
|
|
38
|
-
model: RLCModel
|
|
39
|
-
) => Record<string, any> = function (model: RLCModel) {
|
|
40
|
-
const { options } = model;
|
|
41
|
-
return {
|
|
42
|
-
compilerOptions: {
|
|
43
|
-
target: "ES2017",
|
|
44
|
-
module: options?.moduleKind === "esm" ? "NodeNext" : "es6",
|
|
45
|
-
lib: [],
|
|
46
|
-
declaration: true,
|
|
47
|
-
declarationMap: true,
|
|
48
|
-
inlineSources: true,
|
|
49
|
-
sourceMap: true,
|
|
50
|
-
importHelpers: true,
|
|
51
|
-
strict: true,
|
|
52
|
-
alwaysStrict: true,
|
|
53
|
-
noUnusedLocals: true,
|
|
54
|
-
noUnusedParameters: true,
|
|
55
|
-
noImplicitReturns: true,
|
|
56
|
-
noFallthroughCasesInSwitch: true,
|
|
57
|
-
forceConsistentCasingInFileNames: true,
|
|
58
|
-
moduleResolution: options?.moduleKind === "esm" ? "NodeNext" : "node",
|
|
59
|
-
allowSyntheticDefaultImports: true,
|
|
60
|
-
esModuleInterop: true,
|
|
61
|
-
outDir: options?.moduleKind === "cjs" ? "./dist-esm" : undefined,
|
|
62
|
-
declarationDir: options?.moduleKind === "cjs" ? "./types" : undefined
|
|
63
|
-
},
|
|
64
|
-
include: ["src/**/*.ts"]
|
|
65
|
-
};
|
|
66
|
-
};
|
|
67
|
-
|
|
7
|
+
/**
|
|
8
|
+
* Builds the root tsconfig.json.
|
|
9
|
+
*
|
|
10
|
+
* For azureSdkForJs packages, emits project references pointing into the
|
|
11
|
+
* `config/` subfolder (following the eng/tsconfigs pattern).
|
|
12
|
+
*/
|
|
68
13
|
export function buildTsConfig(model: RLCModel) {
|
|
69
14
|
const { packageDetails, azureSdkForJs } = model.options || {};
|
|
70
15
|
const { generateTest, generateSample } = model.options || {};
|
|
71
|
-
// Take the undefined as true by default
|
|
72
16
|
const clientPackageName = packageDetails?.name ?? "";
|
|
73
17
|
const project = new Project();
|
|
74
|
-
const restLevelTsConfig = azureSdkForJs
|
|
75
|
-
? restLevelTsConfigInAzureSdkForJs()
|
|
76
|
-
: restLevelTsConfigNotInAzureSdkForJs(model);
|
|
77
18
|
|
|
78
|
-
|
|
19
|
+
let tsConfig: Record<string, any>;
|
|
20
|
+
|
|
21
|
+
if (azureSdkForJs) {
|
|
22
|
+
const references: { path: string }[] = [
|
|
23
|
+
{ path: "./config/tsconfig.src.esm.json" },
|
|
24
|
+
{ path: "./config/tsconfig.src.browser.json" },
|
|
25
|
+
{ path: "./config/tsconfig.src.react-native.json" },
|
|
26
|
+
{ path: "./config/tsconfig.src.cjs.json" }
|
|
27
|
+
];
|
|
28
|
+
|
|
79
29
|
if (generateTest) {
|
|
80
|
-
|
|
30
|
+
references.push(
|
|
31
|
+
{ path: "./config/tsconfig.test.node.json" },
|
|
32
|
+
{ path: "./config/tsconfig.test.browser.json" }
|
|
33
|
+
);
|
|
81
34
|
}
|
|
35
|
+
|
|
82
36
|
if (generateSample) {
|
|
83
|
-
|
|
84
|
-
restLevelTsConfig.compilerOptions["paths"] = {};
|
|
85
|
-
restLevelTsConfig.compilerOptions["paths"][clientPackageName] = [
|
|
86
|
-
"./src/index"
|
|
87
|
-
];
|
|
37
|
+
references.push({ path: "./config/tsconfig.samples.json" });
|
|
88
38
|
}
|
|
89
|
-
|
|
90
|
-
if (
|
|
91
|
-
|
|
92
|
-
path: "./tsconfig.samples.json"
|
|
93
|
-
});
|
|
39
|
+
|
|
40
|
+
if (generateTest) {
|
|
41
|
+
references.push({ path: "./config/tsconfig.snippets.json" });
|
|
94
42
|
}
|
|
95
43
|
|
|
44
|
+
tsConfig = { references, files: [] };
|
|
45
|
+
} else {
|
|
46
|
+
const { options } = model;
|
|
47
|
+
tsConfig = {
|
|
48
|
+
compilerOptions: {
|
|
49
|
+
target: "ES2017",
|
|
50
|
+
module: options?.moduleKind === "esm" ? "NodeNext" : "es6",
|
|
51
|
+
lib: [],
|
|
52
|
+
declaration: true,
|
|
53
|
+
declarationMap: true,
|
|
54
|
+
inlineSources: true,
|
|
55
|
+
sourceMap: true,
|
|
56
|
+
importHelpers: true,
|
|
57
|
+
strict: true,
|
|
58
|
+
alwaysStrict: true,
|
|
59
|
+
noUnusedLocals: true,
|
|
60
|
+
noUnusedParameters: true,
|
|
61
|
+
noImplicitReturns: true,
|
|
62
|
+
noFallthroughCasesInSwitch: true,
|
|
63
|
+
forceConsistentCasingInFileNames: true,
|
|
64
|
+
moduleResolution: options?.moduleKind === "esm" ? "NodeNext" : "node",
|
|
65
|
+
allowSyntheticDefaultImports: true,
|
|
66
|
+
esModuleInterop: true,
|
|
67
|
+
outDir: options?.moduleKind === "cjs" ? "./dist-esm" : undefined,
|
|
68
|
+
declarationDir: options?.moduleKind === "cjs" ? "./types" : undefined
|
|
69
|
+
},
|
|
70
|
+
include: ["src/**/*.ts"]
|
|
71
|
+
};
|
|
72
|
+
|
|
96
73
|
if (generateTest) {
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
74
|
+
tsConfig.include.push("test/**/*.ts");
|
|
75
|
+
}
|
|
76
|
+
if (generateSample) {
|
|
77
|
+
tsConfig.include.push("samples-dev/**/*.ts");
|
|
78
|
+
tsConfig.compilerOptions["paths"] = {};
|
|
79
|
+
tsConfig.compilerOptions["paths"][clientPackageName] = ["./src/index"];
|
|
103
80
|
}
|
|
104
81
|
}
|
|
105
82
|
|
|
106
83
|
const filePath = "tsconfig.json";
|
|
107
84
|
const configFile = project.createSourceFile(
|
|
108
85
|
filePath,
|
|
109
|
-
JSON.stringify(
|
|
110
|
-
{
|
|
111
|
-
overwrite: true
|
|
112
|
-
}
|
|
86
|
+
JSON.stringify(tsConfig, null, 2),
|
|
87
|
+
{ overwrite: true }
|
|
113
88
|
);
|
|
114
89
|
return {
|
|
115
90
|
path: filePath,
|
|
@@ -117,34 +92,106 @@ export function buildTsConfig(model: RLCModel) {
|
|
|
117
92
|
};
|
|
118
93
|
}
|
|
119
94
|
|
|
120
|
-
|
|
95
|
+
/**
|
|
96
|
+
* Builds config/tsconfig.src.esm.json — extends eng/tsconfigs/src.esm.json
|
|
97
|
+
*/
|
|
98
|
+
export function buildTsSrcEsmConfig() {
|
|
121
99
|
return {
|
|
122
|
-
path: "tsconfig.src.json",
|
|
123
|
-
content:
|
|
100
|
+
path: "config/tsconfig.src.esm.json",
|
|
101
|
+
content: JSON.stringify(
|
|
102
|
+
{
|
|
103
|
+
extends: "../../../../eng/tsconfigs/src.esm.json",
|
|
104
|
+
include: ["../src/index.ts"]
|
|
105
|
+
},
|
|
106
|
+
null,
|
|
107
|
+
2
|
|
108
|
+
)
|
|
124
109
|
};
|
|
125
110
|
}
|
|
126
111
|
|
|
127
|
-
|
|
128
|
-
|
|
112
|
+
/**
|
|
113
|
+
* Builds config/tsconfig.src.browser.json — extends eng/tsconfigs/src.browser.json
|
|
114
|
+
*/
|
|
115
|
+
export function buildTsSrcBrowserConfig() {
|
|
116
|
+
return {
|
|
117
|
+
path: "config/tsconfig.src.browser.json",
|
|
118
|
+
content: JSON.stringify(
|
|
119
|
+
{
|
|
120
|
+
extends: "../../../../eng/tsconfigs/src.browser.json",
|
|
121
|
+
include: ["../src/index.ts"]
|
|
122
|
+
},
|
|
123
|
+
null,
|
|
124
|
+
2
|
|
125
|
+
)
|
|
126
|
+
};
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
/**
|
|
130
|
+
* Builds config/tsconfig.src.react-native.json — extends eng/tsconfigs/src.react-native.json
|
|
131
|
+
*/
|
|
132
|
+
export function buildTsSrcReactNativeConfig() {
|
|
133
|
+
return {
|
|
134
|
+
path: "config/tsconfig.src.react-native.json",
|
|
135
|
+
content: JSON.stringify(
|
|
136
|
+
{
|
|
137
|
+
extends: "../../../../eng/tsconfigs/src.react-native.json",
|
|
138
|
+
include: ["../src/index.ts"]
|
|
139
|
+
},
|
|
140
|
+
null,
|
|
141
|
+
2
|
|
142
|
+
)
|
|
143
|
+
};
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
/**
|
|
147
|
+
* Builds config/tsconfig.src.cjs.json — extends eng/tsconfigs/src.cjs.json
|
|
148
|
+
*/
|
|
149
|
+
export function buildTsSrcCjsConfig() {
|
|
129
150
|
return {
|
|
130
|
-
path: "tsconfig.
|
|
131
|
-
content:
|
|
151
|
+
path: "config/tsconfig.src.cjs.json",
|
|
152
|
+
content: JSON.stringify(
|
|
153
|
+
{
|
|
154
|
+
extends: "../../../../eng/tsconfigs/src.cjs.json",
|
|
155
|
+
include: ["../src/index.ts"]
|
|
156
|
+
},
|
|
157
|
+
null,
|
|
158
|
+
2
|
|
159
|
+
)
|
|
132
160
|
};
|
|
133
161
|
}
|
|
134
162
|
|
|
135
|
-
|
|
163
|
+
/**
|
|
164
|
+
* Builds config/tsconfig.samples.json — extends eng/tsconfigs/samples.json
|
|
165
|
+
*/
|
|
166
|
+
export function buildTsSampleConfig(model: RLCModel) {
|
|
167
|
+
const { packageDetails } = model.options || {};
|
|
168
|
+
const clientPackageName = packageDetails?.name ?? "";
|
|
136
169
|
return {
|
|
137
|
-
path: "tsconfig.
|
|
138
|
-
content:
|
|
170
|
+
path: "config/tsconfig.samples.json",
|
|
171
|
+
content: JSON.stringify(
|
|
172
|
+
{
|
|
173
|
+
extends: "../../../../eng/tsconfigs/samples.json",
|
|
174
|
+
compilerOptions: {
|
|
175
|
+
paths: {
|
|
176
|
+
[clientPackageName]: ["../dist/esm"]
|
|
177
|
+
}
|
|
178
|
+
}
|
|
179
|
+
},
|
|
180
|
+
null,
|
|
181
|
+
2
|
|
182
|
+
)
|
|
139
183
|
};
|
|
140
184
|
}
|
|
141
185
|
|
|
186
|
+
/**
|
|
187
|
+
* Builds config/tsconfig.snippets.json — extends eng/tsconfigs/snippets.json
|
|
188
|
+
*/
|
|
142
189
|
export function buildTsSnippetsConfig() {
|
|
143
190
|
return {
|
|
144
|
-
path: "tsconfig.snippets.json",
|
|
191
|
+
path: "config/tsconfig.snippets.json",
|
|
145
192
|
content: JSON.stringify(
|
|
146
193
|
{
|
|
147
|
-
extends:
|
|
194
|
+
extends: "../../../../eng/tsconfigs/snippets.json"
|
|
148
195
|
},
|
|
149
196
|
null,
|
|
150
197
|
2
|
|
@@ -3,29 +3,17 @@
|
|
|
3
3
|
|
|
4
4
|
import { RLCModel } from "../interfaces.js";
|
|
5
5
|
|
|
6
|
-
const nodeConfig = `
|
|
7
|
-
import viteConfig from "../../../vitest.shared.config.ts";
|
|
6
|
+
const nodeConfig = `import viteConfig from "../../../vitest.shared.config.ts";
|
|
8
7
|
|
|
9
|
-
export default viteConfig
|
|
8
|
+
export default viteConfig;
|
|
9
|
+
`;
|
|
10
10
|
|
|
11
|
-
const browserConfig = `
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
export default viteConfig;`;
|
|
15
|
-
|
|
16
|
-
const esmConfig = `
|
|
17
|
-
import { mergeConfig } from "vitest/config";
|
|
18
|
-
import vitestConfig from "./vitest.config.ts";
|
|
19
|
-
import vitestEsmConfig from "../../../vitest.esm.shared.config.ts";
|
|
20
|
-
|
|
21
|
-
export default mergeConfig(
|
|
22
|
-
vitestConfig,
|
|
23
|
-
vitestEsmConfig
|
|
24
|
-
);`;
|
|
11
|
+
const browserConfig = `export { default } from "../../../eng/vitestconfigs/browser.config.ts";
|
|
12
|
+
`;
|
|
25
13
|
|
|
26
14
|
export function buildVitestConfig(
|
|
27
15
|
model: RLCModel,
|
|
28
|
-
platform: "browser" | "node"
|
|
16
|
+
platform: "browser" | "node"
|
|
29
17
|
) {
|
|
30
18
|
if (
|
|
31
19
|
model.options?.generateMetadata === false ||
|
|
@@ -44,10 +32,5 @@ export function buildVitestConfig(
|
|
|
44
32
|
path: "vitest.config.ts",
|
|
45
33
|
content: nodeConfig
|
|
46
34
|
};
|
|
47
|
-
case "esm":
|
|
48
|
-
return {
|
|
49
|
-
path: "vitest.esm.config.ts",
|
|
50
|
-
content: esmConfig
|
|
51
|
-
};
|
|
52
35
|
}
|
|
53
36
|
}
|
|
@@ -2,13 +2,19 @@
|
|
|
2
2
|
// Licensed under the MIT License.
|
|
3
3
|
|
|
4
4
|
import { RLCModel } from "../interfaces.js";
|
|
5
|
-
import { isAzureMonorepoPackage } from "../helpers/packageUtil.js";
|
|
6
5
|
|
|
7
6
|
export interface WarpConfigOptions {
|
|
8
7
|
/** Source-level exports, e.g. { ".": "./src/index.ts", "./models": "./src/models/index.ts" } */
|
|
9
8
|
exports?: Record<string, string>;
|
|
10
9
|
}
|
|
11
10
|
|
|
11
|
+
/** Default exports included in every warp config. */
|
|
12
|
+
const BASE_EXPORTS: Record<string, string> = {
|
|
13
|
+
"./package.json": "./package.json",
|
|
14
|
+
".": "./src/index.ts"
|
|
15
|
+
};
|
|
16
|
+
|
|
17
|
+
/** Full inline warp config template. */
|
|
12
18
|
export const WarpConfigTemplate = `# warp.config.yml — build configuration
|
|
13
19
|
|
|
14
20
|
exports:
|
|
@@ -16,41 +22,38 @@ exports:
|
|
|
16
22
|
|
|
17
23
|
targets:
|
|
18
24
|
- name: browser
|
|
19
|
-
tsconfig: "
|
|
20
|
-
polyfillSuffix: "-browser"
|
|
25
|
+
tsconfig: "./config/tsconfig.src.browser.json"
|
|
21
26
|
|
|
22
27
|
- name: react-native
|
|
23
|
-
tsconfig: "
|
|
24
|
-
polyfillSuffix: "-react-native"
|
|
28
|
+
tsconfig: "./config/tsconfig.src.react-native.json"
|
|
25
29
|
|
|
26
30
|
- name: esm
|
|
27
31
|
condition: import
|
|
28
|
-
tsconfig: "
|
|
32
|
+
tsconfig: "./config/tsconfig.src.esm.json"
|
|
29
33
|
|
|
30
34
|
- name: commonjs
|
|
31
35
|
condition: require
|
|
32
|
-
tsconfig: "
|
|
36
|
+
tsconfig: "./config/tsconfig.src.cjs.json"
|
|
37
|
+
moduleType: commonjs
|
|
33
38
|
`;
|
|
34
39
|
|
|
35
40
|
/**
|
|
36
|
-
* Builds a warp.config.yml file
|
|
37
|
-
*
|
|
41
|
+
* Builds a self-contained warp.config.yml file.
|
|
42
|
+
*
|
|
43
|
+
* Emits a full inline config with all exports and targets.
|
|
44
|
+
* Polyfill resolution (browser/react-native file substitution) is handled
|
|
45
|
+
* via package.json `imports` subpath imports (#platform/*).
|
|
38
46
|
*/
|
|
39
47
|
export function buildWarpConfig(
|
|
40
48
|
model: RLCModel,
|
|
41
49
|
{ exports }: WarpConfigOptions = {}
|
|
42
50
|
) {
|
|
43
|
-
if (!isAzureMonorepoPackage(model)) {
|
|
44
|
-
return;
|
|
45
|
-
}
|
|
46
|
-
|
|
47
51
|
if (model.options?.moduleKind !== "esm") {
|
|
48
52
|
return;
|
|
49
53
|
}
|
|
50
54
|
|
|
51
55
|
const allExports: Record<string, string> = {
|
|
52
|
-
|
|
53
|
-
".": "./src/index.ts",
|
|
56
|
+
...BASE_EXPORTS,
|
|
54
57
|
...exports
|
|
55
58
|
};
|
|
56
59
|
|
|
@@ -60,8 +63,5 @@ export function buildWarpConfig(
|
|
|
60
63
|
|
|
61
64
|
const content = WarpConfigTemplate.replace("{{exports}}", exportsContent);
|
|
62
65
|
|
|
63
|
-
return {
|
|
64
|
-
path: "warp.config.yml",
|
|
65
|
-
content
|
|
66
|
-
};
|
|
66
|
+
return { path: "warp.config.yml", content };
|
|
67
67
|
}
|
|
@@ -95,12 +95,17 @@ export function getAzureMonorepoPackageInfo(
|
|
|
95
95
|
config: AzureMonorepoInfoConfig
|
|
96
96
|
): Record<string, any> {
|
|
97
97
|
const commonPackageInfo = getPackageCommonInfo(config);
|
|
98
|
+
const repositoryDirectory = config.monorepoPackageDirectory ?? "sdk/";
|
|
98
99
|
|
|
99
100
|
return {
|
|
100
101
|
...commonPackageInfo,
|
|
101
102
|
...getAzureCommonPackageInfo(config),
|
|
102
103
|
"sdk-type": `${config.azureArm ? "mgmt" : "client"}`,
|
|
103
|
-
repository:
|
|
104
|
+
repository: {
|
|
105
|
+
type: "git",
|
|
106
|
+
url: "git+https://github.com/Azure/azure-sdk-for-js",
|
|
107
|
+
directory: repositoryDirectory
|
|
108
|
+
},
|
|
104
109
|
bugs: {
|
|
105
110
|
url: "https://github.com/Azure/azure-sdk-for-js/issues"
|
|
106
111
|
},
|
|
@@ -154,8 +159,8 @@ function getAzureMonorepoScripts(config: AzureMonorepoInfoConfig) {
|
|
|
154
159
|
const esmScripts = getEsmScripts(config);
|
|
155
160
|
const skipLinting = config.azureArm && config.isModularLibrary;
|
|
156
161
|
const buildSampleScripts = config.azureArm
|
|
157
|
-
? "tsc -p tsconfig.samples.json && dev-tool samples publish -f"
|
|
158
|
-
: "tsc -p tsconfig.samples.json";
|
|
162
|
+
? "tsc -p config/tsconfig.samples.json && dev-tool samples publish -f"
|
|
163
|
+
: "tsc -p config/tsconfig.samples.json";
|
|
159
164
|
return {
|
|
160
165
|
...getCommonPackageScripts(),
|
|
161
166
|
"build:samples": config.withSamples ? buildSampleScripts : "echo skipped",
|
|
@@ -113,10 +113,19 @@ function getEsmEntrypointInformation(config: PackageCommonInfoConfig) {
|
|
|
113
113
|
types: "./dist/commonjs/index.d.ts",
|
|
114
114
|
browser: "./dist/browser/index.js",
|
|
115
115
|
"react-native": "./dist/react-native/index.js",
|
|
116
|
+
imports: {
|
|
117
|
+
"#platform/*.js": {
|
|
118
|
+
browser: "./src/*-browser.mjs",
|
|
119
|
+
"react-native": "./src/*-react-native.mjs",
|
|
120
|
+
default: "./src/*.js"
|
|
121
|
+
}
|
|
122
|
+
},
|
|
116
123
|
exports: resolveWarpExports(config.exports)
|
|
117
124
|
};
|
|
118
125
|
}
|
|
119
126
|
|
|
127
|
+
// Non-monorepo packages use tshy which manages polyfill resolution
|
|
128
|
+
// via esmDialects — do NOT add imports here.
|
|
120
129
|
return {
|
|
121
130
|
tshy: getTshyConfig(config),
|
|
122
131
|
type: "module",
|