Skip to content
This repository has been archived by the owner on Nov 30, 2023. It is now read-only.

Terser generates incorrect sourcemaps. #72

Open
ivan-shaban opened this issue Mar 30, 2020 · 3 comments
Open

Terser generates incorrect sourcemaps. #72

ivan-shaban opened this issue Mar 30, 2020 · 3 comments

Comments

@ivan-shaban
Copy link

Hello, i've got simple config:

import pkg from "./package.json";
import typescript from "@wessberg/rollup-plugin-ts";
import { terser } from "rollup-plugin-terser";

const external = [
    ...Object.keys(pkg.dependencies || {}),
    ...Object.keys(pkg.devDependencies || {}),
];

export default {
    input: "src/index.ts",
    output: [{
        file: pkg.main,
        sourcemap: true,
        format: "cjs",
    }],
    external,
    plugins: [
        typescript({
            transpiler: "babel",
        }),
        terser(),
    ],
};

Which produces incorrect sourcemaps (everything points for first line of source code) when i use terser plugin, if i disable it, sourcemaps works correct. Do you have any ideas why that happens?

Package.json dependencies:

    "@babel/plugin-proposal-class-properties": "^7.8.3",
    "@babel/plugin-proposal-decorators": "7.8.3",
    "@babel/plugin-proposal-export-default-from": "7.8.3",
    "@babel/plugin-proposal-object-rest-spread": "7.9.0",
    "@babel/plugin-transform-async-to-generator": "^7.8.3",
    "@babel/plugin-transform-regenerator": "^7.8.7",
    "@babel/preset-env": "^7.8.4",
    "@babel/preset-typescript": "^7.8.3",
    "@wessberg/rollup-plugin-ts": "1.2.21",
    "jsdoc": "3.6.3",
    "npm-run-all": "^4.1.5",
    "rimraf": "^2.7.1",
    "rollup": "^2.0.3",
    "rollup-plugin-size-snapshot": "0.11.0",
    "rollup-plugin-terser": "^5.2.0",
    "rollup-plugin-visualizer": "4.0.1",
    "tslib": "^1.10.0",
    "typescript": "^3.7.5"

babel.config.js:

module.exports = {
    presets: [
        "@babel/preset-env",
        "@babel/preset-typescript"
    ],
    plugins: [
        "@babel/plugin-transform-async-to-generator",
        "@babel/plugin-transform-regenerator",
        ['@babel/plugin-proposal-decorators', { 'legacy': true }],
        ['@babel/plugin-proposal-class-properties', { 'loose': true }],
        ['@babel/plugin-proposal-export-default-from'],
        ['@babel/plugin-proposal-object-rest-spread', { 'loose': true, 'useBuiltIns': true }],
    ],
};
@TrySound
Copy link
Owner

Does it work without ts plugin?

@ivan-shaban
Copy link
Author

ivan-shaban commented May 23, 2020

No, it doesn't, i've tried without ts and got the same result(

@TrySound
Copy link
Owner

Could you please provide a repro?
https://repl.it/@rollup/rollup-plugin-repro

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants