Skip to content

Commit

Permalink
fix: always generate linked sourcemaps and delete configuration option
Browse files Browse the repository at this point in the history
  • Loading branch information
ACHP committed Jun 22, 2022
1 parent d1c6488 commit 9cd0a34
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 17 deletions.
2 changes: 1 addition & 1 deletion .changeset/mighty-melons-walk.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@
'@sveltejs/adapter-vercel': patch
---

Add new option to generate sourcemap for the `functions/node/render/index.js` generated file
Add sourcemap generation for the generated functions
6 changes: 1 addition & 5 deletions packages/adapter-vercel/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,11 +30,7 @@ export default {

// if true, will split your app into multiple functions
// instead of creating a single one for the entire app
split: false,

// same as esbuild sourcemap option
// https://esbuild.github.io/api/#sourcemap
sourcemap: false
split: false
})
}
};
Expand Down
2 changes: 0 additions & 2 deletions packages/adapter-vercel/index.d.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,9 @@
import { Adapter } from '@sveltejs/kit';
import type { BuildOptions } from 'esbuild';

type Options = {
edge?: boolean;
external?: string[];
split?: boolean;
sourcemap?: BuildOptions['sourcemap'];
};

export default function plugin(options?: Options): Adapter;
16 changes: 7 additions & 9 deletions packages/adapter-vercel/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -84,19 +84,19 @@ const redirects = {
const files = fileURLToPath(new URL('./files', import.meta.url).href);

/** @type {import('.').default} **/
export default function ({ external = [], edge, split, sourcemap = false } = {}) {
export default function ({ external = [], edge, split } = {}) {
return {
name: '@sveltejs/adapter-vercel',

async adapt(builder) {
if (process.env.ENABLE_VC_BUILD) {
await v3(builder, external, edge, split, sourcemap);
await v3(builder, external, edge, split);
} else {
if (edge || split) {
throw new Error('`edge` and `split` options can only be used with ENABLE_VC_BUILD');
}

await v1(builder, external, sourcemap);
await v1(builder, external);
}
}
};
Expand All @@ -105,9 +105,8 @@ export default function ({ external = [], edge, split, sourcemap = false } = {})
/**
* @param {import('@sveltejs/kit').Builder} builder
* @param {string[]} external
* @param {import('esbuild').BuildOptions['sourcemap']} sourcemap
*/
async function v1(builder, external, sourcemap) {
async function v1(builder, external) {
const node_version = get_node_version();

const dir = '.vercel_build_output';
Expand Down Expand Up @@ -148,7 +147,7 @@ async function v1(builder, external, sourcemap) {
platform: 'node',
external,
format: 'cjs',
sourcemap
sourcemap: 'linked'
});

fs.writeFileSync(`${dirs.lambda}/package.json`, JSON.stringify({ type: 'commonjs' }));
Expand Down Expand Up @@ -204,9 +203,8 @@ async function v1(builder, external, sourcemap) {
* @param {string[]} external
* @param {boolean} edge
* @param {boolean} split
* @param {import('esbuild').BuildOptions['sourcemap']} sourcemap
*/
async function v3(builder, external, edge, split, sourcemap) {
async function v3(builder, external, edge, split) {
const node_version = get_node_version();

const dir = '.vercel/output';
Expand Down Expand Up @@ -306,7 +304,7 @@ async function v3(builder, external, edge, split, sourcemap) {
platform: 'node',
format: 'esm',
external,
sourcemap
sourcemap: 'linked'
});

write(
Expand Down

0 comments on commit 9cd0a34

Please sign in to comment.