@azure-tools/typespec-ts 0.55.1 → 0.55.2

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@azure-tools/typespec-ts",
3
- "version": "0.55.1",
3
+ "version": "0.55.2",
4
4
  "description": "A TypeSpec emitter for TypeScript",
5
5
  "main": "dist/src/index.js",
6
6
  "type": "module",
@@ -35,28 +35,28 @@
35
35
  "yaml": "^2.8.3",
36
36
  "@typespec/http-specs": "^0.1.0-alpha.39",
37
37
  "@typespec/spector": "^0.1.0-alpha.26",
38
- "@typespec/spec-api": "^0.1.0-alpha.15",
39
38
  "@typespec/tspd": "^0.76.0",
40
- "@azure-tools/azure-http-specs": "^0.1.0-alpha.42",
41
- "@azure-tools/typespec-autorest": "^0.70.0",
42
- "@azure-tools/typespec-azure-resource-manager": "^0.70.0",
39
+ "@azure-tools/typespec-autorest": "^0.70.1",
40
+ "@typespec/spec-api": "^0.1.0-alpha.15",
43
41
  "@azure-tools/typespec-azure-core": "^0.70.0",
44
- "@azure-tools/typespec-client-generator-core": "^0.70.0",
42
+ "@azure-tools/typespec-azure-resource-manager": "^0.70.0",
43
+ "@azure-tools/azure-http-specs": "^0.1.0-alpha.43",
45
44
  "@typespec/compiler": "^1.14.0",
46
45
  "@typespec/http": "^1.14.0",
47
46
  "@typespec/openapi": "^1.14.0",
48
- "@typespec/versioning": "^0.84.0",
47
+ "@azure-tools/typespec-client-generator-core": "^0.70.0",
49
48
  "@typespec/rest": "^0.84.0",
50
- "@typespec/xml": "^0.84.0"
49
+ "@typespec/xml": "^0.84.0",
50
+ "@typespec/versioning": "^0.84.0"
51
51
  },
52
52
  "peerDependencies": {
53
53
  "@azure-tools/typespec-client-generator-core": "^0.70.0",
54
+ "@azure-tools/typespec-azure-core": "^0.70.0",
54
55
  "@typespec/http": "^1.14.0",
55
- "@typespec/compiler": "^1.14.0",
56
56
  "@typespec/rest": "^0.84.0",
57
- "@azure-tools/typespec-azure-core": "^0.70.0",
58
57
  "@typespec/xml": "^0.84.0",
59
- "@typespec/versioning": "^0.84.0"
58
+ "@typespec/versioning": "^0.84.0",
59
+ "@typespec/compiler": "^1.14.0"
60
60
  },
61
61
  "dependencies": {
62
62
  "fast-xml-parser": "^5.7.0",
package/src/index.ts CHANGED
@@ -462,12 +462,12 @@ export async function $onEmit(context: EmitContext) {
462
462
  // Generate warp.config.yml for Azure monorepo ESM packages
463
463
  commonBuilders.push((model) => buildWarpConfig(model, modularPackageInfo));
464
464
  commonBuilders.push(buildTsConfig);
465
- commonBuilders.push(buildTsSrcEsmConfig);
466
- commonBuilders.push(buildTsSrcBrowserConfig);
465
+ commonBuilders.push(() => buildTsSrcEsmConfig(modularPackageInfo["exports"]));
466
+ commonBuilders.push(() => buildTsSrcBrowserConfig(modularPackageInfo["exports"]));
467
467
  if (option.generateReactNativeTarget) {
468
- commonBuilders.push(buildTsSrcReactNativeConfig);
468
+ commonBuilders.push(() => buildTsSrcReactNativeConfig(modularPackageInfo["exports"]));
469
469
  }
470
- commonBuilders.push(buildTsSrcCjsConfig);
470
+ commonBuilders.push(() => buildTsSrcCjsConfig(modularPackageInfo["exports"]));
471
471
  if (option.generateSample) {
472
472
  commonBuilders.push(buildTsSampleConfig);
473
473
  }
@@ -533,6 +533,14 @@ export async function $onEmit(context: EmitContext) {
533
533
  // Update warp.config.yml for Azure monorepo packages
534
534
  updateBuilders.push((model: ClientModel) => buildWarpConfig(model, modularPackageInfo));
535
535
 
536
+ // Re-sync tsconfig.src.*.json `include` with the warp exports
537
+ updateBuilders.push(() => buildTsSrcEsmConfig(modularPackageInfo["exports"]));
538
+ updateBuilders.push(() => buildTsSrcBrowserConfig(modularPackageInfo["exports"]));
539
+ if (option.generateReactNativeTarget) {
540
+ updateBuilders.push(() => buildTsSrcReactNativeConfig(modularPackageInfo["exports"]));
541
+ }
542
+ updateBuilders.push(() => buildTsSrcCjsConfig(modularPackageInfo["exports"]));
543
+
536
544
  // If the client name changed, regenerate the README and snippets completely;
537
545
  // otherwise update only the API reference link in-place.
538
546
  if (hasReadmeFile) {
@@ -52,16 +52,33 @@ export function buildTsConfig(model: ClientModel) {
52
52
  };
53
53
  }
54
54
 
55
+ /**
56
+ * Derives the tsconfig `include` list from the warp `exports` map so every
57
+ * exported client entry point is compiled and emitted to `dist`; if they drift
58
+ * out of sync, warp fails the build with `DIST_MISSING`. Root index is the fallback.
59
+ */
60
+ export function getSrcIncludePaths(exports?: Record<string, string>): string[] {
61
+ const includes = new Set<string>(["../src/index.ts"]);
62
+ if (exports) {
63
+ for (const value of Object.values(exports)) {
64
+ if (typeof value === "string" && value.endsWith(".ts")) {
65
+ includes.add(value.replace(/^\.\//, "../"));
66
+ }
67
+ }
68
+ }
69
+ return Array.from(includes);
70
+ }
71
+
55
72
  /**
56
73
  * Builds config/tsconfig.src.esm.json — extends eng/tsconfigs/src.esm.json
57
74
  */
58
- export function buildTsSrcEsmConfig() {
75
+ export function buildTsSrcEsmConfig(exports?: Record<string, string>) {
59
76
  return {
60
77
  path: "config/tsconfig.src.esm.json",
61
78
  content: JSON.stringify(
62
79
  {
63
80
  extends: "../../../../eng/tsconfigs/src.esm.json",
64
- include: ["../src/index.ts"],
81
+ include: getSrcIncludePaths(exports),
65
82
  },
66
83
  null,
67
84
  2,
@@ -72,13 +89,13 @@ export function buildTsSrcEsmConfig() {
72
89
  /**
73
90
  * Builds config/tsconfig.src.browser.json — extends eng/tsconfigs/src.browser.json
74
91
  */
75
- export function buildTsSrcBrowserConfig() {
92
+ export function buildTsSrcBrowserConfig(exports?: Record<string, string>) {
76
93
  return {
77
94
  path: "config/tsconfig.src.browser.json",
78
95
  content: JSON.stringify(
79
96
  {
80
97
  extends: "../../../../eng/tsconfigs/src.browser.json",
81
- include: ["../src/index.ts"],
98
+ include: getSrcIncludePaths(exports),
82
99
  },
83
100
  null,
84
101
  2,
@@ -89,13 +106,13 @@ export function buildTsSrcBrowserConfig() {
89
106
  /**
90
107
  * Builds config/tsconfig.src.react-native.json — extends eng/tsconfigs/src.react-native.json
91
108
  */
92
- export function buildTsSrcReactNativeConfig() {
109
+ export function buildTsSrcReactNativeConfig(exports?: Record<string, string>) {
93
110
  return {
94
111
  path: "config/tsconfig.src.react-native.json",
95
112
  content: JSON.stringify(
96
113
  {
97
114
  extends: "../../../../eng/tsconfigs/src.react-native.json",
98
- include: ["../src/index.ts"],
115
+ include: getSrcIncludePaths(exports),
99
116
  },
100
117
  null,
101
118
  2,
@@ -106,13 +123,13 @@ export function buildTsSrcReactNativeConfig() {
106
123
  /**
107
124
  * Builds config/tsconfig.src.cjs.json — extends eng/tsconfigs/src.cjs.json
108
125
  */
109
- export function buildTsSrcCjsConfig() {
126
+ export function buildTsSrcCjsConfig(exports?: Record<string, string>) {
110
127
  return {
111
128
  path: "config/tsconfig.src.cjs.json",
112
129
  content: JSON.stringify(
113
130
  {
114
131
  extends: "../../../../eng/tsconfigs/src.cjs.json",
115
- include: ["../src/index.ts"],
132
+ include: getSrcIncludePaths(exports),
116
133
  },
117
134
  null,
118
135
  2,