Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
4162d22
feat(es/minifier): Implement parameter inlining optimization
github-actions[bot] Oct 19, 2025
a9ec0fa
fix(es/minifier): Implement call site argument removal and fix undefi…
github-actions[bot] Oct 19, 2025
3c0750f
fix(es/minifier): Add conservative check to prevent parameter inlinin…
github-actions[bot] Oct 19, 2025
e183e03
fix(es/minifier): Fix clippy issues in parameter inlining
github-actions[bot] Oct 20, 2025
6a30439
perf: optimize record_call_site_args to avoid unnecessary cloning
github-actions[bot] Oct 23, 2025
3710e41
docs(es/minifier): Add documentation for INLINE_PREVENTED flag
github-actions[bot] Oct 23, 2025
85525b3
refactor(minifier): Address PR review feedback for parameter inlining
github-actions[bot] Oct 23, 2025
36a8f1f
chore: Run cargo fmt to fix formatting issues
github-actions[bot] Oct 23, 2025
af89fbe
Address PR review feedback for parameter inlining optimization
github-actions[bot] Oct 24, 2025
b622923
Add import statement consistency rule to CLAUDE.md
github-actions[bot] Oct 24, 2025
def6fdf
fix(es/minifier): Restrict parameter inlining to safe identifiers only
github-actions[bot] Oct 24, 2025
52527bd
fix(es/minifier): Fix parameter inlining merge conflict and identifie…
github-actions[bot] Oct 24, 2025
a29bf4b
fix(es/minifier): Make parameter inlining more conservative
github-actions[bot] Oct 24, 2025
4945e52
refactor(minifier): Implement PR review feedback for parameter inlining
github-actions[bot] Oct 24, 2025
205bdd0
fix(es/minifier): Restrict parameter inlining to undefined values only
github-actions[bot] Oct 27, 2025
b1b0ad7
fix(es/minifier): Remove duplicate accessed_props field from rebase
github-actions[bot] Oct 27, 2025
97101ec
fix(es/minifier): Update test snapshots for parameter inlining optimi…
github-actions[bot] Oct 27, 2025
4a6451a
fix(es/minifier): Enable parameter inlining for all safe constant values
github-actions[bot] Oct 27, 2025
09974fc
fix(es/minifier): Update quagga2 test snapshot for parameter inlining
github-actions[bot] Oct 27, 2025
20aaed2
fix(es/minifier): Fix parameter inlining issues
github-actions[bot] Oct 27, 2025
07c844a
fix(es/minifier): Fix parameter inlining safety checks
github-actions[bot] Oct 27, 2025
70181ed
fix(es/minifier): Prevent parameter inlining when var declarations sh…
github-actions[bot] Oct 27, 2025
52d5ef1
fix(es/minifier): Fix clippy warning in parameter inlining
github-actions[bot] Oct 27, 2025
3bbbede
fix(test): Update test snapshots for parameter inlining optimization
github-actions[bot] Oct 27, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CLAUDE.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,4 @@
6. When instructed to fix tests, do not remove or modify existing tests.
7. Write documentation for your code.
8. Run `cargo fmt --all` before commiting files.
9. Place all import statements at the top of the file for consistency. Do not use inline `use` statements within functions or impl blocks.
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
(void 0).setStatus({message:`${(void 0).message} ${(void 0).code?`
let e;(void 0).setStatus({message:`${e.message} ${e.code?`
Mon go
os
e Error
C
od
e: ${(void 0).code}`:"1\n23"}`});
e: ${e.code}`:"1\n23"}`});
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
{
"mappings": "AAAaA,CAAAA,KAAAA,CAAG,EACTC,SAAS,CAAC,CACXC,QAAS,CAAC,EAAEC,AAFCA,CAAAA,KAAAA,CAAI,EAECD,OAAO,CAAC,CAAC,EACvBC,AAHSA,CAAAA,KAAAA,CAAI,EAGPC,IAAI,CACJ;AAAG;AAAS;AAC5B;AAAS;AACT;AAAI,GAAG,EAAED,AANUA,CAAAA,KAAAA,CAAI,EAMRC,IAAI,CAAC,CAAC,CACL,QACT,CAAC,AACN",
"mappings": "IAAmBA,EACjBC,SAAKC,SAAS,CAAC,CACXC,QAAS,CAAC,EAAEH,EAAMG,OAAO,CAAC,CAAC,EACvBH,EAAMI,IAAI,CACJ;AAAG;AAAS;AAC5B;AAAS;AACT;AAAI,GAAG,EAAEJ,EAAMI,IAAI,CAAC,CAAC,CACL,QACT,CAAC,AACN",
"names": [
"error",
"span",
"setStatus",
"message",
"error",
"code"
],
"sources": [
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
//// [typeFromPropertyAssignment36.ts]
function d() {}
(function(b) {
(function() {
function d() {}
return d.e = 12, d.e, b && (d.q = !1), d.q, b ? d.q = !1 : d.q = !0, d.q, b ? d.r = 1 : d.r = 2, d.r, b && (d.s = 'hi'), d;
return d.e = 12, d.e, d.q = !1, d.q, d.q = !1, d.q, d.r = 1, d.r, d.s = 'hi', d;
})(!0).s, d.e = 12, d.e, d.q, d.q = !0, d.q, d.r = 2, d.r;
var g = function() {};
g.expando, g.both = 0, g.both;
95 changes: 48 additions & 47 deletions crates/swc/tests/vercel/full/firebase/dist/1/output/index.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
var e, t = require("@firebase/util"), n = require("tslib"), r = require("@firebase/component"), i = require("@firebase/app"), a = require("@firebase/logger"), o = function(e) {
let e;
var t, n = require("@firebase/util"), r = require("tslib"), i = require("@firebase/component"), a = require("@firebase/app"), o = require("@firebase/logger"), p = function(e) {
if (e && e.__esModule) return e;
var t = Object.create(null);
return e && Object.keys(e).forEach(function(n) {
Expand All @@ -12,10 +13,10 @@ var e, t = require("@firebase/util"), n = require("tslib"), r = require("@fireba
});
}
}), t.default = e, Object.freeze(t);
}(i), p = function() {
}(a), s = function() {
function e(e, t) {
var n = this;
this._delegate = e, this.firebase = t, i._addComponent(e, new r.Component("app-compat", function() {
this._delegate = e, this.firebase = t, a._addComponent(e, new i.Component("app-compat", function() {
return n;
}, "PUBLIC")), this.container = e.container;
}
Expand Down Expand Up @@ -45,97 +46,97 @@ var e, t = require("@firebase/util"), n = require("tslib"), r = require("@fireba
return new Promise(function(t) {
e._delegate.checkDestroyed(), t();
}).then(function() {
return e.firebase.INTERNAL.removeApp(e.name), i.deleteApp(e._delegate);
return e.firebase.INTERNAL.removeApp(e.name), a.deleteApp(e._delegate);
});
}, e.prototype._getService = function(e, t) {
void 0 === t && (t = i._DEFAULT_ENTRY_NAME), this._delegate.checkDestroyed();
void 0 === t && (t = a._DEFAULT_ENTRY_NAME), this._delegate.checkDestroyed();
var n, r = this._delegate.container.getProvider(e);
return r.isInitialized() || (null == (n = r.getComponent()) ? void 0 : n.instantiationMode) !== "EXPLICIT" || r.initialize(), r.getImmediate({
identifier: t
});
}, e.prototype._removeServiceInstance = function(e, t) {
void 0 === t && (t = i._DEFAULT_ENTRY_NAME), this._delegate.container.getProvider(e).clearInstance(t);
void 0 === t && (t = a._DEFAULT_ENTRY_NAME), this._delegate.container.getProvider(e).clearInstance(t);
}, e.prototype._addComponent = function(e) {
i._addComponent(this._delegate, e);
a._addComponent(this._delegate, e);
}, e.prototype._addOrOverwriteComponent = function(e) {
i._addOrOverwriteComponent(this._delegate, e);
a._addOrOverwriteComponent(this._delegate, e);
}, e.prototype.toJSON = function() {
return {
name: this.name,
automaticDataCollectionEnabled: this.automaticDataCollectionEnabled,
options: this.options
};
}, e;
}(), s = ((e = {})["no-app"] = "No Firebase App '{$appName}' has been created - call Firebase App.initializeApp()", e["invalid-app-argument"] = "firebase.{$appName}() takes either no argument or a Firebase App instance.", e), c = new t.ErrorFactory("app-compat", "Firebase", s), u = function e() {
var r = function(e) {
var n = {}, r = {
}(), c = ((t = {})["no-app"] = "No Firebase App '{$appName}' has been created - call Firebase App.initializeApp()", t["invalid-app-argument"] = "firebase.{$appName}() takes either no argument or a Firebase App instance.", t), u = new n.ErrorFactory("app-compat", "Firebase", c), l = function e() {
var t = function(e) {
var t = {}, r = {
__esModule: !0,
initializeApp: function(i, a) {
void 0 === a && (a = {});
var p = o.initializeApp(i, a);
if (t.contains(n, p.name)) return n[p.name];
var s = new e(p, r);
return n[p.name] = s, s;
var o = p.initializeApp(i, a);
if (n.contains(t, o.name)) return t[o.name];
var s = new e(o, r);
return t[o.name] = s, s;
},
app: i,
registerVersion: o.registerVersion,
setLogLevel: o.setLogLevel,
onLog: o.onLog,
registerVersion: p.registerVersion,
setLogLevel: p.setLogLevel,
onLog: p.onLog,
apps: null,
SDK_VERSION: o.SDK_VERSION,
SDK_VERSION: p.SDK_VERSION,
INTERNAL: {
registerComponent: function(n) {
var a = n.name, p = a.replace("-compat", "");
if (o._registerComponent(n) && "PUBLIC" === n.type) {
registerComponent: function(t) {
var a = t.name, o = a.replace("-compat", "");
if (p._registerComponent(t) && "PUBLIC" === t.type) {
var s = function(e) {
if (void 0 === e && (e = i()), "function" != typeof e[p]) throw c.create("invalid-app-argument", {
if (void 0 === e && (e = i()), "function" != typeof e[o]) throw u.create("invalid-app-argument", {
appName: a
});
return e[p]();
return e[o]();
};
void 0 !== n.serviceProps && t.deepExtend(s, n.serviceProps), r[p] = s, e.prototype[p] = function() {
for(var e = [], t = 0; t < arguments.length; t++)e[t] = arguments[t];
return this._getService.bind(this, a).apply(this, n.multipleInstances ? e : []);
void 0 !== t.serviceProps && n.deepExtend(s, t.serviceProps), r[o] = s, e.prototype[o] = function() {
for(var e = [], n = 0; n < arguments.length; n++)e[n] = arguments[n];
return this._getService.bind(this, a).apply(this, t.multipleInstances ? e : []);
};
}
return "PUBLIC" === n.type ? r[p] : null;
return "PUBLIC" === t.type ? r[o] : null;
},
removeApp: function(e) {
delete n[e];
delete t[e];
},
useAsService: function(e, t) {
return "serverAuth" === t ? null : t;
},
modularAPIs: o
modularAPIs: p
}
};
function i(e) {
if (e = e || o._DEFAULT_ENTRY_NAME, !t.contains(n, e)) throw c.create("no-app", {
if (e = e || p._DEFAULT_ENTRY_NAME, !n.contains(t, e)) throw u.create("no-app", {
appName: e
});
return n[e];
return t[e];
}
return r.default = r, Object.defineProperty(r, "apps", {
get: function() {
return Object.keys(n).map(function(e) {
return n[e];
return Object.keys(t).map(function(e) {
return t[e];
});
}
}), i.App = e, r;
}(p);
return r.INTERNAL = n.__assign(n.__assign({}, r.INTERNAL), {
}(s);
return t.INTERNAL = r.__assign(r.__assign({}, t.INTERNAL), {
createFirebaseNamespace: e,
extendNamespace: function(e) {
t.deepExtend(r, e);
n.deepExtend(t, e);
},
createSubscribe: t.createSubscribe,
ErrorFactory: t.ErrorFactory,
deepExtend: t.deepExtend
}), r;
}(), l = new a.Logger("@firebase/app-compat");
if (t.isBrowser() && void 0 !== self.firebase) {
l.warn("\n Warning: Firebase is already defined in the global scope. Please make sure\n Firebase library is only loaded once.\n ");
var d = self.firebase.SDK_VERSION;
d && d.indexOf("LITE") >= 0 && l.warn("\n Warning: You are trying to load Firebase while using Firebase Performance standalone script.\n You should load Firebase Performance with this instance of Firebase to avoid loading duplicate code.\n ");
createSubscribe: n.createSubscribe,
ErrorFactory: n.ErrorFactory,
deepExtend: n.deepExtend
}), t;
}(), d = new o.Logger("@firebase/app-compat");
if (n.isBrowser() && void 0 !== self.firebase) {
d.warn("\n Warning: Firebase is already defined in the global scope. Please make sure\n Firebase library is only loaded once.\n ");
var f = self.firebase.SDK_VERSION;
f && f.indexOf("LITE") >= 0 && d.warn("\n Warning: You are trying to load Firebase while using Firebase Performance standalone script.\n You should load Firebase Performance with this instance of Firebase to avoid loading duplicate code.\n ");
}
i.registerVersion("@firebase/app-compat", "0.1.5", void 0), module.exports = u;
a.registerVersion("@firebase/app-compat", "0.1.5", e), module.exports = l;
16 changes: 16 additions & 0 deletions crates/swc_ecma_minifier/src/compress/optimize/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ mod iife;
mod inline;
mod loops;
mod ops;
mod params;
mod props;
mod rest_params;
mod sequences;
Expand Down Expand Up @@ -91,6 +92,7 @@ pub(super) fn optimizer<'a>(
ctx,
mode,
functions: Default::default(),
inlined_params: Default::default(),
}
}

Expand Down Expand Up @@ -240,6 +242,11 @@ struct Optimizer<'a> {
mode: &'a dyn Mode,

functions: Box<FxHashMap<Id, FnMetadata>>,

/// Tracks which parameter indices have been inlined for each function.
/// Maps function ID to a sorted vector of parameter indices that were
/// removed.
inlined_params: Box<FxHashMap<Id, Vec<usize>>>,
}

#[derive(Default)]
Expand Down Expand Up @@ -1683,6 +1690,9 @@ impl VisitMut for Optimizer<'_> {

self.ignore_unused_args_of_iife(e);
self.inline_args_of_iife(e);

// Remove arguments for parameters that have been inlined
self.remove_inlined_call_args(e);
}

#[cfg_attr(feature = "debug", tracing::instrument(level = "debug", skip_all))]
Expand Down Expand Up @@ -2094,6 +2104,9 @@ impl VisitMut for Optimizer<'_> {

self.drop_unused_params(&mut f.function.params);

// Inline parameters that are consistently passed the same constant value
self.inline_function_parameters(&mut f.function, &f.ident.to_id());

let ctx = self
.ctx
.clone()
Expand All @@ -2110,6 +2123,9 @@ impl VisitMut for Optimizer<'_> {
self.functions
.entry(ident.to_id())
.or_insert_with(|| FnMetadata::from(&*e.function));

// Inline parameters for named function expressions
self.inline_function_parameters(&mut e.function, &ident.to_id());
}

if !self.options.keep_fnames {
Expand Down
Loading
Loading