Skip to content

Conversation

@konraddysput
Copy link
Collaborator

Why

This change exposes an option in the sourcemap-tools to process source maps via translation process (for example: via metro in react-native)

ref: BT-5175

@konraddysput konraddysput added the enhancement New feature or request label Jan 21, 2025
@konraddysput konraddysput requested a review from perf2711 January 21, 2025 12:52
@konraddysput konraddysput self-assigned this Jan 21, 2025
@konraddysput konraddysput force-pushed the feature/sourcemap-tools-process-source branch from 324f66f to f25156f Compare January 21, 2025 13:06
Copy link
Contributor

@perf2711 perf2711 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you try and extract some of the duplicated logic in processSource and processSourceAndSourceMap into functions?

Comment on lines 165 to 167
if (!sourceMap) {
return { debugId, source: newSource };
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wonder why it doesn't show an error here? ProcessResult expects sourceMap to be set.

Can you add a new interface called ProcessResultWithoutSourcemap (this will reduce refactoring in other packages) and annotate this function like this:

    public async processSourceAndSourceMap(
        source: string,
        sourceMap: RawSourceMap,
        debugId?: string,
        force?: boolean,
    ): Promise<ProcessResult>;
    public async processSourceAndSourceMap(
        source: string,
        sourceMap?: undefined,
        debugId?: string,
        force?: boolean,
    ): Promise<ProcessResultWithoutSourcemap>;
    public async processSourceAndSourceMap(
        source: string,
        sourceMap?: RawSourceMap,
        debugId?: string,
        force?: boolean,
    ): Promise<ProcessResult> {

Also, change the return type on processSource to return Promise<ProcessResultWithoutSourcemap>.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So it DOES return an error!
image

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

But not on build... strange.

@konraddysput konraddysput merged commit 0226393 into main Jan 23, 2025
5 checks passed
@konraddysput konraddysput deleted the feature/sourcemap-tools-process-source branch January 23, 2025 14:48
konraddysput added a commit that referenced this pull request Jan 23, 2025
* sourcemap-tools: add processSource to SourceProcessor

* sourcemap-tools: abstract processing code to the common method

* sourcemap-tools: Provide better abstraction & definition for processSourceAndAvailableSourceMap

* sourcemap-tools: private processSourceAndAvailableSourceMap

---------

Co-authored-by: Sebastian Alex <sebastian.alex@saucelabs.com>
Co-authored-by: Konrad Dysput <konrad.dysput@saucelabs.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants