linaria
linaria copied to clipboard
Handle already hoisted bindings
Motivation
Fixes https://github.com/callstack/linaria/issues/1047
Summary
This incorrectly failed with an "unsupported error" in cases where the identifier was already hoisted.
A couple of lines down from here we return early if the binding.scope.parent is falsey. So I think it's safe to let this through.
Test plan
I wasn't able to get the test suite (or bootstrap) to run with pnpm so I haven't included any tests.
It seems like it would be fairly easy to add a snapshot test along the lines of the following to the test file here:
it('should work with already hoisted vars', async () => {
const { code, metadata } = await transform(
dedent`
function color() {
return 'red\
}
export const square = css\`
color: ${'${color()}'}
\`;
`,
[evaluator]
);
expect(code).toMatchSnapshot();
expect(metadata).toMatchSnapshot();
});