lucacasonato / now-deno Goto Github PK
View Code? Open in Web Editor NEWDeno builder for Vercel - run Deno on Vercel. :sauropod: + λ = :heart:
Home Page: http://npmjs.com/package/now-deno
License: MIT License
Deno builder for Vercel - run Deno on Vercel. :sauropod: + λ = :heart:
Home Page: http://npmjs.com/package/now-deno
License: MIT License
Is there anything that prevents vercel dev
from bundling the contents?
Every time I run a lambda, I have no issues. But when I try to manually bundle it, or run vercel dev
I get this.
error: Uncaught AssertionError: Assertion failed.
at Object.assert ($deno$/util.ts:33:11)
at compile ($deno$/compiler.ts:1355:5)
at async tsCompilerOnMessage ($deno$/compiler.ts:1548:22)
at async workerMessageRecvCallback ($deno$/runtime_worker.ts:74:9)
So now I am not sure of the issue. If I remove mustache, it works. I had issues with multiple things that I am importing. I am not saying the vanilla code is an issue. I am trying to understand why it's so fragile, and what these libraries are using that can be bundled outside of now-deno
, but in combination with now-deno
just fail.
{
"version": 2,
"functions": {
"api/**/*.{j,t}s": {
"runtime": "[email protected]",
"includeFiles": "**/*.html"
}
},
"env": {
"DENO_UNSTABLE": "true"
}
}
import {
APIGatewayProxyEvent,
APIGatewayProxyResult,
Context,
} from "https://deno.land/x/lambda/mod.ts";
import { renderFile } from "https://deno.land/x/mustache/mod.ts";
export async function handler(
event: APIGatewayProxyEvent,
context: Context
): Promise<APIGatewayProxyResult> {
return {
statusCode: 200,
body: await renderFile(`template.html`, {
txt: "HEY",
}),
headers: {
"content-type": "text/html; charset=utf-8",
},
};
}
<p>Hello {{ txt }}</p>
Because of the change of name from Zeit to Vercel (blog post here), it would be relevant to change the repo tags (topics) to reflect that
note: Remember to include the --allow-read flag when rendering from files
I noticed this when trying to access a file. Vercel allows includedFiles
allowing lambdas to reference files that are compiled as part of it. Technically I don't think it "goes to disk", but I am seeing this permissions issues.
Is this supported today, and not documented? Or is this adding additional ENV variables like DENO_UNSTABLE to support?
Instead of bundling the application using deno bundle
before deployment it should just be precompiled with deno fetch
and then use .deno_dir for dependencies.
Support now dev
now dev
currently does not work on Windows. It should.
Following the docs on Vercel (https://vercel.com/docs/runtimes#official-runtimes/node-js) the Node runtimes first use the req/res handler style and support changes to AWS style with configuration, eg: NODEJS_AWS_HANDLER_NAME
.
It would be nice if now-deno
supports the same APIs style.
Hi, @lucacasonato!
First of all, thank you for the effort and nice bits of code you put on this project.
I tried to use it on a POC, but I'm getting permission errors on my Serverless function.
I already tried to debug and search for a possible explanation of how it works and how it starts my file on top of Deno, but I couldn't find any solution.
Could you help me with that issue?
I have a open PR ( at uqmessias/web-socket-react-native#1) with the code you can use to debug if you wish.
If I installed deno via asdf, now dev
doesn't seem working with the following error:
$ npx now dev
Now CLI 17.0.3 dev (beta) — https://zeit.co/feedback
> Creating initial build
> Success! Build completed
> Ready! Available at http://localhost:3000
unknown command: deno. Perhaps you have to reshim?
unknown command: deno. Perhaps you have to reshim?
error: bad deno executable
Unexpected bootstrap error when calling AWS_LAMBDA_RUNTIME_API /init/error:
InitException: bad deno executable
at Lambda.<anonymous> (/Users/kt3k/s/now-deno-example/node_modules/now/dist/index.js:2:3545645)
at Generator.next (<anonymous>)
at fulfilled (/Users/kt3k/s/now-deno-example/node_modules/now/dist/index.js:2:3543532)
at processTicksAndRejections (internal/process/task_queues.js:93:5)
If I removed asdf-installed deno and installed it with the official installer script, then it worked. Maybe this isn't a issue of this tool, but do you have any idea about the cause of the above error? @lucacasonato
I'm trying to use deno-postgres with now-deno as this example. But this doesn't deploy to now with the following build time error.
...
2020-02-13T16:22:18.209Z Download https://deno.land/x/[email protected]/md5.ts
2020-02-13T16:22:18.209Z Download https://deno.land/x/postgres/encode.ts
2020-02-13T16:22:18.209Z Download https://deno.land/x/postgres/decode.ts
2020-02-13T16:22:18.209Z Download https://deno.land/x/postgres/oid.ts
2020-02-13T16:22:18.209Z Download https://deno.land/x/postgres/deferred.ts
2020-02-13T16:22:18.209Z
2020-02-13T16:22:18.209Z error TS1343: The 'import.meta' meta-property is only allowed when the '--module' option is 'esnext' or 'system'.
2020-02-13T16:22:18.210Z
2020-02-13T16:22:18.210Z ► https://deno.land/[email protected]/testing/runner.ts:294:5
2020-02-13T16:22:18.210Z
2020-02-13T16:22:18.210Z 294 if (import.meta.main) {
2020-02-13T16:22:18.210Z ~~~~~~~~~~~
2020-02-13T16:22:18.210Z
2020-02-13T16:22:18.210Z
2020-02-13T16:22:18.210Z at buildDenoLambda (/zeit/82db6065a0e33879/.build-utils/.builder/node_modules/now-deno/dist/index.js:63:15)
2020-02-13T16:22:18.210Z at runMicrotasks (<anonymous>)
2020-02-13T16:22:18.210Z at processTicksAndRejections (internal/process/task_queues.js:93:5)
2020-02-13T16:22:18.270Z worker exited with code 20 and signal null
2020-02-13T16:22:20.560Z Done with "api/read.ts"
In the upcoming deno 1.0.0 release, clients can bundle a module with their own tsconfig file with --config
flag, addressed in the release note in v1.0.0-rc2 here
Looking at the source code, the runtime hasn't implement this option yet.
Line 92 in 12d7195
In addition, since it needs config file location, maybe creating new environment value tsconfig
under env
parameter in now.json
would be a good idea in this case.
Atm now-deno uses the latest release but I think it would be good for users to (optionally?) pass a version number for the deno-lambda release to use.
(In the future this will match the deno version.)
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.