-
Notifications
You must be signed in to change notification settings - Fork 4
sourcemap-tools: add processSource to SourceProcessor #332
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
Conversation
324f66f to
f25156f
Compare
There was a problem hiding this 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?
| if (!sourceMap) { | ||
| return { debugId, source: newSource }; | ||
| } |
There was a problem hiding this comment.
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>.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
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.
* 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>

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