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

fix(type): Patch rollup-plugin-dts bug that broke prebundled zod #8306

Merged
merged 1 commit into from
Nov 1, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,8 @@
"packageManager": "pnpm@9.12.3",
"pnpm": {
"patchedDependencies": {
"graceful-fs@4.2.10": "patches/graceful-fs@4.2.10.patch"
"graceful-fs@4.2.10": "patches/graceful-fs@4.2.10.patch",
"rollup-plugin-dts": "patches/rollup-plugin-dts.patch"
}
},
"lint-staged": {
Expand Down
27 changes: 27 additions & 0 deletions patches/rollup-plugin-dts.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
diff --git a/dist/rollup-plugin-dts.mjs b/dist/rollup-plugin-dts.mjs
index 4a9412285c48c37d03340a086c771f8e61fd82ac..c1b7d3b95979811b71b49a53aba4ca07901e2a9d 100644
--- a/dist/rollup-plugin-dts.mjs
+++ b/dist/rollup-plugin-dts.mjs
@@ -351,6 +351,10 @@ class NamespaceFixer {
code += `type ${ns.name}_${exportedName}${typeParams.in} = ${localName}${typeParams.out};\n`;
code += `declare const ${ns.name}_${exportedName}: typeof ${localName};\n`;
}
+ else if (type === "namespace") {
+ // namespaces may contain both types and values
+ code += `import ${ns.name}_${exportedName} = ${localName};\n`;
+ }
else {
// functions and vars are just values
code += `declare const ${ns.name}_${exportedName}: typeof ${localName};\n`;
@@ -1404,6 +1408,11 @@ class Transformer {
}
convertImportDeclaration(node) {
if (ts.isImportEqualsDeclaration(node)) {
+ if (ts.isEntityName(node.moduleReference)) {
+ const scope = this.createDeclaration(node, node.name);
+ scope.pushReference(scope.convertEntityName(node.moduleReference));
+ return;
+ }
// assume its like `import default`
if (!ts.isExternalModuleReference(node.moduleReference)) {
throw new UnsupportedSyntaxError(node, "ImportEquals should have a literal source.");
7 changes: 5 additions & 2 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading