aboutsummaryrefslogtreecommitdiff
path: root/packages/bun-debug-adapter-protocol/src/debugger/sourcemap.test.ts
blob: 44d9ca3621d217aaa8784bf52da95952c33476e4 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
import { test, expect } from "bun:test";
import { readFileSync } from "node:fs";
import { SourceMap } from "./sourcemap";

test("works without source map", () => {
  const sourceMap = getSourceMap("without-sourcemap.js");
  expect(sourceMap.generatedLocation({ line: 7 })).toEqual({ line: 7, column: 0, verified: true });
  expect(sourceMap.generatedLocation({ line: 7, column: 2 })).toEqual({ line: 7, column: 2, verified: true });
  expect(sourceMap.originalLocation({ line: 11 })).toEqual({ line: 11, column: 0, verified: true });
  expect(sourceMap.originalLocation({ line: 11, column: 2 })).toEqual({ line: 11, column: 2, verified: true });
});

test("works with source map", () => {
  const sourceMap = getSourceMap("with-sourcemap.js");
  // FIXME: Columns don't appear to be accurate for `generatedLocation`
  expect(sourceMap.generatedLocation({ line: 3 })).toMatchObject({ line: 4, verified: true });
  expect(sourceMap.generatedLocation({ line: 27 })).toMatchObject({ line: 20, verified: true });
  expect(sourceMap.originalLocation({ line: 32 })).toEqual({ line: 43, column: 4, verified: true });
  expect(sourceMap.originalLocation({ line: 13 })).toEqual({ line: 13, column: 6, verified: true });
});

function getSourceMap(filename: string): SourceMap {
  const { pathname } = new URL(`./fixtures/${filename}`, import.meta.url);
  const source = readFileSync(pathname, "utf-8");
  const match = source.match(/\/\/# sourceMappingURL=(.*)$/m);
  if (match) {
    const [, url] = match;
    return SourceMap(url);
  }
  return SourceMap();
}
s'>+82 * Fix Netlify adapter and dynamic routes * Changeset 2022-04-06fix(integrations): `astro:build:done` dir now matches SSR client output (#3008)Gravatar Juan Martín Seery 5-7/+20 * `dir` now matches client output * Updated integrations * Changeset 2022-04-06fix: Nested hydration with Solid (#3003)Gravatar Ryan Carniato 3-16/+44 * fix: solid nested hydration * Create ten-rice-unite.md Co-authored-by: Nate Moore <natemoo-re@users.noreply.github.com> 2022-04-06[ci] formatGravatar natemoo-re 2-6/+15 2022-04-06Astro add docs (#2958)Gravatar Peter Singh 3-3/+49 * So This works 😎 * need to add to the cli next * Renamed Files and Export Applied creditation to where I found the 'inspiration' for this application. * applied `astro docs` to cli * Trying to add to CLI, Not working 🤷‍♂️ * Converted into async method, * 🎆🎆 It works!!! 🥳🎉🥳 Embarrasing as it is I totally missed the part where logic was to be in. * Moved `docs` cmd to `supportedCommands` * refactor: cleanup docs command * chore: add changeset * chore: rename browser to open Co-authored-by: Nate Moore <nate@skypack.dev> 2022-04-06fix: @astrojs/vercel bug fixes (#3000)Gravatar Juan Martín Seery 2-6/+29 * Fixed outDir * Updated server out * changeset * Renamed out to tmp 2022-04-06[ci] formatGravatar matthewp 1-32/+32 2022-04-06[ci] release (beta) (#3005)astro@1.0.0-beta.3Gravatar github-actions[bot] 31-88/+98 Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com> 2022-04-06Fixes dynamic API routes in SSR (#3006)Gravatar Matthew Phillips 4-1/+26 * Fixes dynamic API routes in SSR * Adds a changeset 2022-04-06[ci] formatGravatar tony-sull 1-1/+1 2022-04-06fix(#2981): keeps `astro preview` server alive (#3004)Gravatar Tony Sullivan 3-1/+17 * fix(#2981): keeps server alive * chore: adding changeset * keep alive until the 'close' or 'error' event fires 2022-04-06Update readme.mdGravatar Nate Moore 1-2/+3 2022-04-06[ci] collect statsGravatar FredKSchott 1-0/+1 2022-04-05[ci] formatGravatar matthewp 1-1/+1 2022-04-05[ci] release (beta) (#2997)@astrojs/netlify@0.1.1-beta.0Gravatar github-actions[bot] 3-2/+9 Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com> 2022-04-05Docs: netlify adapter site requirement (#2996)Gravatar Ben Holmes 3-4/+23 * feat: human-readable error on bad site or base * fix: human-readable error should have 1 config option * docs: update README * chore: changeset * docs: mention localhost for testing via netlify CLI 2022-04-05[ci] collect statsGravatar FredKSchott 1-0/+1 2022-04-05[ci] formatGravatar FredKSchott 1-32/+32 2022-04-04[ci] release (beta) (#2992)astro@1.0.0-beta.2Gravatar github-actions[bot] 31-87/+94 Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>