svelte-inline-compile icon indicating copy to clipboard operation
svelte-inline-compile copied to clipboard

Clarify that imports do not need to be within <script> tag

Open rgossiaux opened this issue 3 years ago • 2 comments

When I was looking at your Readme, the example with the imports inside

On a related note, do you mind if I publicize/advertise your project at all? I feel like I'm the first person to stumble upon it and I feel like this could get much broader adoption. It solves a huge pain point with the framework overall.

rgossiaux avatar Dec 30 '21 19:12 rgossiaux

That is a great idea! The component that gets generated will have a closure around the imports at the top of the file as well as any variables defined above it in the test function. We should showcase this as a way to decrease boilerplate. The only drawback to the approach is that linters will complain about unused imports/variables since they don’t know that they are being used by the generated component.

It would be awesome if you spread the word! Thank you!

drewchandler avatar Dec 30 '21 20:12 drewchandler

The only drawback to the approach is that linters will complain about unused imports/variables since they don’t know that they are being used by the generated component.

Ah yes, you're right. Actually it's a bit worse than that if you're using TypeScript-- the TS compiler removes all unused imports and shockingly there's no real way to disable that. I ended up adding in a dummy assertion of the form expect(A).not.toBe(B); to trick the TS compiler.

rgossiaux avatar Dec 31 '21 02:12 rgossiaux