Skip to content

Commit

Permalink
fix: side effect imports (#584)
Browse files Browse the repository at this point in the history
Co-authored-by: Javier Rivas <JRivas@experianinteractive.com>
  • Loading branch information
ja-rivas and Javier Rivas authored Jul 21, 2022
1 parent a51701e commit dae644a
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 1 deletion.
15 changes: 15 additions & 0 deletions packages/core/src/helpers/render-imports.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,19 @@ describe('renderImport', () => {
});
expect(output).toMatchSnapshot();
});

test('Adds correctly a side-effect import', () => {
const data = [
{
imports: {},
path: '../render-blocks.scss',
},
];
const output = renderImport({
theImport: data[0],
target: 'react',
asyncComponentImports: false,
});
expect(output).toEqual("import '../render-blocks.scss';");
});
});
2 changes: 1 addition & 1 deletion packages/core/src/helpers/render-imports.ts
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ export const renderImport = ({
}
}

return `import ${importValue} from '${path}';`;
return importValue ? `import ${importValue} from '${path}';` : `import '${path}';`;
};

export const renderImports = ({
Expand Down

1 comment on commit dae644a

@vercel
Copy link

@vercel vercel bot commented on dae644a Jul 21, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.