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

fix: provide original code in source maps when using RAM bundles #761

Merged
merged 1 commit into from
Apr 13, 2021

Conversation

joeblynch
Copy link
Contributor

@joeblynch joeblynch commented Mar 20, 2021

Summary

When building RAM bundles, there are a couple issues which occur with the source map:

  1. The source map contains the transformed source code output of Babel, instead of the original source code.
  2. The original file paths in the source map are prefixed with node_modules/@haul-bundler/core/build/webpack/loaders/babelWorkerLoader/index.js??ref--5-0!.

Setting the webpack config to use devtool: 'source-map', when building RAM bundles, appears to resolve these issues.

Test plan

  1. Build a RAM bundle of an RN app with Haul and produce a source map of the bundle. For reference I've included
    source maps.zip, which includes source maps from the default react-native init Android app, both with and without this fix.
  2. Examine the content of the source map. To help with this, I threw together dump-source-map, which can be used to reconstruct the original source code, as contained in a source map file.

For example, without the fix, the source map will contain:
/Users/jlynch/tmp/TestRNApp60/node_modules/@haul-bundler/core/build/webpack/loaders/babelWorkerLoader/index.js??ref--5-0!/Users/jlynch/tmp/TestRNApp60/App.js

...
const App = () => {
  return /*#__PURE__*/React.createElement(Fragment, {
    __source: {
      fileName: _jsxFileName,
      lineNumber: 29,
      columnNumber: 5
    }
  }, /*#__PURE__*/React.createElement(StatusBar, {
    barStyle: "dark-content",
    __source: {
      fileName: _jsxFileName,
      lineNumber: 30,
      columnNumber: 7
    }
  }), /*#__PURE__*/React.createElement(SafeAreaView, {
...

With the fix, the source map will contain:
/Users/jlynch/tmp/TestRNApp60/App.js

...
const App = () => {
  return (
    <Fragment>
      <StatusBar barStyle="dark-content" />
...

@zamotany zamotany merged commit cafa6ea into callstack:master Apr 13, 2021
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

Successfully merging this pull request may close these issues.

2 participants