Skip to content
This repository has been archived by the owner on Mar 23, 2023. It is now read-only.

reExportDataFetching not working as expected #85

Open
benedfit opened this issue Aug 28, 2020 · 7 comments
Open

reExportDataFetching not working as expected #85

benedfit opened this issue Aug 28, 2020 · 7 comments

Comments

@benedfit
Copy link

benedfit commented Aug 28, 2020

The following config:

{
    defaultLayout: true,
    layoutPath: 'src/layouts',
    usesSrc: true,
    reExportDataFetching: true
}

Results in the following error when trying to export getStaticProps from a layout:

Attempted import error: 'getStaticProps' is not exported from '/Users/bedwards/Projects/newhighsco/jarvenis.com/src/layouts/index' (imported as '_getStaticProps').

Changing layoutPath to 'src/layouts` solved this issue for me, but wanted to warn anyone else who may fall into this issue

@jescalan
Copy link
Contributor

Could you check and see if #84 solves this issue?

@benedfit
Copy link
Author

It would, because I'd no longer need to set layoutPath, but I think the problem would still exist if someone else used dot-notation for layoutPath. I'll try and knock up a test case to check

@jescalan
Copy link
Contributor

Thank you, that would be super helpful!

@benedfit benedfit changed the title layoutPath starting with . results in getStaticProps error reExportDataFetching not working as expected Aug 29, 2020
@benedfit
Copy link
Author

So the dot-notation was a red herring, this issue seems to happen whenever I add a getStaticProps function to a layout.

Here is my project structure where I'm hitting the issue https://github.com/newhighsco/jarvenis.com/tree/feat/use-mdx. I'm currently refactoring to use MDX.

I followed the test fixtures at https://github.com/hashicorp/next-mdx-enhanced/tree/master/__tests__/fixtures/layout-exports-ssg, but run into the same issue even if my layouts are at the root of my project or under src

@benedfit
Copy link
Author

@jescalan got a working example anywhere I could reference?

@jescalan
Copy link
Contributor

jescalan commented Aug 31, 2020

@jescalan
Copy link
Contributor

I can look into this further this week, or you are welcome to open a PR and do so!

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

No branches or pull requests

2 participants