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

Mention inline modules cannot export things #33968

Merged
merged 2 commits into from
Jun 17, 2024

Conversation

Josh-Cena
Copy link
Member

Fix #30520.

@DanKaplanSES What do you think?

@Josh-Cena Josh-Cena requested a review from a team as a code owner June 6, 2024 19:00
@Josh-Cena Josh-Cena requested review from teoli2003 and removed request for a team June 6, 2024 19:00
@github-actions github-actions bot added Content:JS JavaScript docs size/xs 0-5 LoC changed labels Jun 6, 2024
Copy link
Contributor

github-actions bot commented Jun 6, 2024

Preview URLs

(comment last updated: 2024-06-15 18:50:20)

You can only use `import` and `export` statements inside modules, not regular scripts.
You should generally define all your modules in separate files. Modules declared inline in HTML can only import other modules, but anything they export will not be accessible by other modules (because they don't have a URL).
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I love this paragraph. It's exactly what I was hoping to find when I first read the page.

files/en-us/web/javascript/guide/modules/index.md Outdated Show resolved Hide resolved
@github-actions github-actions bot added size/s 6-50 LoC changed and removed size/xs 0-5 LoC changed labels Jun 15, 2024
Copy link
Collaborator

@hamishwillee hamishwillee left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I very much like this fix. Looks like discussion has concluded so merging.

@hamishwillee hamishwillee merged commit edce35f into mdn:main Jun 17, 2024
8 checks passed
@Josh-Cena Josh-Cena deleted the no-inline-module branch June 17, 2024 03:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Content:JS JavaScript docs size/s 6-50 LoC changed
Projects
None yet
Development

Successfully merging this pull request may close these issues.

If possible, include an example of importing from an embedded module
3 participants