Skip to content

Preprocessing with Babel makes svelte components imports to be dropped #521

@Andarist

Description

@Andarist

I've seen related issues regarding TypeScript compiler but I couldn't find any related to Babel.

I've successfully worked around my issue but I wonder if this issue is known and if perhaps at least some note to the docs could be added about it.

Basically the problem is that the script and the template parts are preprocessed separately and thus when using @babel/preset-typescript the import like this gets dropped:

import ChildComp from './ChildComp.svelte';

Babel doesn't recognize that the ChildComp was actually referenced at the "runtime position" in the original source because that part of the source is not being given to it.

The workaround that I've used is to use this preset-level option onlyRemoveTypeImports: true

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions