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

Terser JavaScript output #256

Closed
woutervanerp opened this issue Jan 4, 2024 · 0 comments
Closed

Terser JavaScript output #256

woutervanerp opened this issue Jan 4, 2024 · 0 comments
Assignees

Comments

@woutervanerp
Copy link

woutervanerp commented Jan 4, 2024

I'm testing with Terser and i don't seem to get the same result.

My astro.config.mjs

import { defineConfig } from "astro/config";
import compress from "astro-compress";

export default defineConfig({
    integrations: [compress({
        JavaScript: {
            terser: {
                compress: true,
                mangle: true,
                module: true,
            }
        }
    })]
});

When i set up a clean test project (without astro) with Terser and run

terser index.js -o dist/index.min.js --compress --mangle --module

It makes from this:

// index.js
function sayHello() {
    console.log("Hello, world!");
}

function greet(name) {
    console.log("Greetings, " + name + "!");
}

const myNumber = 42;

sayHello();
greet("Alice");
console.log("My number is: " + myNumber);

this (desired outcome):

var o;console.log("Hello, world!"),o="Alice",console.log("Greetings, "+o+"!"),console.log("My number is: 42");

But with my astro config the output is (not expected outcome):

function e(){console.log("Hello, world!")}function l(o){console.log("Greetings, "+o+"!")}const n=42;e(),l("Alice"),console.log("My number is: 42")
@NikolaRHristov NikolaRHristov self-assigned this Jan 6, 2024
@NikolaRHristov NikolaRHristov closed this as not planned Won't fix, can't repro, duplicate, stale May 25, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

2 participants