Skip to content
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 import statement in resources/plugins.mdx after Aside (because it's already used before it's imported...) #2581

Conversation

trueberryless
Copy link
Contributor

@trueberryless trueberryless commented Nov 6, 2024

Description

  • I don't know if this is a bug, but I'm not sure why it actually works, but I think that:
  • import statement is misplaced and therefore moved to the top of the page (after the Aside)

Reason: The components imported are already used before being imported, or am I blind?

(already mentioned shortly in #2580)

Copy link

changeset-bot bot commented Nov 6, 2024

⚠️ No Changeset found

Latest commit: 47d72da

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

Copy link

netlify bot commented Nov 6, 2024

Deploy Preview for astro-starlight ready!

Name Link
🔨 Latest commit 47d72da
🔍 Latest deploy log https://app.netlify.com/sites/astro-starlight/deploys/672b7be41d8f00000876a58f
😎 Deploy Preview https://deploy-preview-2581--astro-starlight.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.
Lighthouse
Lighthouse
1 paths audited
Performance: 100 (no change from production)
Accessibility: 100 (no change from production)
Best Practices: 100 (no change from production)
SEO: 100 (no change from production)
PWA: -
View the detailed breakdown and full score reports

To edit notification comments on pull requests, go to your Netlify site configuration.

@delucis
Copy link
Member

delucis commented Nov 6, 2024

Ah, the position of import statements is actually unimportant in MDX (and even in regular JS as it happens), which admittedly might seem a bit surprising. The way that JS module loading works is that first all import statements are collected from the file and evaluated and then other code is run. For example, this is totally valid:

const result = callFunction('x');

import { callFunction } from './somewhere';

For legibility reasons you wouldn’t usually do that of course, but it’s not wrong as such.

@github-actions github-actions bot added the 📚 docs Documentation website changes label Nov 6, 2024
@astrobot-houston
Copy link
Collaborator

Lunaria Status Overview

🌕 This pull request will trigger status changes.

Learn more

By default, every PR changing files present in the Lunaria configuration's files property will be considered and trigger status changes accordingly.

You can change this by adding one of the keywords present in the ignoreKeywords property in your Lunaria configuration file in the PR's title (ignoring all files) or by including a tracker directive in the merged commit's description.

Tracked Files

Locale File Note
en resources/plugins.mdx Source changed, localizations will be marked as outdated.
Warnings reference
Icon Description
🔄️ The source for this localization has been updated since the creation of this pull request, make sure all changes in the source have been applied.

@trueberryless
Copy link
Contributor Author

For example, this is totally valid:

const result = callFunction('x');

import { callFunction } from './somewhere';

LOL, that reminds me of some weirdness I heard about var. I don't know if it still has this "functionality" but you could use a variable before declaring it. Comming from C# this just seems like a horror movie 😂

@delucis
Copy link
Member

delucis commented Nov 6, 2024

Yeah var also gets hoisted IIRC (at least the name declaration does, not the value). Although weird behaviour of var is also why everyone prefers let and const these days.

Anyway, given this I think we can close this PR. Thanks again! 🙌

@delucis delucis closed this Nov 6, 2024
@trueberryless trueberryless deleted the fix-move-import-statement-to-top branch November 6, 2024 20:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
📚 docs Documentation website changes
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants