sveltejs/sapper

Some bugs related to sapper cli dev, build and export options with flag --cwd

Opened this issue · 0 comments

I am trying to integrate sapper into nrwl/nx. So i wanted to change the structure of the folders and run into some bugs and issues:

  • When using the 'build-dir' option with sapper build, starting the server with node __sapper__/build fails with Error: ENOENT: no such file or directory, open '../../__sapper__/build/build.json'. (Reproduce with npm run build:builddir)
  • When using the flag --cwd together with sapper dev, then it seems that everything compiles fine, but when I try to load the url I get (node:30240) UnhandledPromiseRejectionWarning: Error: ENOENT: no such file or directory, open '__sapper__/dev/build.json'. (Reproduce with npm run dev)
  • sapper build has no static option, whereas sapper export and sapper dev have. I tried to change the reference to the static folder in the file server.js, but when building, the assets are not found (see my comment in the file server.js). Therefore it is not possible to move the static folder if a build is necessary.
  • In sapper build you specify the output directory directly after sapper build, in sapper dev and sapper export you specify this option with the flag --build-dir which is inconsistent.
  • I am using the sapper cli with the --cwd flag like --cwd ./apps/web-page. I have to specify an absolute path for the --build-dir flag to make the --build-dir option work.
  • When I use sapper export with the --build-dir option where the __sapper__ folder points not to the --cwd directory then the build part is at the specified --build-dir directory, but the exported files are at the specified --cwd directory and there is no command line flag to specify a directory for the exported files. (Reproduce with npm run export:builddir)
  • When using the --cwd flag the rollup.config.js specified at the path of the --cwd option is used. But to make sapper dev, sapper build or sapper export work, I need to have a file named rollup.config.js in the root directory. This file can be completely empty.

In a follow up I will also test the sapper flags --src and --routes. But for these I have to set up different repositories.

The repo can be found under https://github.com/floratmin/sample-sapper-cli-cwd-build-dir-static-options
To recognize which folder is used for the static content i changed the success kid picture with a success kit picture.

Expected behavior
The folder structure should be adoptable to different needs.

Information about your Sapper Installation:

  • The output of npx envinfo --system --npmPackages svelte,sapper,rollup,webpack --binaries --browsers
    System:
    OS: Linux 4.15 Ubuntu 18.04.2 LTS (Bionic Beaver)
    CPU: (8) x64 Intel(R) Core(TM) i7-3770 CPU @ 3.40GHz
    Memory: 175.39 MB / 11.67 GB
    Container: Yes
    Shell: 4.4.19 - /bin/bash
    Binaries:
    Node: 14.11.0 - ~/.nvm/versions/node/v14.11.0/bin/node
    npm: 6.14.8 - ~/.nvm/versions/node/v14.11.0/bin/npm
    Watchman: 4.9.0 - /usr/local/bin/watchman
    Browsers:
    Chrome: 84.0.4147.135
    npmPackages:
    rollup: ^2.3.4 => 2.28.2
    sapper: ^0.28.0 => 0.28.9
    svelte: ^3.17.3 => 3.29.0
  • Your browser
    Chrome 84

Severity
High severity, makes a 'clean' integration with nrwl/nx impossible.