Repository: rollup/rollup (2025-07-29T13:29:57Z)

Issue:
4.46 breaks `styled-components` with new `in` optimization
### Rollup Version

4.46.1

### Operating System (or Browser)

all

### Node Version (if applicable)

_No response_

### Link To Reproduction

https://rollupjs.org/repl/?version=4.46.1&shareable=JTdCJTIyZXhhbXBsZSUyMiUzQW51bGwlMkMlMjJtb2R1bGVzJTIyJTNBJTVCJTdCJTIyY29kZSUyMiUzQSUyMiUyRiUyRiUyMGltcG9ydCUyMHVuaXRsZXNzJTIwZnJvbSUyMCclNDBlbW90aW9uJTJGdW5pdGxlc3MnJTNCJTVDbmltcG9ydCUyMHVuaXRsZXNzJTIwZnJvbSUyMCcuJTJGdW5pdGxlc3MnJTVDbiU1Q24lMkYlMkYlMjBPcmlnaW5hbCUyMGZ1bmN0aW9uJTIwaW4lMjAlNjBzdHlsZWQtY29tcG9uZW50cyU2MCUyQyUyMHN0cmlwcGVkJTIwZm9yJTIwVHlwZVNjcmlwdCUzQSUyMGh0dHBzJTNBJTJGJTJGZ2l0aHViLmNvbSUyRnN0eWxlZC1jb21wb25lbnRzJTJGc3R5bGVkLWNvbXBvbmVudHMlMkZibG9iJTJGZDBiNzNhY2Q5MzFkYWVmOWVlYmI5N2UzNGZlNDU1MmZmYzU3ZDYzZSUyRnBhY2thZ2VzJTJGc3R5bGVkLWNvbXBvbmVudHMlMkZzcmMlMkZ1dGlscyUyRmFkZFVuaXRJZk5lZWRlZC50cyUyM0wxMCU1Q25leHBvcnQlMjBkZWZhdWx0JTIwZnVuY3Rpb24lMjBhZGRVbml0SWZOZWVkZWQobmFtZSUyQyUyMHZhbHVlKSUyMCU3QiU1Q24lMjAlMjAlMkYlMkYlMjBodHRwcyUzQSUyRiUyRmdpdGh1Yi5jb20lMkZhbWlsYWphY2slMkZlc2xpbnQtcGx1Z2luLWZsb3d0eXBlLWVycm9ycyUyRmlzc3VlcyUyRjEzMyU1Q24lMjAlMjBpZiUyMCh2YWx1ZSUyMCUzRCUzRCUyMG51bGwlMjAlN0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VmYXVsdCUyMHVuaXRsZXNzS2V5cyUyMiUyQyUyMmlzRW50cnklMjIlM0FmYWxzZSUyQyUyMm5hbWUlMjIlM0ElMjJ1bml0bGVzcy5qcyUyMiU3RCU1RCUyQyUyMm9wdGlvbnMlMjIlM0ElN0IlN0QlN0Q=),
[the `unitlessKeys` object shouldn't be emptied (see the `name in unitless` check), as is the case in 4.45.3 and earlier.
`styled-components` uses this to determine wether to add `px` units to CSS like `flex: 1`.](https://github.com/styled-components/styled-components/blob/d0b73acd931daef9eebb97e34fe4552ffc57d63e/packages/styled-components/src/utils/addUnitIfNeeded.ts#L10-L12)

### Actual Behaviour

[It removes all properties and this breaks projects that use `styled-components` with `vite`.](https://rollupjs.org/repl/?version=4.46.1&shareable=JTdCJTIyZXhhbXBsZSUyMiUzQW51bGwlMkMlMjJtb2R1bGVzJTIyJTNBJTVCJTdCJTIyY29kZSUyMiUzQSUyMiUyRiUyRiUyMGltcG9ydCUyMHVuaXRsZXNzJTIwZnJvbSUyMCclNDBlbW90aW9uJTJGdW5pdGxlc3MnJTNCJTVDbmltcG9ydCUyMHVuaXRsZXNzJTIwZnJvbSUyMCcuJTJGdW5pdGxlc3MnJTVDbiU1Q24lMkYlMkYlMjBPcmlnaW5hbCUyMGZ1bmN0aW9uJTIwaW4lMjAlNjBzdHlsZWQtY29tcG9uZW50cyU2MCUyQyUyMHN0cmlwcGVkJTIwZm9yJTIwVHlwZVNjcmlwdCUzQSUyMGh0dHBzJTNBJTJGJTJGZ2l0aHViLmNvbSUyRnN0eWxlZC1jb21wb25lbnRzJTJGc3R5bGVkLWNvbXBvbmVudHMlMkZibG9iJTJGZDBiNzNhY2Q5MzFkYWVmOWVlYmI5N2UzNGZlNDU1MmZmYzU3ZDYzZSUyRnBhY2thZ2VzJTJGc3R5bGVkLWNvbXBvbmVudHMlMkZzcmMlMkZ1dGlscyUyRmFkZFVuaXRJZk5lZWRlZC50cyUyM0wxMCU1Q25leHBvcnQlMjBkZWZhdWx0JTIwZn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yMDElMkMlNUNuJTIwJTIwc3Ryb2tlRGFzaG9mZnNldCUzQSUyMDElMkMlNUNuJTIwJTIwc3Ryb2tlTWl0ZXJsaW1pdCUzQSUyMDElMkMlNUNuJTIwJTIwc3Ryb2tlT3BhY2l0eSUzQSUyMDElMkMlNUNuJTIwJTIwc3Ryb2tlV2lkdGglM0ElMjAxJTVDbiU3RCU1Q24lNUNuZXhwb3J0JTIwZGVmYXVsdCUyMHVuaXRsZXNzS2V5cyUyMiUyQyUyMmlzRW50cnklMjIlM0FmYWxzZSUyQyUyMm5hbWUlMjIlM0ElMjJ1bml0bGVzcy5qcyUyMiU3RCU1RCUyQyUyMm9wdGlvbnMlMjIlM0ElN0IlN0QlN0Q=) Projects that use `rollup` to build npm libraries are unaffected, since `styled-components` is typically a peer dependency and thus marked as `external` in those cases.


Discussion:
Here's a repro that [shows the failure at runtime](https://stackblitz.com/edit/vitejs-vite-cfbvvlgw?file=src%2FApp.tsx), and how downgrading `rollup` to `4.45.3` [resolves it](https://stackblitz.com/edit/vitejs-vite-x46crnmj?file=package.json).
Thanks a lot for reporting this issue! It should be fixed in this PR #6041.
This issue has been resolved via #6041 as part of rollup@4.46.2. You can test it via `npm install rollup`.



Patch:
diff --git a/src/ast/nodes/BinaryExpression.ts b/src/ast/nodes/BinaryExpression.ts
index 5fd97123ead..c892972168c 100644
--- a/src/ast/nodes/BinaryExpression.ts
+++ b/src/ast/nodes/BinaryExpression.ts
@@ -13,6 +13,7 @@ import {
 	UNKNOWN_PATH
 } from '../utils/PathTracker';
 import { getRenderedLiteralValue } from '../utils/renderLiteralValue';
+import ExternalVariable from '../variables/ExternalVariable';
 import NamespaceVariable from '../variables/NamespaceVariable';
 import ExpressionStatement from './ExpressionStatement';
 import type { LiteralValue } from './Literal';
@@ -106,7 +107,9 @@ export default class BinaryExpression extends NodeBase implements DeoptimizableE
 
 		// Optimize `'export' in namespace`
 		if (this.operator === 'in' && this.right.variable instanceof NamespaceVariable) {
-			return this.right.variable.context.traceExport(String(leftValue))[0] != null;
+			const [variable] = this.right.variable.context.traceExport(String(leftValue));
+			if (variable instanceof ExternalVariable) return UnknownValue;
+			return !!variable;
 		}
 
 		const rightValue = this.right.getLiteralValueAtPath(EMPTY_PATH, recursionTracker, origin);
@@ -120,7 +123,9 @@ export default class BinaryExpression extends NodeBase implements DeoptimizableE
 
 	getRenderedLiteralValue() {
 		// Only optimize `'export' in ns`
-		if (this.operator !== 'in' || !this.right.variable?.isNamespace) return UnknownValue;
+		if (this.operator !== 'in' || !(this.right.variable instanceof NamespaceVariable)) {
+			return UnknownValue;
+		}
 
 		if (this.renderedLiteralValue !== UNASSIGNED) return this.renderedLiteralValue;
 		return (this.renderedLiteralValue = getRenderedLiteralValue(
@@ -147,11 +152,12 @@ export default class BinaryExpression extends NodeBase implements DeoptimizableE
 	include(
 		context: InclusionContext,
 		includeChildrenRecursively: IncludeChildren,
-		_options?: InclusionOptions
+		options?: InclusionOptions
 	) {
-		this.included = true;
+		if (!this.included) this.includeNode(context);
 		if (typeof this.getRenderedLiteralValue() === 'symbol') {
-			super.include(context, includeChildrenRecursively, _options);
+			this.left.include(context, includeChildrenRecursively, options);
+			this.right.include(context, includeChildrenRecursively, options);
 		}
 	}
 


Test patch:
diff --git a/test/form/samples/external-namespace-optimzation-in-operator/_config.js b/test/form/samples/external-namespace-optimzation-in-operator/_config.js
index 27cac503e6f..e8b8e8d6aed 100644
--- a/test/form/samples/external-namespace-optimzation-in-operator/_config.js
+++ b/test/form/samples/external-namespace-optimzation-in-operator/_config.js
@@ -1,6 +1,6 @@
 module.exports = {
 	description: 'disables optimization for external namespace when using the in operator',
 	options: {
-		external: ['node:crypto']
+		external: ['node:crypto', './ext.js']
 	}
 };
diff --git a/test/form/samples/external-namespace-optimzation-in-operator/_expected.js b/test/form/samples/external-namespace-optimzation-in-operator/_expected.js
index f0e7e0746cb..c4aee3950f4 100644
--- a/test/form/samples/external-namespace-optimzation-in-operator/_expected.js
+++ b/test/form/samples/external-namespace-optimzation-in-operator/_expected.js
@@ -1,5 +1,27 @@
 import * as nc from 'node:crypto';
+import * as ext from './ext.js';
+
+function _mergeNamespaces(n, m) {
+	m.forEach(function (e) {
+		e && typeof e !== 'string' && !Array.isArray(e) && Object.keys(e).forEach(function (k) {
+			if (k !== 'default' && !(k in n)) {
+				var d = Object.getOwnPropertyDescriptor(e, k);
+				Object.defineProperty(n, k, d.get ? d : {
+					enumerable: true,
+					get: function () { return e[k]; }
+				});
+			}
+		});
+	});
+	return Object.freeze(n);
+}
+
+var pt = /*#__PURE__*/_mergeNamespaces({
+	__proto__: null
+}, [ext]);
 
 const crypto = 'webcrypto' in nc;
+const direct = 'whatever' in ext;
+const indirect = 'whatever' in pt;
 
-export { crypto };
+export { crypto, direct, indirect };
diff --git a/test/form/samples/external-namespace-optimzation-in-operator/ext.js b/test/form/samples/external-namespace-optimzation-in-operator/ext.js
new file mode 100644
index 00000000000..79716867daa
--- /dev/null
+++ b/test/form/samples/external-namespace-optimzation-in-operator/ext.js
@@ -0,0 +1,1 @@
+export const whatever = 1
diff --git a/test/form/samples/external-namespace-optimzation-in-operator/main.js b/test/form/samples/external-namespace-optimzation-in-operator/main.js
index ff9e8ae494c..02fd0a0de85 100644
--- a/test/form/samples/external-namespace-optimzation-in-operator/main.js
+++ b/test/form/samples/external-namespace-optimzation-in-operator/main.js
@@ -1,2 +1,7 @@
 import * as nc from 'node:crypto';
+import * as ext from './ext.js';
+import * as pt from './passthrough.js';
+
 export const crypto = 'webcrypto' in nc;
+export const direct = 'whatever' in ext;
+export const indirect = 'whatever' in pt;
diff --git a/test/form/samples/external-namespace-optimzation-in-operator/passthrough.js b/test/form/samples/external-namespace-optimzation-in-operator/passthrough.js
new file mode 100644
index 00000000000..8ea6df22889
--- /dev/null
+++ b/test/form/samples/external-namespace-optimzation-in-operator/passthrough.js
@@ -0,0 +1,1 @@
+export * from './ext.js'
diff --git a/test/form/samples/namespace-optimization-in-operator/_expected.js b/test/form/samples/namespace-optimization-in-operator/_expected.js
index 2f585faf530..2259bb79ab7 100644
--- a/test/form/samples/namespace-optimization-in-operator/_expected.js
+++ b/test/form/samples/namespace-optimization-in-operator/_expected.js
@@ -1,3 +1,4 @@
 function c() {}
 
 console.log(c());
+console.log(true);
diff --git a/test/form/samples/namespace-optimization-in-operator/main.js b/test/form/samples/namespace-optimization-in-operator/main.js
index b7cabb7238b..7aa3bcffb32 100644
--- a/test/form/samples/namespace-optimization-in-operator/main.js
+++ b/test/form/samples/namespace-optimization-in-operator/main.js
@@ -1,4 +1,5 @@
 import * as foo from './foo';
 
-if ('d' in foo) console.log(foo.d())
-if ('c' in foo) console.log(foo.c())
+if ('d' in foo) console.log(foo.d());
+if ('c' in foo) console.log(foo.c());
+console.log('c' in foo);
diff --git a/test/form/samples/optimization-in-operator/_config.js b/test/form/samples/optimization-in-operator/_config.js
new file mode 100644
index 00000000000..8af6c86c0d4
--- /dev/null
+++ b/test/form/samples/optimization-in-operator/_config.js
@@ -0,0 +1,3 @@
+module.exports = defineTest({
+	description: 'keep foo structure'
+});
diff --git a/test/form/samples/optimization-in-operator/_expected.js b/test/form/samples/optimization-in-operator/_expected.js
new file mode 100644
index 00000000000..3972a98fbc9
--- /dev/null
+++ b/test/form/samples/optimization-in-operator/_expected.js
@@ -0,0 +1,11 @@
+var foo = {
+	a: 1,
+	b: 1
+};
+
+function check(name) {
+	if (name in foo) return true;
+	return false;
+}
+
+export { check as default };
diff --git a/test/form/samples/optimization-in-operator/foo.js b/test/form/samples/optimization-in-operator/foo.js
new file mode 100644
index 00000000000..49e5cbbe0e9
--- /dev/null
+++ b/test/form/samples/optimization-in-operator/foo.js
@@ -0,0 +1,4 @@
+export default {
+	a: 1,
+	b: 1
+};
diff --git a/test/form/samples/optimization-in-operator/main.js b/test/form/samples/optimization-in-operator/main.js
new file mode 100644
index 00000000000..5e30a2f4012
--- /dev/null
+++ b/test/form/samples/optimization-in-operator/main.js
@@ -0,0 +1,6 @@
+import foo from './foo';
+
+export default function check(name) {
+	if (name in foo) return true;
+	return false;
+}