Skip to content

chore(smithy-client): build-fix, hide submodule export from api-extractor #1596

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
May 15, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .changeset/pink-bats-explode.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
---
---
4 changes: 4 additions & 0 deletions packages/core/api-extractor.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"extends": "../../api-extractor.packages.json",
"mainEntryPointFilePath": "./dist-types/index.d.ts"
}
1 change: 1 addition & 0 deletions packages/core/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
"clean": "rimraf ./dist-* && rimraf *.tsbuildinfo || exit 0",
"lint": "npx eslint -c ../../.eslintrc.js \"src/**/*.ts\" --fix && node ./scripts/lint",
"format": "prettier --config ../../prettier.config.js --ignore-path ../../.prettierignore --write \"**/*.{ts,md,json}\"",
"extract:docs": "api-extractor run --local",
"test": "yarn g:vitest run",
"test:cbor:perf": "node ./scripts/cbor-perf.mjs",
"test:watch": "yarn g:vitest watch"
Expand Down
2 changes: 1 addition & 1 deletion packages/smithy-client/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
"clean": "rimraf ./dist-* && rimraf *.tsbuildinfo || exit 0",
"lint": "eslint -c ../../.eslintrc.js \"src/**/*.ts\"",
"format": "prettier --config ../../prettier.config.js --ignore-path ../../.prettierignore --write \"**/*.{ts,md,json}\"",
"extract:docs": "api-extractor run --local",
"extract:docs": "node ./scripts/fix-api-extractor && api-extractor run --local && node ./scripts/fix-api-extractor --unset",
"test": "yarn g:vitest run",
"test:watch": "yarn g:vitest watch"
},
Expand Down
34 changes: 34 additions & 0 deletions packages/smithy-client/scripts/fix-api-extractor.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
const fs = require("node:fs");
const path = require("path");

const file = path.join(__dirname, "..", "dist-types", "index.d.ts");

const contents = fs.readFileSync(file, "utf-8");

/**
* This build script temporarily excludes the statement
* ```
* export * from "@smithy/core/serde";
* ```
* from the package's type declarations during running api-extractor.
*
* This has no effect on the runtime, but api-extractor at this time cannot understand
* the package.json exports field nor the compatibility redirect (packages/core/serde.d.ts).
*/

module.exports = {
source: `export * from "@smithy/core/serde";`,
replacement: `/* export * from "@smithy/core/serde"; */`,
unset() {
fs.writeFileSync(file, contents.replace(module.exports.replacement, module.exports.source));
},
set() {
fs.writeFileSync(file, contents.replace(module.exports.source, module.exports.replacement));
},
};

if (process.argv.includes("--unset")) {
module.exports.unset();
} else {
module.exports.set();
}
Loading