Closed barryofguilder closed 4 months ago
Try
import type { WithBoundArgs } from '@glint/template';
we can't recommend import { type ... }
for type-only imports because we cannot be guaranteed, just from statically analyzing an import that there isn't a runtime side-effect occurring. As such, rollup (and any bundler) will leave the call to @glint/template
in the output code as a side-effecting import.
changing to import type
resolves.
That fixed it, thanks!
we can't recommend
import { type ... }
for type-only imports because we cannot be guaranteed, just from statically analyzing an import that there isn't a runtime side-effect occurring. As such, rollup (and any bundler) will leave the call to@glint/template
in the output code as a side-effecting import.changing to
import type
resolves.
Is this only for type-only imports from the "@glint/template" package or does this go for all type-only imports for any package? I have a bunch of other type-only imports where I do { type Foo } from ..
and there are no issues.
"@glint/template" package or does this go for all type-only imports for any package?
it goes for any package. You may not run in to errors at runtime from other packages because @glint/template
does not have any runtime code -- so it can't be resolved.
But for your other packages, you'll likely still have side-effectful imports in your output. This may be fine for your use case (esp as a runtime module exists), but it's something to keep in mind.
I generated a new addon using this blueprint today. When I'm adding the signature for one of my components and use the
WithBoundArgs
orComponentLike
types from "@glint/template", I get an error when running the test-app.My component in the addon:
Error message:
This error will happen with a
gts
or ats
file. Is there something I'm missing