Skip to content

Commit

Permalink
fix: trace dependency with nft (#3)
Browse files Browse the repository at this point in the history
* fix: trace dependency with nft

* add esbuild as dependency

* tweaks
  • Loading branch information
egoist committed Apr 24, 2021
1 parent 6b35a3c commit 1a0657f
Show file tree
Hide file tree
Showing 7 changed files with 440 additions and 56 deletions.
6 changes: 4 additions & 2 deletions example/handler.ts
@@ -1,8 +1,10 @@
import type { Handler } from '../'
import { transform } from 'esbuild'

export const handler: Handler = (req, res, next) => {
export const handler: Handler = async (req, res, next) => {
if (req.path === '/foo') {
res.end('foo')
const result = await transform(`export const foo = 1`, { format: 'cjs' })
res.end(result.code)
return
}
next()
Expand Down
9 changes: 9 additions & 0 deletions example/test-function.js
@@ -0,0 +1,9 @@
const polka = require('polka')

const app = polka()
const handler = require('./.vercel_build_output/functions/node/render').default

app.use(handler)

app.listen(3000)
console.log('http://localhost:3000')
3 changes: 2 additions & 1 deletion package.json
Expand Up @@ -28,6 +28,7 @@
"@sucrase/jest-plugin": "^2.0.0",
"@types/jest": "^26.0.20",
"@types/polka": "^0.5.2",
"esbuild": "^0.11.13",
"jest": "^26.6.3",
"polka": "^0.5.2",
"prettier": "^2.2.1",
Expand All @@ -42,6 +43,6 @@
"vite": "^2.2.1"
},
"dependencies": {
"esbuild": "^0.11.13"
"@vercel/nft": "^0.10.1"
}
}

1 comment on commit 1a0657f

@vercel
Copy link

@vercel vercel bot commented on 1a0657f Apr 24, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.