halfdanj / svelte-adapter-appengine Goto Github PK
View Code? Open in Web Editor NEWUtilize the Google Cloud App Engine infrastructure to host SvelteKit content.
License: Apache License 2.0
Utilize the Google Cloud App Engine infrastructure to host SvelteKit content.
License: Apache License 2.0
Currently doing some detective work around this but:
kit.prerender.entries
within my svelte.config.js
. These do not prerender.export const prerender = true
in their +page.ts
. These do prerender.crawl
is set to false
.My suspicion is that this may be an issue with the adapter API, rather than with this adapter, but it's highly frustrating.
Something changed in sveltejs/kit#6179 that needs to be fixed in the adapter.
I usually use app.yaml for development or stage deployment, and app_prod.yaml for production deployment.
Can't we pass an option such as defaultYamlFile(where the default value is app.yaml) so that one can specify which one to load?
With the recent announcement of 1.0 it would be great to get this in alignment.
"peerDependencies": {
"@sveltejs/kit": ">=1.0.0-next.341"
},
Thanks in advance,
Matt
Currently, AppEngine complains during upload:
Updating service [default]...⠶WARNING: *** Improve build performance by generating and committing package-lock.json.
If this is not some kind of config error on my part, I'll be happy to submit a PR for this.
Build failed with 1 error:
.svelte-kit/appengine-tmp/entry.js:3:8: error: No matching export in "node_modules/@sveltejs/kit/dist/install-fetch.js" for import "__fetch_polyfill"
Looks like the __fetch_polyfill
is now available as installFetch
as noted here: sveltejs/kit#4111
Does the adapter should support SvelteKit 2.0? Because I am getting the resolve dependency error with npm i
or npm upgrade
after applying npx svelte-migrate@latest sveltekit-2
migration script.
npm upgrade
npm ERR! code ERESOLVE
npm ERR! ERESOLVE unable to resolve dependency tree
npm ERR!
npm ERR! While resolving: [email protected]
npm ERR! Found: @sveltejs/[email protected]
npm ERR! node_modules/@sveltejs/kit
npm ERR! dev @sveltejs/kit@"^2.0.0" from the root project
npm ERR!
npm ERR! Could not resolve dependency:
npm ERR! peer @sveltejs/kit@"^1.0.0" from [email protected]
npm ERR! node_modules/svelte-adapter-appengine
npm ERR! dev svelte-adapter-appengine@"^0.10.3" from the root project
npm ERR!
npm ERR! Fix the upstream dependency conflict, or retry
npm ERR! this command with --force or --legacy-peer-deps
npm ERR! to accept an incorrect (and potentially broken) dependency resolution.
npm run build using the latest sveltekit fails on this line
import {getRawBody} from '@sveltejs/kit/node';
Build failed with 1 error:
.svelte-kit/appengine-tmp/entry.js:3:8: error: No matching export in "node_modules/@sveltejs/kit/dist/node.js" for import "getRawBody"
https://scratch.mit.edu/discuss/topic/549251/?page=24#post-5989763
This is not really an issue, but a question and/or a feature request (depending on the answer!)
Is there a better way to ask questions? Please alert me!
Does the adaptor support API endpoints? I created a simple one, but it doesn't seem to work once deployed.
Is there more documentation that I'm missing somewhere?
thanks,
-Steve
After successful file upload, the gcloud app deploy
step exits with the following error:
ERROR: (gcloud.app.deploy) Error Response: [3] "runtime: nodejs16" does not exist.
After checking the configuration of previous deployments using the "node" adapter, I can see that their runtime name was simply "nodejs".
Is any configuration inside gcloud required in order to use the specified "nodejs16" value generated into the app.yaml?
Hi there,
As Google has announced the general availability of nodejs18 recently it would be great to be able to configure which runtime the adapter uses rather than have it hardcoded.
Perhaps the we could pass this in via the svelte.config.js file as an optional when we instantiate the adapter, i.e.
adapter: appengine({
runtime: 'nodejs18'
})
Kind regards,
Matt
Upon adding the svelte-adapter-appengine I get the following error on build using strict typescript with lang="ts" in script tags.
<script lang="ts">
2 | import AuthHeader from '$lib/AuthHeader.svelte'
3 | import type { PageData } from './$types'
^
4 |
5 | export let data: PageData
error during build:
ParseError: Unexpected token
at error (file:///C:/gocode/src/Setyr/Web/node_modules/svelte/compiler.mjs:16669:19)
at Parser$1.error (file:///C:/gocode/src/Setyr/Web/node_modules/svelte/compiler.mjs:16747:9)
at Parser$1.acorn_error (file:///C:/gocode/src/Setyr/Web/node_modules/svelte/compiler.mjs:16741:14)
at Object.read_script [as read] (file:///C:/gocode/src/Setyr/Web/node_modules/svelte/compiler.mjs:8793:16)
at tag (file:///C:/gocode/src/Setyr/Web/node_modules/svelte/compiler.mjs:15695:33)
at new Parser$1 (file:///C:/gocode/src/Setyr/Web/node_modules/svelte/compiler.mjs:16706:21)
at parse$I (file:///C:/gocode/src/Setyr/Web/node_modules/svelte/compiler.mjs:16838:20)
at compile (file:///C:/gocode/src/Setyr/Web/node_modules/svelte/compiler.mjs:46610:17)
at compileSvelte2 (file:///C:/gocode/src/Setyr/Web/node_modules/@sveltejs/vite-plugin-svelte/dist/index.js:466:22)
at async Object.transform (file:///C:/gocode/src/Setyr/Web/node_modules/@sveltejs/vite-plugin-svelte/dist/index.js:2202:25)
svelte.config
import adapter from '@sveltejs/adapter-auto'
import { sveltekit, vitePreprocess } from '@sveltejs/kit/vite'
/** @type {import('@sveltejs/kit').Config} */
const config = {
// Consult https://kit.svelte.dev/docs/integrations#preprocessors
// for more information about preprocessors
preprocess: vitePreprocess(),
kit: {
adapter: adapter()
}
}
export default config
// import appengine from 'svelte-adapter-appengine'
// /** @type {import('@sveltejs/kit').Config} */
// export default {
// kit: {
// adapter: appengine()
// }
// }
With the default config everything works as expected.
Commenting out the "export default config" and uncommenting the adapter produces the error
FYI adding the "target" per the docs throws an exception
The server should handle _ah requests correctly to allow manual scaling
I intend on making a PR to implement this, but figured an issue first for thoughts would make sense.
I'm using this for a project, and I need to create an extra script to run after building to add some extra stuff to the app.yaml
- some of these things are variable like env_variables
, or service
(dev, staging or prod).
I think it would be useful for the adapter to accept another argument, which will be dumped as yaml into the resulting app.yaml
kit: {
adapter: appengine('build', [], {
service: process.env.SERVICE ,
instance_class: "F4",
automatic_scaling: {
min_instances: 1
},
inbound_services: [ "warmup" ]
})
}
While investigating why the integration tests in #29 continued to fail I saw that the /todos
endpoint of the demo app is broken when using the svelte-adapter-appengine on SvelteKit versions >= 1.0.0-next.356.
Steps to reproduce:
yes "" | npm init svelte@next example-app
cd example-app
npm install
npm install --save-dev svelte-adapter-appengine
sed -i 's/@sveltejs\/adapter-auto/svelte-adapter-appengine/' svelte.config.js
npm run build
node .appengine_build_output/index.js
Afterwards open http://localhost:8080/todos in the browser. The browser will try to load the page but it will never complete. I tested this with Chrome and Firefox on Linux. Interestingly when using curl
to fetch the same URL the response arrives immediately.
I also tried the same using the official SvelteKit node adapter but with the node adapter the page loads fine.
From the behavior I suspect the issue may be related to sveltejs/kit#5291 but I'm not exactly sure why this would lead to problems with the adapter.
I have a sveltekit project where I have a multiple images, css files, and fonts under /static folder.
When I build with sveltekit-adapter-appengine, I get this message:
You've exceeded the maximum number of routes (99) allowed in AppEngine app.yaml, and you have 113 routes.
This often happens when you have a lot of static assets.
If possible, use vites asset importing instead: https://kit.svelte.dev/docs/assets
Now when I look at the build/app.yaml file, each file's route is generated, causing the above error, such as:
- url: /img/icon/brand-a.svg
static_files: storage/img/icon/brand-a.svg
upload: storage/img/icon/brand-a.svg
secure: always
- url: /img/icon/brand-b.svg
static_files: storage/img/icon/brand-b.svg
upload: storage/img/icon/brand-b.svg
secure: always
Is there any way to get away with this error other than moving the static folder under /src such as generating the app.yaml file maybe just like below? (fix me if my syntaxes are wrong)
- url: /css/(.*\.(css))
static_files: storage/css/\1
upload: storage/css/(.*\.(css))
secure: always
- url: /img/(.+/)?([^/]+)
static_files: storage/img/\1\2
upload: storage/img/(.+/)?([^/]+)
secure: always
As of sveltejs/[email protected], SvelteKit is using Vite 4.
I'm prerendering my root path; however, when I look in build/
, index.html
is no longer present. (This was working on prior versions of SK). There are various issues floating around related to paths.base
and Vite, so I'm going to dive into the adapter in due course to see what's going on. It might be an API change that's effecting it. This issue is mainly me noting it out loud for now.
Even though running vite dev
and also vite preview
work locally, after deployment both chrome and safari aren't loading the JS due to this error (this is the chrome version, safari uses different wording):
Failed to load module script: Expected a JavaScript module script but the server responded with a MIME type of "text/plain". Strict MIME type checking is enforced for module scripts per HTML spec.
I'm not sure whether this is due to a change in the adapter or in sveltekit.
This occurs with adapter version 0.9.1 and sveltekit build 504 - I tried downgrading to 0.9.0 and 477, but the behavior is the same (also, undoing all code changes done in the project since using these older versions does not make a difference).
Despite having the secure:always , the app resolves to use the unsecure http rather than https .
Although adding secure to all the urls fixes it . As shown below :
`handlers:
Hello!
I'm getting this when I do npm run build:
Using appengine
builder.prerender() has been removed. Prerendering now takes place in the build phase — see builder.prerender and builder.writePrerendered
I believe this is related to a recent change here:
sveltejs/kit#4112
Thanks for looking into this.
It should be possible to supply a custom app yaml, for example with a custom scaling setting.
Adapter is broken after big revamp of the adapter api in sveltejs/kit#2931
I've got the followwing error when deploy the app:
status: FAILURE unmarshalling package.json: json: cannot unmarshal array into Go struct field PackageJSON.dependencies of type map[string]string
The generated package.json
is set to an empty array in dependencies
, when changed to an empty object it works.
Before:
{
"type": "commonjs",
"dependencies": []
}
After:
{
"type": "commonjs",
"dependencies": {}
}
With Sveltekit 2.0 now released it would be great to update this to support it.
When running the app on Google App Engine, I have the error "Invalid Request Body".
I am using the last version of Sveltekit.
The log for the build :
[email protected] build
vite build
vite v3.1.0 building for production...
✓ 30 modules transformed.
vite v3.1.0 building SSR bundle for production...
✓ 44 modules transformed.
Generated an empty chunk: "hooks"
.svelte-kit/output/server/vite-manifest.json 1.29 KiB
.svelte-kit/output/server/index.js 67.80 KiB
.svelte-kit/output/server/entries/endpoints/api/notifications/_server.ts.js 0.07 KiB
.svelte-kit/output/server/entries/fallbacks/layout.svelte.js 0.23 KiB
.svelte-kit/output/server/entries/fallbacks/error.svelte.js 1.50 KiB
.svelte-kit/output/server/entries/pages/_page.svelte.js 0.31 KiB
.svelte-kit/output/server/chunks/index.js 3.10 KiB
.svelte-kit/output/server/chunks/hooks.js 0.00 KiB
Run npm run preview to preview your production build locally.
.svelte-kit/output/client/vite-manifest.json 2.21 KiB
.svelte-kit/output/client/_app/immutable/components/layout.svelte-34b45f3a.js 0.53 KiB / gzip: 0.35 KiB
.svelte-kit/output/client/_app/immutable/components/error.svelte-ea5211a3.js 2.07 KiB / gzip: 0.95 KiB
.svelte-kit/output/client/_app/immutable/components/pages/_page.svelte-9e7c726b.js 0.81 KiB / gzip: 0.47 KiB
.svelte-kit/output/client/_app/immutable/chunks/singletons-d21fa692.js 1.81 KiB / gzip: 0.99 KiB
.svelte-kit/output/client/_app/immutable/start-b228e340.js 22.92 KiB / gzip: 8.99 KiB
.svelte-kit/output/client/_app/immutable/chunks/0-3f4b2ff7.js 0.09 KiB / gzip: 0.09 KiB
.svelte-kit/output/client/_app/immutable/chunks/1-253c57f3.js 0.09 KiB / gzip: 0.09 KiB
.svelte-kit/output/client/_app/immutable/chunks/2-fdf0651a.js 0.09 KiB / gzip: 0.10 KiB
.svelte-kit/output/client/_app/immutable/chunks/index-4f5b2732.js 6.62 KiB / gzip: 2.70 KiB
And the log of the deployment :
Services to deploy:
descriptor: [/home/virgile/Projets/bodela/sources/motard_way/backoffice/build/app.yaml]
source: [/home/virgile/Projets/bodela/sources/motard_way/backoffice/build]
target project: [motard-book]
target service: [default]
target version: [20220910t113338]
target url: [https://motard-book.nw.r.appspot.com]
target service account: [App Engine default service account]
Do you want to continue (Y/n)? Y
Beginning deployment of service [default]...
Created .gcloudignore file. See gcloud topic gcloudignore
for details.
╔════════════════════════════════════════════════════════════╗
╠═ Uploading 9 files to Google Cloud Storage ═╣
╚════════════════════════════════════════════════════════════╝
File upload done.
Updating service [default]...⠛WARNING: *** Improve build performance by generating and committing package-lock.json.
Updating service [default]...done.
Setting traffic split for service [default]...done.
Deployed service [default] to [https://motard-book.nw.r.appspot.com]
You can stream logs from the command line by running:
$ gcloud app logs tail -s default
To view your application in the web browser run:
$ gcloud app browse
Builds on the latest sveltekit release return this error:
.svelte-kit/appengine-tmp/entry.js:2:9: error: No matching export in "node_modules/@sveltejs/kit/dist/node/polyfills.js" for import "installFetch"
Sveltekit 341 renamed and moved installFetch
. I think the fix is just to use installPolyfills
from @sveltejs/kit/node/polyfills
instead of installFetch
.
"... Strict MIME type checking is enforced for module scripts per HTML spec."
When deploying files to App Engine with the help of this adapter, the javascript files that are uploaded to Google Cloud Storage (GCS) end up with the mime type text/plain (instead of "text/javascript" or perhaps "application/javascript"). This breaks my app and I can't figure out how to fix this, except by manually changing the metadata on every file within the corresponding GCS bucket. Any ideas?
Once deployed as an app to google cloud, I get this error on page load, or on refreshing the browser.
Failed to fetch dynamically imported module: https://xxxxx.ew.r.appspot.com/_app/undefined
it seems to happen as a result of an extra item inserted into the nodes array - import("/_app/undefined") when hydrating a page as below
Seems to relate to a similar issue across other cloud providers (see issue with vercel below)
As soon as I use page links, ie. by clicking on links within the pages (not refreshing the browser) everything functions and navigates as expected.
Steps to reproduce:
pnpm install --save-dev svelte-adapter-appengine
npm run build
. The following error messages are received.> .svelte-kit/appengine-tmp/entry.js:1:18: error: Could not resolve "polka" (mark it as external to exclude it from the bundle)
> .svelte-kit/appengine-tmp/entry.js:2:24: error: Could not resolve "compression" (mark it as external to exclude it from the bundle)
I was able to get around this by just running pnpm install --save-dev polka compression
and it worked fine, but It does increase my package size and it's likely worth documenting/looking into.
Thanks for writing this though I really wasn't looking forward to tackling this myself :).
I have an endpoint (src/routes/foo/[...slug].json/+server.ts
) that I prerender (for $reasons), by passing the paths into the list of paths to prerender in svelte.config.js
, and adding export const prerender = true
to the endpoint file.
This correctly outputs a pile of files as build/storage/foo/**/*.json
. However! It does not add those entries to the configured app.yaml
, meaning they don't get uploaded/handled correctly by GAE.
I think this might be also generating entries for items in builder.prerendered.paths
... but haven't had the time to look into this just yet.
Under the source directory in my Svelte project, I have a "static" folder containing images. Build adds the following lines to the app.yaml for each image file. These break the GCP deployment. By deleting these lines everything works as expected.
url: /fifthimage.jpg
static_files: storage\fifthimage.jpg
upload: storage\fifthimage.jpg
secure: always
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.