fix(vite): get radix-ui working (#3344)

This commit is contained in:
Marvin Hagemeister
2025-09-05 16:51:22 +02:00
committed by GitHub
parent b06ef5a855
commit 185ab95751
7 changed files with 992 additions and 10 deletions
@@ -439,6 +439,21 @@ Object.defineProperty(exports, "__esModule", { value: true });
__exportStar(require("./node"), exports);`,
expected: `${INIT}
import * as _ns from "./node";
var __createBinding = this && this.__createBinding || (Object.create ? function (o, m, k, k2) {
if (k2 === undefined) k2 = k;
Object.defineProperty(o, k2, {
enumerable: true,
get: function () {
return m[k];
}
});
} : function (o, m, k, k2) {
if (k2 === undefined) k2 = k;
o[k2] = m[k];
});
var __exportStar = this && this.__exportStar || function (m, exports) {
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
};
export * from "./node";
${DEFAULT_EXPORT}
Object.assign(_default, _ns);
@@ -470,6 +485,13 @@ const pkg = require(path.join(basedir, "package.json"));`,
});
});
Deno.test("commonjs - keep binding", () => {
runTest({
input: `export var __createBinding = Object.create ? 1 : 2;`,
expected: `export var __createBinding = Object.create ? 1 : 2;`,
});
});
Deno.test("commonjs - require lazy import", () => {
runTest({
input: `if (typeof process.env.NODE_PG_FORCE_NATIVE !== 'undefined') {
@@ -533,3 +555,32 @@ ${DEFAULT_EXPORT}
${DEFAULT_EXPORT_END}`,
});
});
Deno.test("commonjs - wrapped iife binding", () => {
runTest({
input: `"production" !== process.env.NODE_ENV && (function() {
exports.foo = 123
})()`,
expected: `${INIT}
"production" !== process.env.NODE_ENV && function () {
exports.foo = 123;
}();
var _foo = exports.foo;
export { _foo as foo };
${DEFAULT_EXPORT}
_default.foo = _foo;
${DEFAULT_EXPORT_END}`,
});
});
Deno.test("commonjs - re-export", () => {
runTest({
input: `module.exports = require("foo");`,
expected: `${INIT}
export * from "foo";
import * as _mod from "foo";
module.exports = _mod;
${DEFAULT_EXPORT}
${DEFAULT_EXPORT_END}`,
});
});