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

🐛 BUG: Unable to export components #1214

Closed
jonathantneal opened this issue Aug 24, 2021 · 4 comments
Closed

🐛 BUG: Unable to export components #1214

jonathantneal opened this issue Aug 24, 2021 · 4 comments

Comments

@jonathantneal
Copy link
Contributor

jonathantneal commented Aug 24, 2021

What package manager are you using?

npm

What operating system are you using?

Mac

Describe the Bug

I want to publish a component package for Astro. Its usage would look like this:

---
import Icon from '@example/Icons'
---
<Icon.ZoomIn />

The @example/Icons package would resolve to an Icons.astro file that looks like this:

---
import Height from './Height.astro'
import Width from './Width.astro'
import ZoomIn from './ZoomIn.astro'
import ZoomOut from './ZoomOut.astro'

const Icon = {
	Height,
	Width,
	ZoomIn,
	ZoomOut,
}

export default Icon

export { Height, Width, ZoomIn, ZoomOut }
---

Unfortunately, this use of export throws the following error.

SyntaxError: [66:6]: The export keyword can only be used with the module goal

Preview

https://codesandbox.io/s/github/jonathantneal/astro-radix-icons

Is this a bug? How else might I do this?

Steps to Reproduce

  1. git clone https://github.com/jonathantneal/astro-radix-icons
  2. cd astro-radix-icons
  3. npm install
  4. npm start
  5. Error! SyntaxError: [66:6]: The export keyword can only be used with the module goal

Link to Minimal Reproducible Example (Optional)

https://github.com/jonathantneal/astro-radix-icons

@jasikpark
Copy link
Contributor

Can you try doing so in a regular js/ts file?

@jasikpark
Copy link
Contributor

@matthewp
Copy link
Contributor

Ah yeah, I didn't notice that, but we don't currently support exporting from .astro files at all.

@matthewp
Copy link
Contributor

This was attempted in #619, now there's #1142 as an RFC to make this possible. So going to close as a dupe, even though it definitely is an issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants