Skip to content
This repository was archived by the owner on Jan 11, 2023. It is now read-only.
This repository was archived by the owner on Jan 11, 2023. It is now read-only.

Exporting a server route called index.js prevents routes further down the filesystem hierarchy from being exported #1170

Open
@antony

Description

@antony

Describe the bug
A bit of a mouthful.

If I have:

src
src/routes
src/routes/somedir/index.js
src/routes/somedir/[slug].js

The final server route ([slug].js) will fail to export with an error ENOTDIR.

The reason being that the following directory structure has been exported:

__sapper__/export/somedir [FILE]

which should be a [DIR] so that the nested routes can be exported to it.

Logs

> Built in 15.2s
> Crawling http://localhost:3001/blog/
    440 kB   api/v1/posts
    380 kB   index.html
     15 kB   api/v1/posts/highest-mountains-in-england

internal/fs/utils.js:229
    throw err;
    ^

Error: ENOTDIR: not a directory, open '/home/ant/Projects/beyonk-blog/web/__sapper__/export/blog/api/v1/posts/highest-mountains-in-england'
    at Object.openSync (fs.js:456:3)
    at Object.writeFileSync (fs.js:1297:35)
    at save (/home/ant/Projects/beyonk-blog/web/node_modules/sapper/dist/export.js:1800:6)
    at ChildProcess.<anonymous> (/home/ant/Projects/beyonk-blog/web/node_modules/sapper/dist/export.js:1805:3)
    at ChildProcess.emit (events.js:305:20)
    at emit (internal/child_process.js:883:12)
    at processTicksAndRejections (internal/process/task_queues.js:85:21) {
  errno: -20,
  syscall: 'open',
  code: 'ENOTDIR',
  path: '/home/ant/Projects/beyonk-blog/web/__sapper__/export/blog/api/v1/posts/highest-mountains-in-england'
}

To Reproduce
Create a directory structure as above. Having some machine issues right now so I can't create a repo, but it is inbound asap.

Expected behavior
I'm not exactly sure. I think that the index route should probably end up in an index file inside somedir so that the rest of the routes can be exported.

Information about your Sapper Installation:

  • Your operating system: Ubuntu 19.04

  • Sapper version: 0.29.12

  • Exported app

  • Rollup

Severity
I'm fairly sure I can work around it, but it's a problem for new users. I also know that it has caused a problem for the folk over at sanity.io, since their Sapper template doesn't actually result in a true static site, and you end up getting a couple of API requests per view which can rack up. I've raised sanity-io/sanity-template-sapper-blog#42 which I am trying to fix.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions