浏览代码

Fix compile errors in web

ghorsington 3 年之前
父节点
当前提交
aa740aed39
共有 4 个文件被更改,包括 77 次插入7 次删除
  1. 27 0
      web/Dockerfile
  2. 1 2
      web/src/client.ts
  3. 1 5
      web/src/routes/_layout.svelte
  4. 48 0
      web/src/sapper.d.ts

+ 27 - 0
web/Dockerfile

@@ -0,0 +1,27 @@
+FROM node:14-alpine
+
+RUN apk --no-cache add make
+
+WORKDIR /app
+
+COPY ./shared/package.json ./shared/package.json
+WORKDIR /app/shared
+RUN npm install
+
+WORKDIR /app
+
+COPY ./web/package.json ./web/package.json
+WORKDIR /app/web
+RUN npm install
+
+WORKDIR /app
+
+COPY ./shared ./shared
+COPY ./web ./web
+COPY ./Makefile ./Makefile
+
+RUN make build_web
+
+WORKDIR /app/web
+EXPOSE 3000
+CMD npm start

+ 1 - 2
web/src/client.ts

@@ -1,5 +1,4 @@
-// @ts-ignore -- generated package
-import * as sapper from "@sapper/app"; // eslint-disable-line import/no-unresolved
+import * as sapper from "@sapper/app";
 
 sapper.start({
 	target: document.querySelector("#sapper"),

+ 1 - 5
web/src/routes/_layout.svelte

@@ -1,13 +1,9 @@
 <script lang="typescript">
-	// @ts-ignore -- generated package
-	import { stores } from "@sapper/app"; // eslint-disable-line import/no-unresolved
+	import { stores } from "@sapper/app";
 
 	// You may not want to use `segment`, but it is passed for the time being and will
-	// create a warning if not expected: https://github.com/sveltejs/sapper-template/issues/210
 	// https://github.com/sveltejs/sapper/issues/824
 	export let segment: string = "";
-	// Silence unused export property warning
-	if (segment) {};
 
 	const { page } = stores();
 

+ 48 - 0
web/src/sapper.d.ts

@@ -0,0 +1,48 @@
+declare module '@sapper/app' {
+    // from sapper/runtime/src/app/types.ts
+    // sapper doesn't export its types yet
+    interface Redirect {
+        statusCode: number
+        location: string
+    }
+    // end
+
+    function goto(href: string, opts?: { replaceState: boolean }): Promise<unknown>
+    function prefetch(href: string): Promise<{ redirect?: Redirect; data?: unknown }>
+    function prefetchRoutes(pathnames: string[]): Promise<unknown>
+    function start(opts: { target: Element | null }): Promise<unknown>
+    const stores: () => {
+        page: PageStore<{
+            host: string,
+            path: string,
+            params: Record<string, unknown>,
+            query: Record<string, unknown>
+        }>,
+        preloading: boolean,
+        session: Writable<unknown>
+    };
+
+    export { goto, prefetch, prefetchRoutes, start, stores }
+}
+
+declare module '@sapper/server' {
+    import { RequestHandler } from 'express'
+
+    interface MiddlewareOptions {
+        session?: (req: Express.Request, res: Express.Response) => unknown
+        ignore?: unknown
+    }
+
+    function middleware(opts?: MiddlewareOptions): RequestHandler
+
+    export { middleware }
+}
+
+declare module '@sapper/service-worker' {
+    const timestamp: number
+    const files: string[]
+    const shell: string[]
+    const routes: { pattern: RegExp }[]
+
+    export { timestamp, files, files as assets, shell, routes }
+}