From 7636289804d3f4b5769ec89b4150072a9cf1a9c0 Mon Sep 17 00:00:00 2001 From: George Fu Date: Thu, 14 Nov 2024 16:28:01 +0000 Subject: [PATCH] fix: avoid self referencing import for external build transforms --- .changeset/sweet-horses-impress.md | 5 +++++ packages/core/scripts/lint.js | 13 +++++++++++++ .../core/src/submodules/protocols/requestBuilder.ts | 3 ++- 3 files changed, 20 insertions(+), 1 deletion(-) create mode 100644 .changeset/sweet-horses-impress.md diff --git a/.changeset/sweet-horses-impress.md b/.changeset/sweet-horses-impress.md new file mode 100644 index 00000000000..e73d3565b17 --- /dev/null +++ b/.changeset/sweet-horses-impress.md @@ -0,0 +1,5 @@ +--- +"@smithy/core": patch +--- + +avoid self referencing submodule import diff --git a/packages/core/scripts/lint.js b/packages/core/scripts/lint.js index 2eea0d15522..eb95fccb233 100644 --- a/packages/core/scripts/lint.js +++ b/packages/core/scripts/lint.js @@ -110,6 +110,19 @@ const walk = require("../../../scripts/utils/walk"); ); } } + + const subModuleImports = [ + ...new Set( + (sourceCode.toString().match(/(from |import\()"\@smithy\/core\/(.*?)";/g) || []).map( + (_) => _.match(/@smithy\/core\/(.*?)"/)[1] + ) + ), + ]; + const ownModule = item.match(/src\/submodules\/(.*?)\//)?.[1]; + + if (subModuleImports.includes(ownModule)) { + errors.push(`self-referencing submodule import found in ${item}`); + } } })().then(() => { if (errors.length) { diff --git a/packages/core/src/submodules/protocols/requestBuilder.ts b/packages/core/src/submodules/protocols/requestBuilder.ts index c6d2dfc7e83..5ec514766b8 100644 --- a/packages/core/src/submodules/protocols/requestBuilder.ts +++ b/packages/core/src/submodules/protocols/requestBuilder.ts @@ -1,7 +1,8 @@ -import { resolvedPath } from "@smithy/core/protocols"; import { HttpRequest } from "@smithy/protocol-http"; import type { SerdeContext } from "@smithy/types"; +import { resolvedPath } from "./resolve-path"; + /** * @internal * used in code-generated serde.