sveltejs / template

Template for building basic applications with Svelte

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Svelte Typescript support inside Docker gives @rollup/plugin-typescript TS18003

fenilli opened this issue · comments

Describe the bug
After trying to create a docker image using a svelte app converted to typescript, it gives the error @rollup/plugin-typescript TS18003: No inputs were found in config file '/app/tsconfig.json'. Specified 'include' paths were '["src/**/"]' and 'exclude' paths were '["node_modules/","sapper/","public/"]' when npm run build is called, when you're inside a directory in the container: WORKDIR /app.

Logs

> [9/9] RUN npm run build:
sveltejs/svelte#11 0.395 
sveltejs/svelte#11 0.395 > svelte-app@1.0.0 build /app
sveltejs/svelte#11 0.395 > rollup -c
sveltejs/svelte#11 0.395 
sveltejs/svelte#11 0.703 
sveltejs/svelte#11 0.703 src/main.ts → public/build/bundle.js...
sveltejs/svelte#11 0.705 (!) Plugin typescript: @rollup/plugin-typescript TS18003: No inputs were found in config file '/app/tsconfig.json'. Specified 'include' paths were '["src/**/*"]' and 'exclude' paths were '["node_modules/*","__sapper__/*","public/*"]'.
sveltejs/svelte#11 0.705 [!] (plugin typescript) Error: @rollup/plugin-typescript: Couldn't process compiler options
sveltejs/svelte#11 0.709 Error: @rollup/plugin-typescript: Couldn't process compiler options
sveltejs/svelte#11 0.709     at error (/app/node_modules/rollup/dist/shared/rollup.js:5275:30)
sveltejs/svelte#11 0.709     at throwPluginError (/app/node_modules/rollup/dist/shared/rollup.js:18232:12)
sveltejs/svelte#11 0.709     at Object.error (/app/node_modules/rollup/dist/shared/rollup.js:18839:24)
sveltejs/svelte#11 0.709     at emitParsedOptionsErrors (/app/node_modules/@rollup/plugin-typescript/dist/index.js:333:17)
sveltejs/svelte#11 0.709     at Object.buildStart (/app/node_modules/@rollup/plugin-typescript/dist/index.js:627:13)
sveltejs/svelte#11 0.709     at /app/node_modules/rollup/dist/shared/rollup.js:19041:25
sveltejs/svelte#11 0.709     at async Promise.all (index 2)
sveltejs/svelte#11 0.709     at rollupInternal (/app/node_modules/rollup/dist/shared/rollup.js:20052:9)
sveltejs/svelte#11 0.709     at build (/app/node_modules/rollup/dist/bin/rollup:1467:20)
sveltejs/svelte#11 0.709     at runRollup (/app/node_modules/rollup/dist/bin/rollup:1649:21)
sveltejs/svelte#11 0.709 
sveltejs/svelte#11 0.717 npm ERR! code ELIFECYCLE
sveltejs/svelte#11 0.718 npm ERR! errno 1
sveltejs/svelte#11 0.723 npm ERR! svelte-app@1.0.0 build: `rollup -c`
sveltejs/svelte#11 0.723 npm ERR! Exit status 1
sveltejs/svelte#11 0.723 npm ERR! 
sveltejs/svelte#11 0.723 npm ERR! Failed at the svelte-app@1.0.0 build script.
sveltejs/svelte#11 0.723 npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
sveltejs/svelte#11 0.730 
sveltejs/svelte#11 0.730 npm ERR! A complete log of this run can be found in:
sveltejs/svelte#11 0.730 npm ERR!     /root/.npm/_logs/2021-02-14T18_46_39_529Z-debug.log
------
executor failed running [/bin/sh -c npm run build]: exit code: 1

To Reproduce

  1. npx degit sveltejs/template my-svelte-project inside WSL2 Ubuntu
  2. cd into my-svelte-project folder
  3. node scripts/setupTypeScript.js
  4. Create a Dockerfile at the root of the svelte app
  5. Add this to Dockerfile
ARG NODE_VERSION=14.15.5
FROM node:${NODE_VERSION}

WORKDIR /app

COPY package*.json ./
COPY rollup.config.js ./
COPY tsconfig.json ./

RUN npm install

COPY /public /public
COPY /src /src

RUN npm run build

ENV PORT=5000

EXPOSE ${PORT}

CMD npm run ${RUN:-dev}
  1. docker build -f Dockerfile -t my-svelte-app .

Expected behavior
Expected to run normally as the npm run build is running insided the /app workdir, creating the docker image correctly.

Information about your Svelte project:
System:
OS: Linux 5.4 Ubuntu 20.04.1 LTS (Focal Fossa)
CPU: (24) x64 AMD Ryzen 9 3900X 12-Core Processor
Memory: 9.19 GB / 12.44 GB
Container: Yes
Shell: 5.0.17 - /bin/bash
Binaries:
Node: 14.15.5 - ~/.nvm/versions/node/v14.15.5/bin/node
npm: 6.14.11 - ~/.nvm/versions/node/v14.15.5/bin/npm

The projects uses Rollup.

Severity
Its severe as its blocks the image to be created, meaning its not even possible to start working on a project.

Additional context
If WORKDIR /app is removed the image builds correctly.

If tsconfig.json is changed to be:

{
  "extends": "@tsconfig/svelte/tsconfig.json",

  "include": ["/src/**/*"],
  "exclude": ["/node_modules/*", "/__sapper__/*", "/public/*"]
}

It gives this error instead:

> [9/9] RUN npm run build:
sveltejs/svelte#13 0.504 
sveltejs/svelte#13 0.504 > svelte-app@1.0.0 build /app
sveltejs/svelte#13 0.504 > rollup -c
sveltejs/svelte#13 0.504 
sveltejs/svelte#13 0.837 
sveltejs/svelte#13 0.837 src/main.ts → public/build/bundle.js...
sveltejs/svelte#13 0.855 [!] Error: Could not resolve entry module (src/main.ts).
sveltejs/svelte#13 0.859 Error: Could not resolve entry module (src/main.ts).
sveltejs/svelte#13 0.859     at error (/app/node_modules/rollup/dist/shared/rollup.js:5275:30)
sveltejs/svelte#13 0.859     at ModuleLoader.loadEntryModule (/app/node_modules/rollup/dist/shared/rollup.js:18730:20)
sveltejs/svelte#13 0.859     at async Promise.all (index 0)
sveltejs/svelte#13 0.859 
sveltejs/svelte#13 0.867 npm ERR! code ELIFECYCLE
sveltejs/svelte#13 0.867 npm ERR! errno 1
sveltejs/svelte#13 0.871 npm ERR! svelte-app@1.0.0 build: `rollup -c`
sveltejs/svelte#13 0.871 npm ERR! Exit status 1
sveltejs/svelte#13 0.871 npm ERR! 
sveltejs/svelte#13 0.871 npm ERR! Failed at the svelte-app@1.0.0 build script.
sveltejs/svelte#13 0.872 npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
sveltejs/svelte#13 0.876 
sveltejs/svelte#13 0.876 npm ERR! A complete log of this run can be found in:
sveltejs/svelte#13 0.877 npm ERR!     /root/.npm/_logs/2021-02-14T18_47_17_555Z-debug.log

If rollup.config.js input: is changed to be: input: '/src/main.ts',, its works like expected.

Possible Solution
Changing the typescript script scripts/setupTypeScript.js to add / before both tsconfig.json "includes and excludes" and rollup.config.js "input" solves for both using WORKDIR /app as not using any WORKDIR.