Skip to content
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

fix(core): add compatibility types for submodules #6509

Merged
merged 1 commit into from
Sep 24, 2024
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
7 changes: 7 additions & 0 deletions packages/core/account-id-endpoint.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
/**
* Do not edit:
* This is a compatibility redirect for contexts that do not understand package.json exports field.
*/
declare module "@aws-sdk/core/account-id-endpoint" {
export * from "@aws-sdk/core/dist-types/submodules/account-id-endpoint/index.d";
}
7 changes: 7 additions & 0 deletions packages/core/client.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
/**
* Do not edit:
* This is a compatibility redirect for contexts that do not understand package.json exports field.
*/
declare module "@aws-sdk/core/client" {
export * from "@aws-sdk/core/dist-types/submodules/client/index.d";
}
7 changes: 7 additions & 0 deletions packages/core/httpAuthSchemes.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
/**
* Do not edit:
* This is a compatibility redirect for contexts that do not understand package.json exports field.
*/
declare module "@aws-sdk/core/httpAuthSchemes" {
export * from "@aws-sdk/core/dist-types/submodules/httpAuthSchemes/index.d";
}
8 changes: 6 additions & 2 deletions packages/core/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -62,11 +62,15 @@
}
},
"files": [
"dist-*/**",
"./account-id-endpoint.d.ts",
"./account-id-endpoint.js",
"./client.d.ts",
"./client.js",
"./httpAuthSchemes.d.ts",
"./httpAuthSchemes.js",
"./protocols.d.ts",
"./protocols.js",
"./account-id-endpoint.js"
"dist-*/**"
],
"sideEffects": false,
"author": {
Expand Down
7 changes: 7 additions & 0 deletions packages/core/protocols.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
/**
* Do not edit:
* This is a compatibility redirect for contexts that do not understand package.json exports field.
*/
declare module "@aws-sdk/core/protocols" {
export * from "@aws-sdk/core/dist-types/submodules/protocols/index.d";
}
21 changes: 20 additions & 1 deletion packages/core/scripts/lint.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,11 @@ for (const submodule of submodules) {
};
fs.writeFileSync(path.join(root, "package.json"), JSON.stringify(pkgJson, null, 2) + "\n");
}
if (!pkgJson.files.includes(`./${submodule}.js`)) {
if (!pkgJson.files.includes(`./${submodule}.js`) || !pkgJson.files.includes(`./${submodule}.d.ts`)) {
pkgJson.files.push(`./${submodule}.js`);
pkgJson.files.push(`./${submodule}.d.ts`);
errors.push(`package.json files array missing ${submodule}.js compatibility redirect file.`);
pkgJson.files = [...new Set(pkgJson.files)].sort();
fs.writeFileSync(path.join(root, "package.json"), JSON.stringify(pkgJson, null, 2) + "\n");
}
// tsconfig metadata.
Expand All @@ -54,6 +56,23 @@ for (const submodule of submodules) {
* This is a compatibility redirect for contexts that do not understand package.json exports field.
*/
module.exports = require("./dist-cjs/submodules/${submodule}/index.js");
`
);
}
// compatibility types file.
const compatibilityTypesFile = path.join(root, `${submodule}.d.ts`);
if (!fs.existsSync(compatibilityTypesFile)) {
errors.push(`${submodule} is missing compatibility types file in the package root folder.`);
fs.writeFileSync(
compatibilityTypesFile,
`
/**
* Do not edit:
* This is a compatibility redirect for contexts that do not understand package.json exports field.
*/
declare module "@aws-sdk/core/${submodule}" {
export * from "@aws-sdk/core/dist-types/submodules/${submodule}/index.d";
}
`
);
}
Expand Down
Loading