pngwn / MDsveX

A markdown preprocessor for Svelte.
https://mdsvex.pngwn.io
MIT License
2.36k stars 102 forks source link

npx sapper export results in 404 for index.svx #160

Open jamesb93 opened 4 years ago

jamesb93 commented 4 years ago

Hi again,

Using npx sapper export results in a build that 404's most pages. Does sapper-mdsvex support exporting in this way? The goal is to export on a branch for github pages.

jamesb93 commented 4 years ago

Hi sorry, I realise my original bug report was not that informative. I went back to investigate this further and thought I would start by providing my log. This is from a fresh pull using npx degit.

> Built in 2.1s
> Crawling http://localhost:3000/
(node:10029) UnhandledPromiseRejectionWarning: TypeError: Cannot read property 'parts' of undefined
    at handle_page (/Users/james/dev/webdev/freshy/__sapper__/build/server/server.js:2856:23)
    at Array.find_route (/Users/james/dev/webdev/freshy/__sapper__/build/server/server.js:3140:4)
    at nth_handler (/Users/james/dev/webdev/freshy/__sapper__/build/server/server.js:3249:14)
    at /Users/james/dev/webdev/freshy/__sapper__/build/server/server.js:3249:31
    at Array.find_route (/Users/james/dev/webdev/freshy/__sapper__/build/server/server.js:738:3)
    at nth_handler (/Users/james/dev/webdev/freshy/__sapper__/build/server/server.js:3249:14)
    at /Users/james/dev/webdev/freshy/__sapper__/build/server/server.js:3249:31
    at Array.<anonymous> (/Users/james/dev/webdev/freshy/__sapper__/build/server/server.js:3305:4)
    at nth_handler (/Users/james/dev/webdev/freshy/__sapper__/build/server/server.js:3249:14)
    at /Users/james/dev/webdev/freshy/__sapper__/build/server/server.js:3249:31
(Use `node --trace-warnings ...` to show where the warning was created)
(node:10029) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). To terminate the node process on unhandled promise rejection, use the CLI flag `--unhandled-rejections=strict` (see https://nodejs.org/api/cli.html#cli_unhandled_rejections_mode). (rejection id: 1)
(node:10029) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.
    1.3 kB   (404) index.html

> Finished in 7.2s. Type npx serve __sapper__/export to run the app.
pngwn commented 4 years ago

Are you using any processors?

jamesb93 commented 4 years ago

Not as far as I know. This happens on a fresh project too using the template with npx degit "pngwn/sapper-mdsvex-template" fresh-site

betweenvenus commented 4 years ago

I'm also getting 404's on all pages immediately from the dev server. I'm on Windows, I wonder if OP is on Windows as well?

jamesb93 commented 4 years ago

hi @betweenvenus I'm on macOS 10.14.6. I have Windows on another machine that I'd be happy to help debug with though if that helps @pngwn.

pngwn commented 4 years ago

I'll take a look at this as soon as I can. Pretty busy right now sadly. Not entirely sure what is going on.

jamesb93 commented 4 years ago

No worries, I appreciate anything you can do to look into it. If you roughly know the issue and can delegate away I'd be happy dig further on your behalf.

betweenvenus commented 4 years ago

@pngwn Thank you! No need to stress at all since it seems like only a couple of us have this issue so far.

pngwn commented 4 years ago

I just gave the template a quick test and can't recreate this so far but maybe if i replicate your environments I can make some progress.

Could you both run the follow command and copy the output here:

npx envinfo --system --npmPackages svelte,sapper,rollup,webpack --binaries --browsers

Thanks!

jamesb93 commented 4 years ago

  System:
    OS: macOS Mojave 10.14.6
    CPU: (8) x64 Intel(R) Core(TM) i7-4980HQ CPU @ 2.80GHz
    Memory: 2.36 GB / 16.00 GB
    Shell: 3.1.2 - /usr/local/bin/fish
  Binaries:
    Node: 14.11.0 - /usr/local/bin/node
    Yarn: 1.22.5 - /usr/local/bin/yarn
    npm: 6.14.8 - /usr/local/bin/npm
  Browsers:
    Edge: 85.0.564.41
    Firefox: 80.0.1
    Safari: 13.1.2
  npmPackages:
    rollup: ^2.23.1 => 2.23.1 
    sapper: ^0.28.0 => 0.28.5 
    svelte: ^3.0.0 => 3.24.1 
jamesb93 commented 4 years ago

And same problem after runing yarn upgade sevlte sapper:


  System:
    OS: macOS Mojave 10.14.6
    CPU: (8) x64 Intel(R) Core(TM) i7-4980HQ CPU @ 2.80GHz
    Memory: 1.67 GB / 16.00 GB
    Shell: 3.1.2 - /usr/local/bin/fish
  Binaries:
    Node: 14.11.0 - /usr/local/bin/node
    Yarn: 1.22.5 - /usr/local/bin/yarn
    npm: 6.14.8 - /usr/local/bin/npm
  Browsers:
    Edge: 85.0.564.41
    Firefox: 80.0.1
    Safari: 13.1.2
  npmPackages:
    rollup: ^2.23.1 => 2.23.1 
    sapper: ^0.28.0 => 0.28.8 
    svelte: ^3.0.0 => 3.26.0 
betweenvenus commented 4 years ago

@pngwn Here's mine:

npx: installed 1 in 1.416s

  System:
    OS: Windows 10 10.0.18363
    CPU: (4) x64 Intel(R) Core(TM) i5-7600 CPU @ 3.50GHz
    Memory: 3.22 GB / 15.96 GB
  Binaries:
    Node: 12.18.4 - C:\Program Files\nodejs\node.EXE
    Yarn: 1.22.5 - ~\AppData\Roaming\npm\yarn.CMD
    npm: 6.14.6 - C:\Program Files\nodejs\npm.CMD
  Browsers:
    Edge: Spartan (44.18362.449.0)
    Internet Explorer: 11.0.18362.1
  npmPackages:
    rollup: ^2.23.1 => 2.23.1
    sapper: ^0.28.0 => 0.28.0
    svelte: ^3.0.0 => 3.24.1
jamesb93 commented 3 years ago

Hey @pngwn sorry to bother you - imagine you are still quite busy. Did you happen to find out why we might have been seeing this error?

jamesb93 commented 3 years ago

I did a bit of digging myself with some interesting results.

If I clone this repository and follow these stops I get a successful npx sapper export (albeit it without a proper index.html?):

git clone https://github.com/pngwn/sapper-mdsvex-template cd sapper-mdsvex-template rm package-lock.json yarn.lock rm -rf node_modules npm i npx sapper export

However, if I run the same steps with yarn I get the error. Even after cleaning my own project out lock files and reinstalling with npm the error reproduces so I'm wondering if there is something that needs to be done properly in initialisation here.

jamesb93 commented 3 years ago

Okay I think I have found the issue @pngwn @betweenvenus and it is beautifully simple.

I think we have both been runing npx sapper export.

You want to run yarn run export or npm run export otherwise it doesnt actually pass the correct arguments as one would expect here (taken from package.json).

"export": "sapper export --legacy --ext '.svelte .svx'"

pngwn commented 3 years ago

Aaaah that is a sneaky one. Thanks so much for this and I'm sorry I wasn't of much use here.

I'm going to reopen this and add a docs tag, due to the pain this has caused I think it is worthy of a docs entry.

pngwn commented 3 years ago

And this is the wrong repo.

betweenvenus commented 3 years ago

You're the best @pngwn! And nicely done @jamesb93!