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

Wrong source map generated for minifiy #9567

Closed
SyMind opened this issue Sep 19, 2024 · 1 comment · Fixed by #9578
Closed

Wrong source map generated for minifiy #9567

SyMind opened this issue Sep 19, 2024 · 1 comment · Fixed by #9578
Assignees
Labels
Milestone

Comments

@SyMind
Copy link
Contributor

SyMind commented Sep 19, 2024

Describe the bug

\n in template strings will be converted to a newline, but the source map is incorrect.

The generated source map is also broken with Sentry. For more details, please refer to this issue: web-infra-dev/rspack#7914.

I have created a repository to reproduce the bug.

image

Input code

function foo(span, error) {
    span.setStatus({
        message: `${error.message} ${error.code ? `\nMongoose Error Code: ${error.code}` : ''}`,
    });
}
foo();

Config

import * as path from 'path';
import * as fs from "fs";
import swc from "@swc/core";
 
const src = fs.readFileSync(path.join(import.meta.dirname, 'index.js'), 'utf-8');
const { code, map } = await swc.minify(src,
  {
    module: true,
    compress: true,
    mangle: true,
    sourceMap: true,
  }
);

Playground link (or link to the minimal reproduction)

https://play.swc.rs/?version=1.7.26&code=H4sIAAAAAAAAA0srzUsuyczPU0jLz9coLkjM01FILSrKL9JUqOZSAAKQkF5xaklwSWJJabEGRBAEclOLixPTU60UElSqwTr0oCK1CjCB5PyUVAV7hYSYPN%2F8vPT8%2FOJUBVeQhIIzUMIKRVltgoKVgrp6bYIO2IJaTWuuWi6Qk4AMAIxLORKjAAAA&config=H4sIAAAAAAAAA32VTY7bMAyF9zlF4PUspgXaRQ9QdNMzCIpFOZqRRUOkkhiD3L30XzqTUNnF%2FPhE6YliPnb7ffNGbfNr%2FyE%2F5WOwmSDfviVCY2J7kUjD4wDU5jBw87JRpglxLjBHri%2B7ZR22uQOeVEDfX7%2F9WBUNXBhysvEPxAEyrdoVRkQCCXkbaYv1IQU%2Fft5Qi%2F2QgehTTKJSr%2FSQmL7qV5bx%2FLXWHD8gRrDpCTGWTEgM3bLX%2B4VbjNEOBOZks7LKtFObA6FWYoKFwZkh46Dy5AIHFLMU6sA606IDBYUMLYcTaDKpJbJEcrwKdXAoXTf3wB2Gk43FsiKEy3wjstlHdsRAbHzRPFhYxYAF6s4GbzJwyUq9NwyponoHkNNHS5Rsr9kzJ3hppSrbhPedMNOQvHQrj49i6WztiAk68dOE4BVTJ1sgc9A2msGVFiZX2zrVTaDgwID30iMaPQduj1rJ6fWjV4DcrPWgeLIAc3t9FT49hCf4t5yRl86qZPSWj3VKY3%2FA%2BKRAD3xE9yRBLoKxjrNMh8tQ5yU5kL4Ap6YUmsHj45feZzRxHqIPnSEvQ1Y0XcSDOh5CisIl%2FrrGrreJ3dvUxdt1LVN7tyY0Pboyw%2FXvYLr0ZYj%2FbP4nbSN5K9oE%2BrsJ5UjvCc%2Bp2V3%2FAVGwuJNeBgAA

SWC Info output

No response

Expected behavior

Source Map should be right.

Actual behavior

No response

Version

1.7.26

Additional context

No response

@swc-bot
Copy link
Collaborator

swc-bot commented Oct 24, 2024

This closed issue has been automatically locked because it had no new activity for a month. If you are running into a similar issue, please create a new issue with the steps to reproduce. Thank you.

@swc-project swc-project locked as resolved and limited conversation to collaborators Oct 24, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Development

Successfully merging a pull request may close this issue.

3 participants