diff --git a/.changeset/lucky-coins-march.md b/.changeset/lucky-coins-march.md new file mode 100644 index 0000000..ca74486 --- /dev/null +++ b/.changeset/lucky-coins-march.md @@ -0,0 +1,5 @@ +--- +"vite-plugin-relay-lite": patch +--- + +Dedupe import statements for compiled documents diff --git a/src/compile.test.ts b/src/compile.test.ts index c908fc0..66863e7 100644 --- a/src/compile.test.ts +++ b/src/compile.test.ts @@ -204,11 +204,8 @@ test('mixed case', () => { expect(result.code).toMatchInlineSnapshot(` "import graphql__f4ce3be5b8e81a99157cd3e378f936b6 from "./__generated__/Test.graphql"; import graphql__be4d44055d9f79bc8ffc68b6e8277222 from "./__generated__/TestFragment.graphql"; - import graphql__be4d44055d9f79bc8ffc68b6e8277222 from "./__generated__/TestFragment.graphql"; - import graphql__f4ce3be5b8e81a99157cd3e378f936b6 from "./__generated__/Test.graphql"; import graphql__37866396c946bd011298fc64841dcb46 from "./__generated__/TestTruthy.graphql"; import graphql__60fd06bd826b4b4bd4d4bb065b9f6e73 from "./__generated__/TestFalsy.graphql"; - import graphql__f4ce3be5b8e81a99157cd3e378f936b6 from "./__generated__/Test.graphql"; import external from 'x/y'; const host = \`\${host}/graphql\`; diff --git a/src/compile.ts b/src/compile.ts index 38fae14..9fd45de 100644 --- a/src/compile.ts +++ b/src/compile.ts @@ -100,7 +100,7 @@ export function compile( }); content.prepend( - [...imports, ''].join('\n'), + [...new Set(imports), ''].join('\n'), ); return {