Tyler Flint
10/04/2021, 3:54 PMsource-map-support
isn’t working either. I’m wondering if that’s because it separates the sourcemap from the code during build, instead of inlining it?thdxr
10/04/2021, 3:55 PMTyler Flint
10/04/2021, 3:55 PMTyler Flint
10/04/2021, 3:56 PMimport Koa from 'koa';
import bodyParser from 'koa-bodyparser';
import serverless from 'serverless-http';
import { isDev } from 'serverless-boost/app';
import { processRequest } from 'serverless-boost/lambda/request';
import { createContext } from '../app';
import endpoints from '../web';
// init the global context
const context = createContext();
// init the app
const web = new Koa();
// plumb the web stack
web
.use(bodyParser());
// log the requests
web.use(function(ctx, next) {
console.log(`${ctx.method} ${ctx.path}`);
return next();
});
// inject the global context into the request ctx state
web.use(function(ctx, next) {
ctx.state = context;
return next();
});
// attach endpoints
for (let { handle: attach } of endpoints) {
attach(web);
}
// run the serverless stack directly
export const main = processRequest(serverless(web));
Tyler Flint
10/04/2021, 3:57 PMsourceMap.install()
Tyler Flint
10/04/2021, 3:57 PMthdxr
10/04/2021, 3:58 PMthdxr
10/04/2021, 3:58 PMTyler Flint
10/04/2021, 3:59 PMTyler Flint
10/04/2021, 3:59 PMTyler Flint
10/04/2021, 4:01 PMTyler Flint
10/04/2021, 4:03 PMsource-map-support
basically fixes the default error stack backtrace to walk back through the source maps and get to the original source. So when you’re seeing the stack trace it’s the actual source, whether typescript, javascript, coffeescript, etc before it was compiled and minified.Tyler Flint
10/04/2021, 4:04 PMthdxr
10/04/2021, 4:05 PMthdxr
10/04/2021, 4:06 PMTyler Flint
10/04/2021, 4:06 PMimport sourceMap from 'source-map-support'
// source map support for sanity
sourceMap.install();
// handle the request
export const main = ...
Tyler Flint
10/04/2021, 4:09 PMReferenceError: bonk is not defined
at /src/web/status.js:14:5
instead of this:
ReferenceError: bonk is not defined
at /var/task/src/lambda/web.js:28593:5
Tyler Flint
10/04/2021, 4:10 PM