Skip to content

failed to read input source map - @swc/jest + yarn PnP workspaces #9416

@mrginglymus

Description

@mrginglymus

Describe the bug

Using yarn PnP with workspaces causes swc to emit

  ERROR  failed to read input source map: failed to parse inline source map url
src.js.map

Caused by:
    relative URL without a base

Switching to the node-modules linker, stops the errors.

I'd been seeing this for a while, and hoped that #8789 might fix it, but it appears not to

Input code

// sub-package is a workspace package with a peer dependency
import adder from 'sub-package';

it('tests', () => {
    expect(adder(1, 2)).toEqual(3)
});

Config

export default {
    cache: false,
    transform: {
        "^.+\\.m?(t|j)sx?$": "@swc/jest"
    },
    testPathIgnorePatterns: ["/node_modules/"],
}

Playground link (or link to the minimal reproduction)

https://github.com/mrginglymus/swc-repro

SWC Info output

Operating System:
    Platform: win32
    Arch: x64
    Machine Type: x86_64
    Version: Windows 10 Pro
    CPU: (24 cores)
        Models: Intel(R) Core(TM) i9-10920X CPU @ 3.50GHz

Binaries:
    Node: 22.4.0
    npm: N/A
    Yarn: N/A
    pnpm: N/A

Relevant Packages:
    @swc/core: N/A
    @swc/helpers: N/A
    @swc/types: N/A


SWC Config:
    output: N/A
    .swcrc path: N/A

Next.js info:
    output: N/A

Expected behavior

No errors :)

Version

1.7.9

Additional context

This only happens when importing code from a workspace package with peer dependencies.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions