plugins icon indicating copy to clipboard operation
plugins copied to clipboard

[@rollup/plugin-terser] Broken sourcemap in v0.2.0

Open ChoSeoHwan opened this issue 3 years ago β€’ 13 comments

  • Rollup Plugin Name: @rollup/plugin-terser
  • Rollup Plugin Version: 0.2.0
  • Rollup Version: 3.6.0
  • Operating System (or Browser): window 10
  • Node Version: 16.18.0
  • Link to reproduction (⚠️ read below):

Expected Behavior

Generate sourcemap normally

Actual Behavior

Broken source map with Wraning.

  • In v0.1.0
{"version":3,"file":"index.js","sources":["../src/errors/RollupBuilderError.ts","../src/errors/OutputError   ....   ACL,IAG0B,IAAzBH,EAAcN,OAAeM,EAAc,GAAKA,CAAa"}
  • In v0.2.0
{"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":""}

Additional Information

  • Rollup Warning message
(!) Broken sourcemap
https://rollupjs.org/guide/en/#warning-sourcemap-is-likely-to-be-incorrect             
Plugins that transform code (such as "terser") should generate accompanying sourcemaps.
created dist in 3.2s    
  • rollup.config
const { DEFAULT_EXTENSIONS } = require('@babel/core');
const resolve = require('@rollup/plugin-node-resolve');
const commonjs = require('@rollup/plugin-commonjs');
const babel = require('@rollup/plugin-babel');
const terser = require('@rollup/plugin-terser');
const cleaner = require('rollup-plugin-cleaner');
const peerDepsExternal = require('rollup-plugin-peer-deps-external');
const typescript = require('rollup-plugin-typescript2');
const ttypescript = require('ttypescript');

const typescriptOptions = {
    typescript: ttypescript,
    tsconfig: 'tsconfig.json'
};

const babelOptions = {
    extensions: [...DEFAULT_EXTENSIONS, '.ts'],
    babelHelpers: 'runtime'
};

const resolveOptions = {
    browser: true
};

module.exports = {
    input: 'src/index.ts',
    context: 'window',
    output: {
        dir: 'dist',
        format: 'cjs',
        sourcemap: true,
        exports: 'named',
        name: 'buildRollupOptions'
    },
    plugins: [
        cleaner({ targets: ['dist'] }),
        peerDepsExternal(),
        resolve(resolveOptions),
        typescript({
            ...typescriptOptions,
            tsconfigDefaults: {
                compilerOptions: {
                    outDir: 'dist',
                    plugins: [
                        { "transform": "typescript-transform-paths", "afterDeclarations": true }
                    ]
                }
            }
        }),
        commonjs(),
        babel(babelOptions),
        terser()
    ]
};

ChoSeoHwan avatar Dec 08 '22 01:12 ChoSeoHwan

@ChoSeoHwan can you confirm that this is still an issue in v0.2.1 ?

tada5hi avatar Dec 21 '22 17:12 tada5hi

It's still an issue for me in v0.2.1.

brettz9 avatar Dec 21 '22 18:12 brettz9

I am also experiencing this issue on 0.2.1:

> rollup -c


src/index.ts β†’ dist/index.min.js...
(!) Broken sourcemap
https://rollupjs.org/guide/en/#warning-sourcemap-is-likely-to-be-incorrect
Plugins that transform code (such as "terser") should generate accompanying sourcemaps.
created dist/index.min.js in 493ms

maxlapides avatar Dec 21 '22 19:12 maxlapides

@brettz9 @maxlapides just to be sure, this "feature" has never worked before, has it?

tada5hi avatar Dec 21 '22 20:12 tada5hi

@tada5hi Well we definitely had sourcemaps before, but I'll be honest: I have never tested to see if they're actually working properly. Screenshot 2022-12-21 at 12 10 25 PM

maxlapides avatar Dec 21 '22 20:12 maxlapides

@maxlapides ok. I created a draft pull request to implement this feature in the meantime. Need to write some tests and than I think we are good to go ✌️😊

tada5hi avatar Dec 22 '22 11:12 tada5hi

+1 I need sourcemaps for terser

ivands avatar Dec 26 '22 09:12 ivands

@ivands I think it won't take that long anymore. Tests are added. I'm just waiting for @shellscape to give me feedback resp. accept the changes. Than the feature will be released.

tada5hi avatar Dec 26 '22 17:12 tada5hi

wait for good news

"@rollup/plugin-terser": "^0.2.1",

(!) Broken sourcemap https://rollupjs.org/guide/en/#warning-sourcemap-is-likely-to-be-incorrect Plugins that transform code (such as "terser") should generate accompanying sourcemaps. created dist/index.js in 904ms

YamadaAoi avatar Jan 05 '23 08:01 YamadaAoi

v0.3.0 is released. Can you confirm that the source map generation is working now ?

tada5hi avatar Jan 06 '23 16:01 tada5hi

@tada5hi Thanks so much! Looks like 0.3.0 is perfect. The source map generation on 0.3.0 matches 0.1.0 :)

maxlapides avatar Jan 06 '23 21:01 maxlapides

@maxlapides I'm happy if it works now. I'm always happy to help ✌️☺️

tada5hi avatar Jan 06 '23 21:01 tada5hi

@shellscape can you close the issue ? @ChoSeoHwan please reopen the issue if the source map generation is still not working for you :v:

tada5hi avatar Jan 13 '23 20:01 tada5hi