Skip to content

[Bug]: commonjs source-maps sources point to .js and cjs files contain duplicated sourceMappingURL #27320

@Hotell

Description

@Hotell

Library

React Components / v9 (@fluentui/react-components)

Are you reporting Accessibility issue?

None

Reproduction

Pre swc (using TS):

Post swc:

Bug Description

Actual Behavior

After migration to swc, source maps for commonjs inputs don't point to TS original source anymore.

Also the sourceMappingURL is being printed twice within cjs output (which is present within the source map )

Expected Behavior

This regression is actually expected, but we didn't thought about it while implementing the change, as our transpilation pipeline changed

From

graph LR;
 
S["Start"]
E["End"]
B["Babel"]

    S-->TSC:esm-->B
    S-->TSC:cjs-->B
    B-->E;
Loading

To

graph LR;
 
S["Start"]
E["End"]
B["Babel"]

    S-->SWC:esm-->B-->SWC:cjs-->E
Loading

Besides the duplicated sourceMappingURL emit within cjs output, it shouldn't have any real impact for consumers, as we use sourcesContent which is a source of truth for the actual source mapping.

More feedback is needed.

Actionable for now is to reduce that duplicate emit for commonjs.

Logs

No response

Requested priority

Normal

Products/sites affected

No response

Are you willing to submit a PR to fix?

yes

Validations

  • Check that there isn't already an issue that reports the same bug to avoid creating a duplicate.
  • The provided reproduction is a minimal reproducible example of the bug.

Related issues/PRs

#27250

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