Skip to content
Snippets Groups Projects
Unverified Commit d74fbe95 authored by Phoomparin Mano's avatar Phoomparin Mano Committed by GitHub
Browse files

fix(sdk): fix typescript type references to embedding-sdk not resolving (#47659)

* replace plain embedding-sdk imports

* fix direct module imports
parent db9ca5ec
No related branches found
No related tags found
No related merge requests found
...@@ -14,14 +14,12 @@ const SDK_PACKAGE_NAME = "@metabase/embedding-sdk-react"; ...@@ -14,14 +14,12 @@ const SDK_PACKAGE_NAME = "@metabase/embedding-sdk-react";
// this map should be synced with "tsconfig.sdk.json" // this map should be synced with "tsconfig.sdk.json"
const REPLACES_MAP = { const REPLACES_MAP = {
"metabase-enterprise/": `${SDK_PACKAGE_NAME}/dist/enterprise/frontend/src/metabase-enterprise/`, "metabase-enterprise": `${SDK_PACKAGE_NAME}/dist/enterprise/frontend/src/metabase-enterprise`,
"metabase-lib/": `${SDK_PACKAGE_NAME}/dist/frontend/src/metabase-lib/`,
"metabase-lib": `${SDK_PACKAGE_NAME}/dist/frontend/src/metabase-lib`, "metabase-lib": `${SDK_PACKAGE_NAME}/dist/frontend/src/metabase-lib`,
"metabase-shared/": `${SDK_PACKAGE_NAME}/dist/frontend/src/metabase-shared/`, "metabase-types": `${SDK_PACKAGE_NAME}/dist/frontend/src/metabase-types`,
"metabase-types/": `${SDK_PACKAGE_NAME}/dist/frontend/src/metabase-types/`, "metabase": `${SDK_PACKAGE_NAME}/dist/frontend/src/metabase`,
"metabase/": `${SDK_PACKAGE_NAME}/dist/frontend/src/metabase/`, "embedding-sdk": `${SDK_PACKAGE_NAME}/dist/enterprise/frontend/src/embedding-sdk`,
"embedding-sdk/": `${SDK_PACKAGE_NAME}/dist/enterprise/frontend/src/embedding-sdk/`, "cljs": `${SDK_PACKAGE_NAME}/dist/target/cljs_release`,
"cljs/": `${SDK_PACKAGE_NAME}/dist/target/cljs_release/`,
}; };
const traverseFilesTree = dir => { const traverseFilesTree = dir => {
...@@ -49,7 +47,10 @@ const replaceAliasedImports = filePath => { ...@@ -49,7 +47,10 @@ const replaceAliasedImports = filePath => {
Object.entries(REPLACES_MAP).forEach(([alias, replacement]) => { Object.entries(REPLACES_MAP).forEach(([alias, replacement]) => {
fileContent = fileContent fileContent = fileContent
.replaceAll(`from "${alias}`, `from "${replacement}`) // replaces "metabase-lib/foo" with "<sdk>/metabase-lib/foo"
.replaceAll(`from "${alias}/`, `from "${replacement}/`)
// replaces "metabase-lib" with "<sdk>/metabase-lib"
.replaceAll(`from "${alias}"`, `from "${replacement}"`)
.replaceAll(`import("${alias}`, `import("${replacement}`) .replaceAll(`import("${alias}`, `import("${replacement}`)
.replace( .replace(
// replace dynamic imports using alias, with possible relative paths - "../../" and "frontend/src/" // replace dynamic imports using alias, with possible relative paths - "../../" and "frontend/src/"
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment