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

Allow exports in export block #554

Open
i-am-the-slime opened this issue Apr 7, 2024 · 5 comments
Open

Allow exports in export block #554

i-am-the-slime opened this issue Apr 7, 2024 · 5 comments
Labels
enhancement New feature or request good first issue Good for newcomers

Comments

@i-am-the-slime
Copy link

Is your feature request related to a problem? Please describe.
I'm using ladle with PureScript and it almost works. It's just that the compiler output looks like this:

var someStory = /* #__PURE__ */ // some JS component

export {
    someStory
};

This leads to the following error:

TypeError: Cannot read properties of null (reading 'type')
    at getNamedExports (/node_modules/@ladle/react/lib/cli/vite-plugin/parse/get-named-exports.js:31:30)

If I manually change this to say export var someStory =... and remove the export block it works fine.

Interestingly, it keeps working from there on out (so even when the file gets overwritten)

Describe the solution you'd like
I'd love for this to simply work without me having to change the output of the compiler.

Describe alternatives you've considered
If there was a way to hook into the reading of files, I could probably fix this with some regex or something more bespoke that traverses the AST, so that could be an alternative.
If that's something I could do with vite out of the box I'd be happy about any pointers.

@i-am-the-slime i-am-the-slime added the needs triage needs to be reviewed label Apr 7, 2024
@tajo
Copy link
Owner

tajo commented Apr 9, 2024

Valid request. We would need to add specifiers / ExportSpecifier here.

It's a different case from other ExportedNamedDeclarations.

Should be fairly straightforward if you want to open a PR.

@tajo tajo added enhancement New feature or request good first issue Good for newcomers and removed needs triage needs to be reviewed labels Apr 9, 2024
@woeps
Copy link

woeps commented Apr 25, 2024

Would it be (easily) possible to also support StoryDefault exported in export block like:

var storyDefault = {
  title: "Custom Title"
};

export {
  hello_world ,
  storyDefault as default,
}

If this is not yet covered by #556, would anybody have some pointers on what needs to be done to support it?

@i-am-the-slime
Copy link
Author

@woeps have you tried my branch? There's a test you can probably modify and see if it works already

@woeps
Copy link

woeps commented May 6, 2024

@i-am-the-slime I tried your branch locally and it seems StoryDefault in export block is not supported yet.
I haven't tinkered with any tests: Do you mean the tests in packages/ladle/tests/parse/get-storyname-and-meta.test.ts?

@i-am-the-slime
Copy link
Author

@woeps I mean this one on my fork/branch:

test("Export Block", async () => {

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request good first issue Good for newcomers
Projects
None yet
Development

No branches or pull requests

3 participants