Skip to content

Commit

Permalink
chore: refactor
Browse files Browse the repository at this point in the history
  • Loading branch information
antfu committed Apr 20, 2023
1 parent 8471f90 commit 913bb4c
Show file tree
Hide file tree
Showing 11 changed files with 8 additions and 6 deletions.
12 changes: 7 additions & 5 deletions src/ast/nodes/ImportExpression.ts
Expand Up @@ -73,9 +73,12 @@ export default class ImportExpression extends NodeBase {
const variables: string[] = [];

for (const property of objectPattern.properties) {
if (property.type === 'RestElement') return;
if (property.computed) return;
if (property.key.type !== 'Identifier') return;
if (
property.type === 'RestElement' ||
property.computed ||
property.key.type !== 'Identifier'
)
return;

Check warning on line 81 in src/ast/nodes/ImportExpression.ts

View check run for this annotation

Codecov / codecov/patch

src/ast/nodes/ImportExpression.ts#L81

Added line #L81 was not covered by tests
variables.push((property.key as Identifier).name);
}

Expand All @@ -86,8 +89,7 @@ export default class ImportExpression extends NodeBase {
if (awaitExpression.parent?.type !== 'MemberExpression') return;

const memberExpression = awaitExpression.parent as MemberExpression;
if (memberExpression.computed) return;
if (memberExpression.property.type !== 'Identifier') return;
if (memberExpression.computed || memberExpression.property.type !== 'Identifier') return;

return [(memberExpression.property as Identifier).name];
}
Expand Down
@@ -1,5 +1,5 @@
module.exports = {
description: 'treeshakes dynamic imports when the target is statically known',
description: 'treeshakes dynamic imports when the target is deterministic',
options: {
output: {
inlineDynamicImports: true
Expand Down

0 comments on commit 913bb4c

Please sign in to comment.