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

codegen: less whitespace and unneeded punctuation #1986

Closed
mischnic opened this issue Jul 31, 2021 · 1 comment · Fixed by #1990
Closed

codegen: less whitespace and unneeded punctuation #1986

mischnic opened this issue Jul 31, 2021 · 1 comment · Fixed by #1990
Assignees
Labels
Milestone

Comments

@mischnic
Copy link
Contributor

mischnic commented Jul 31, 2021

Describe the feature

swc could omit more whitespace (between keyword and string) and also the parenthesis to a constructor call without any arguments.

Input code

function useSelection(selectionType, derivedHalfSelectedKeys) {
	return selectionType === "radio"
		? new Set()
		: new Set(1);
}

Config

	swc.minifySync(code, {
		sourceMap: false,
		mangle: true,
		compress: true,
	});

Terser output

function useSelection(e,n){return"radio"===e?new Set:new Set(1)}

swc output

function useSelection(a,b){return "radio"===a?new Set():new Set(1);}

Version
The version of @swc/core: be23e66

@mischnic mischnic added the C-bug label Jul 31, 2021
@kdy1 kdy1 added this to the v1.2.71 milestone Jul 31, 2021
@mischnic mischnic changed the title minifier: less whitespace and unneeded punctuation codegen: less whitespace and unneeded punctuation Jul 31, 2021
@kdy1 kdy1 modified the milestones: v1.2.71, v1.2.72 Aug 2, 2021
@kdy1 kdy1 self-assigned this Aug 3, 2021
@kdy1 kdy1 closed this as completed in #1990 Aug 3, 2021
kdy1 added a commit that referenced this issue Aug 3, 2021
swc_common:
 - Add `Span.has_mark`.

swc_ecma_codegen:
 - Emit `1e3` for `1000`.
 - Optimize output. (#1986)

swc_ecma_minifier:
 - name mangler: Don't use keywords as an id.
 - `properties`: Optimize member expression with string properties.
 - `inline`: Inline some function expressions even if it's not fn-local.
 - `analyzer`: Track reassignment correctly.
 - `analyzer`: Track fn-local correctly.
 - `sequences`: Inject `void` if required.
 - `inline`: Inline function declarations correctly.
 - `sequences`: Merge expressions into test of if statements.
 - `sequences`: Reduce calls to an assigned variable.
 - Use `Marks` instead of `&dyn Comments`.


swc_ecma_transforms_optimization:
 - `expr_simplifier`: Fix infinite loops.

node/swc:
 - Ensure that `.transform` performs minification. (#1989)
@swc-bot
Copy link
Collaborator

swc-bot commented Oct 23, 2022

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 23, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
3 participants