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

Can source-map README be written in more detail? #237

Closed
chapaofan-zy opened this issue Sep 3, 2024 · 2 comments
Closed

Can source-map README be written in more detail? #237

chapaofan-zy opened this issue Sep 3, 2024 · 2 comments

Comments

@chapaofan-zy
Copy link

Can source-map README be written in more detail?

or

How to transform a source-map like ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAAA;AACA,SAAS,EAAE,KAAK,CAAE,CAAC,CAAE,MAAM,EAAE,CAAE;AAC/B,sBAAsB,EAAE,CAAE;AAC1B,UAAU,EAAE,CAAE;AACd,SAAS,EAAE,CAAE;AACb;AACA" to

export interface Mapping<Data = unknown> {
    sourceOffsets: number[];
    generatedOffsets: number[];
    lengths: number[];
    generatedLengths?: number[];
    data: Data;
}
@johnsoncodehk
Copy link
Member

You need to use @jridgewell/sourcemap-codec to decode this string and then convert it. There is a complete demonstration code from withastro/language-tools: https://github.com/withastro/language-tools/blob/af5bbc5f6b4f0a66113d7050a85824078ffaaeac/packages/ts-plugin/src/astro2tsx.ts#L60-L124

@chapaofan-zy
Copy link
Author

thx, just don't know number[] means in

export interface Mapping<Data = unknown> {
    sourceOffsets: number[];
    generatedOffsets: number[];
    lengths: number[];
    generatedLengths?: number[];
    data: Data;
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants