Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add link to source map visualization #63

Merged
merged 3 commits into from
Feb 24, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion .github/renovate.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
{
"$schema": "https://docs.renovatebot.com/renovate-schema.json",
"extends": ["github>Boshen/renovate", "helpers:pinGitHubActionDigestsToSemver"]
"extends": [
"github>Boshen/renovate",
"helpers:pinGitHubActionDigestsToSemver"
]
}
30 changes: 29 additions & 1 deletion src/components/output/CodegenPanel.vue
Original file line number Diff line number Diff line change
@@ -1,10 +1,38 @@
<script setup lang="ts">
import { computed } from 'vue'
import { useOxc } from '~/composables/oxc'
import OutputPreview from './OutputPreview.vue'

const { oxc } = await useOxc()

const sourcemapLink = computed(() => {
const code = oxc.value.codegenText
const map = oxc.value.codegenSourcemapText

Check failure on line 10 in src/components/output/CodegenPanel.vue

View workflow job for this annotation

GitHub Actions / Build Playground

Property 'codegenSourcemapText' does not exist on type 'Oxc'.
if (code && map) {
const hash = btoa(`${code.length}\0${code}${map.length}\0${map}`)
return `https://evanw.github.io/source-map-visualization/#${hash}`
}
return ''
})
</script>

<template>
<OutputPreview :code="oxc.codegenText" lang="tsx" />
<div class="w-full flex flex-col overflow-auto">
<OutputPreview :code="oxc.codegenText" lang="tsx" />
<a
v-if="sourcemapLink"
class="m-2 flex items-center self-start text-sm opacity-80"
:href="sourcemapLink"
target="_blank"
rel="noopener"
>
<span
class="text-[#3c3c43] font-medium dark:text-[#fffff5]/[.86] hover:text-[#3451b2] dark:hover:text-[#a8b1ff]"
>Visualize source map</span
>
<div
class="i-ri:arrow-right-up-line ml-1 h-3 w-3 text-[#3c3c43]/[.56] dark:text-[#fffff5]/[.6]"
/>
</a>
</div>
</template>
16 changes: 16 additions & 0 deletions src/components/sidebar/Codegen.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
<script setup lang="ts">
import Checkbox from '~/components/ui/Checkbox.vue'
import { useOxc } from '~/composables/oxc'
const { options } = await useOxc()
</script>

<template>
<div flex flex-col gap2>
<div font-medium>Codegen</div>
<Checkbox
v-model="options.codegen.enableSourcemap"

Check failure on line 12 in src/components/sidebar/Codegen.vue

View workflow job for this annotation

GitHub Actions / Build Playground

Property 'enableSourcemap' does not exist on type '{ indentation?: number | undefined; enableTypescript?: boolean | undefined; }'.
label="Enable Source Map"
/>
</div>
</template>
3 changes: 3 additions & 0 deletions src/components/sidebar/Sidebar.vue
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
<script setup lang="ts">
import Codegen from './Codegen.vue'
import Linter from './Linter.vue'
import Logo from './Logo.vue'
import Minifier from './Minifier.vue'
Expand All @@ -23,6 +24,8 @@ import Transformer from './Transformer.vue'
<Minifier />
<!-- <Prettier /> -->
<hr />
<Codegen />
<hr />
<OptionsDialog />
</div>
</aside>
Expand Down
4 changes: 3 additions & 1 deletion src/composables/oxc.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,9 @@
target: 'es2015',
isolatedDeclarations: false,
},
codegen: {},
codegen: {
enableSourcemap: true,

Check failure on line 42 in src/composables/oxc.ts

View workflow job for this annotation

GitHub Actions / Build Playground

Object literal may only specify known properties, and 'enableSourcemap' does not exist in type 'OxcCodegenOptions'.
},
minifier: {},
controlFlow: {
verbose: false,
Expand Down
Loading