-
-
Notifications
You must be signed in to change notification settings - Fork 4.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
"default" is imported from external module "svelte-autosize" but never used #13122
Comments
See vitejs/vite#15890 for the info. |
I started exploring this a bit but i really don't like the solution (which also is not fully coded yet). My solution was basically to do what Basically instead of returning the ast immediately we could do this const all_imported_specifiers = new Set(
body
.filter((el) => el.type === 'ImportDeclaration')
.flatMap((import_thing) => {
return import_thing.specifiers.map((specifier) => specifier.local.name);
})
);
/**
* @type {{type: 'Program', sourceType: 'module', body: typeof body}}
*/
const returned_ast = {
type: 'Program',
sourceType: 'module',
body
};
walk(
returned_ast,
{},
{
Identifier(node, context) {
if (!context.path.some((parent) => parent.type === 'ImportDeclaration')) {
all_imported_specifiers.delete(node.name);
}
}
}
);
returned_ast.body = returned_ast.body.map((statement) => {
if (statement.type !== 'ImportDeclaration') return statement;
const updated_specifiers = statement.specifiers
.map((specifier) => {
if (all_imported_specifiers.has(specifier.local.name)) {
return null;
}
return specifier;
})
.filter(Boolean);
return {
...statement,
specifiers: updated_specifiers
};
});
return returned_ast; however this is very likely to have a lot of edge cases because of how svelte produces the output code: for the ast for an internal function calls the identifiers generally look like this {
type: "Identifier",
name: "$.each",
} instead of having a member access for the Considering this is basically doing work that rollup will already do (is just to mute the warning) and that it's not actually blocking (because it's just a warning)...do you think is worth it to explore? |
Describe the bug
"default" is imported from external module "svelte-autosize" but never used
Reproduction
Logs
No response
System Info
Severity
annoyance
The text was updated successfully, but these errors were encountered: