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

bug: comments are not entirely emitted when comments: 'all' is specified #1440

Open
michaele-blend opened this issue Sep 6, 2023 · 0 comments

Comments

@michaele-blend
Copy link

Bug report

Version 5.19.4

Complete CLI command or minify() options used

/** @returns {terser.MinifyOptions} */
const getTerserOpts = () => ({
  ecma: 2020,
  toplevel: true,

  parse: {},
  mangle: true,
  compress: {
    keep_fargs: false,

    pure_getters: true,
    drop_console: false,
    pure_funcs: [],

    unsafe: true,
    unsafe_arrows: true,
    unsafe_comps: true,
    unsafe_Function: true,
    unsafe_math: true,
    unsafe_symbols: true,
    unsafe_methods: true,
    unsafe_proto: true,

    passes: 10,
  },
  format: {
    comments: 'all',
    wrap_func_args: false,
    wrap_iife: false,
  },
});

const file1 = `
// f1-before

const func = () => 'surprise!';

// f1-after
`
const file2 = `
// f2-before

console.log(func());

// f2-after
`



const terser = require('terser');
terser.minify({ 'file-1.js': file1, 'file-2.js': file2 }, getTerserOpts()).then(console.dir)

terser input

see above

terser output or error

Expected result

when comments: 'all' is specified, I expect to receive all comments: [f1-before, f1-after, f2-before, f2-after].

{
  code: '// f1-before\n// f1-after\n// f2-before\nconsole.log("surprise!");\n// f2-after'
}

(for my use case, I am not too particular about the ordering. but I do care that they are all present)

Actual result
even when comments: 'all' is specified, the f1-after comment is missing

{
  code: '// f1-before\n// f2-before\nconsole.log("surprise!");\n// f2-after'
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant