-
-
Notifications
You must be signed in to change notification settings - Fork 2.5k
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
Move hoisted script analysis optimization as experimental #8011
Conversation
🦋 Changeset detectedLatest commit: 9c775a5 The changes in this PR will be included in the next version bump. Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
walk(parentInfo.ast, { | ||
enter(node) { | ||
if (node.type === 'ImportDeclaration') { | ||
imports.push(node as ImportDeclaration); | ||
} else if ( | ||
node.type === 'ExportDefaultDeclaration' || | ||
node.type === 'ExportNamedDeclaration' | ||
) { | ||
exports.push(node as ExportNamedDeclaration | ExportDefaultDeclaration); | ||
} | ||
}, | ||
}); | ||
// All of the aliases the current component is imported as | ||
for (const node of (parentInfo.ast as any).body) { | ||
if (node.type === 'ImportDeclaration') { | ||
imports.push(node); | ||
} else if (node.type === 'ExportDefaultDeclaration' || node.type === 'ExportNamedDeclaration') { | ||
exports.push(node); | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Import and exports declarations are top level only, so use this optimization.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
One small suggestion to make this A++, @bluwy! (OK, to make my life easier in the future... but that still counts as A++ in my books!!) 😉
Co-authored-by: Sarah Rainsberger <sarah@rainsberger.ca>
Changes
Fix #7744
Supersedes and closes #7997
Move the feature in #7707 behind an experimental flag. And added extra comments to make the analysis easier to follow.
Testing
Updated hoisted script test to enable the experimental flags.
Docs
Added the jsdocs. cc @withastro/maintainers-docs for feedback!