Skip to content

Commit f214d42

Browse files
authored
chore(smithy-client): build-fix, hide submodule export from api-extractor (#1596)
1 parent 06b0ce8 commit f214d42

File tree

5 files changed

+42
-1
lines changed

5 files changed

+42
-1
lines changed

.changeset/pink-bats-explode.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
---
2+
---

packages/core/api-extractor.json

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
{
2+
"extends": "../../api-extractor.packages.json",
3+
"mainEntryPointFilePath": "./dist-types/index.d.ts"
4+
}

packages/core/package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
"clean": "rimraf ./dist-* && rimraf *.tsbuildinfo || exit 0",
1212
"lint": "npx eslint -c ../../.eslintrc.js \"src/**/*.ts\" --fix && node ./scripts/lint",
1313
"format": "prettier --config ../../prettier.config.js --ignore-path ../../.prettierignore --write \"**/*.{ts,md,json}\"",
14+
"extract:docs": "api-extractor run --local",
1415
"test": "yarn g:vitest run",
1516
"test:cbor:perf": "node ./scripts/cbor-perf.mjs",
1617
"test:watch": "yarn g:vitest watch"

packages/smithy-client/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
"clean": "rimraf ./dist-* && rimraf *.tsbuildinfo || exit 0",
1212
"lint": "eslint -c ../../.eslintrc.js \"src/**/*.ts\"",
1313
"format": "prettier --config ../../prettier.config.js --ignore-path ../../.prettierignore --write \"**/*.{ts,md,json}\"",
14-
"extract:docs": "api-extractor run --local",
14+
"extract:docs": "node ./scripts/fix-api-extractor && api-extractor run --local && node ./scripts/fix-api-extractor --unset",
1515
"test": "yarn g:vitest run",
1616
"test:watch": "yarn g:vitest watch"
1717
},
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
const fs = require("node:fs");
2+
const path = require("path");
3+
4+
const file = path.join(__dirname, "..", "dist-types", "index.d.ts");
5+
6+
const contents = fs.readFileSync(file, "utf-8");
7+
8+
/**
9+
* This build script temporarily excludes the statement
10+
* ```
11+
* export * from "@smithy/core/serde";
12+
* ```
13+
* from the package's type declarations during running api-extractor.
14+
*
15+
* This has no effect on the runtime, but api-extractor at this time cannot understand
16+
* the package.json exports field nor the compatibility redirect (packages/core/serde.d.ts).
17+
*/
18+
19+
module.exports = {
20+
source: `export * from "@smithy/core/serde";`,
21+
replacement: `/* export * from "@smithy/core/serde"; */`,
22+
unset() {
23+
fs.writeFileSync(file, contents.replace(module.exports.replacement, module.exports.source));
24+
},
25+
set() {
26+
fs.writeFileSync(file, contents.replace(module.exports.source, module.exports.replacement));
27+
},
28+
};
29+
30+
if (process.argv.includes("--unset")) {
31+
module.exports.unset();
32+
} else {
33+
module.exports.set();
34+
}

0 commit comments

Comments
 (0)