From 9f16e37f84a7747914007f54f88106de11927f1e Mon Sep 17 00:00:00 2001 From: Shodai Suzuki Date: Tue, 6 Feb 2024 09:34:34 +0900 Subject: [PATCH] fix(msw): fixed imports of `split-tags`, `tags`, and `split` mode (#1205) --- packages/core/src/writers/split-mode.ts | 6 +++++- packages/core/src/writers/split-tags-mode.ts | 5 ++++- packages/core/src/writers/tags-mode.ts | 4 +++- 3 files changed, 12 insertions(+), 3 deletions(-) diff --git a/packages/core/src/writers/split-mode.ts b/packages/core/src/writers/split-mode.ts index 916afa762..6c987d6d1 100644 --- a/packages/core/src/writers/split-mode.ts +++ b/packages/core/src/writers/split-mode.ts @@ -59,9 +59,13 @@ export const writeSplitMode = async ({ packageJson: output.packageJson, output, }); + mockData += builder.importsMock({ implementation: implementationMock, - imports: [{ exports: imports, dependency: relativeSchemasPath }], + imports: [ + { exports: imports, dependency: relativeSchemasPath }, + { exports: importsMock, dependency: relativeSchemasPath }, + ], specsName, hasSchemaDir: !!output.schemas, isAllowSyntheticDefaultImports, diff --git a/packages/core/src/writers/split-tags-mode.ts b/packages/core/src/writers/split-tags-mode.ts index a9f4df21a..bce8c5064 100644 --- a/packages/core/src/writers/split-tags-mode.ts +++ b/packages/core/src/writers/split-tags-mode.ts @@ -75,7 +75,10 @@ export const writeSplitTagsMode = async ({ }); mockData += builder.importsMock({ implementation: implementationMock, - imports: importsForBuilder, + imports: [ + ...importsForBuilder, + { exports: importsMock, dependency: relativeSchemasPath }, + ], specsName, hasSchemaDir: !!output.schemas, isAllowSyntheticDefaultImports, diff --git a/packages/core/src/writers/tags-mode.ts b/packages/core/src/writers/tags-mode.ts index 23929b8a1..04f4b8f1e 100644 --- a/packages/core/src/writers/tags-mode.ts +++ b/packages/core/src/writers/tags-mode.ts @@ -76,7 +76,9 @@ export const writeTagsMode = async ({ if (output.mock) { data += builder.importsMock({ implementation: implementationMock, - imports: importsForBuilder, + imports: [ + { exports: importsMock, dependency: schemasPathRelative }, + ], specsName, hasSchemaDir: !!output.schemas, isAllowSyntheticDefaultImports,