Skip to content

Default source maps generated for DEV builds seem invalid? #11204

Closed

Description

@bvaughn

Source maps generated for a create-react-app project in DEV mode seem slightly broken. Specifically, translating from a position in the (compiled) source to the original source returns a valid line number but it always returns an invalid column number of 0. (Production source maps are fine.)

Source map translation is being done with the source-map package.

This breaks an upcoming React DevTools feature ("named hooks") so I've filed an issue in the React repo with more details:
react/react#21868


create-react-app version: 4.0.3

Repro project: https://github.com/bvaughn/test-named-hooks


(Potentially related to older issues #6296 or #4683.)

Activity

  1. bvaughn commented on Jul 13, 2021

    @bvaughn
    ContributorAuthor

    One interesting thing to note is that error overlays correctly report both line and column number:

    Screen Shot 2021-07-13 at 5 08 45 PM

    But programmatically parsing the error stack, loading source maps, and translating the position (like DevTools is doing) seems to fail: react/react#21868 (comment)

    I'm not sure what the difference is (yet) 😄

  2. bvaughn commented on Jul 13, 2021

    @bvaughn
    ContributorAuthor

    I think this might be due to DEV bundles using "cheap-module-source-map" module:
    https://github.com/facebook/create-react-app/blob/bb64e31a81eb12d688c14713dce812143688750a/packages/react-scripts/config/webpack.config.js#L177-L181

    According to the webpack documentation:

    cheap-module-source-map - A SourceMap without column-mappings that simplifies loader Source Maps to a single mapping per line.

    I guess this is what makes them fast, but I'm not sure why the error overlays have the right column numbers.

  3. bvaughn commented on Jul 13, 2021

    @bvaughn
    ContributorAuthor

    After looking into this a little more, I think this source-map type probably remains the correct choice for create-react-app. I will attempt to work around this on the DevTools side.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions