From 2298d2467fe96e7dd0ad90e9d3e2be4aa016491b Mon Sep 17 00:00:00 2001 From: Pooya Parsa Date: Thu, 22 Aug 2024 23:55:01 +0200 Subject: [PATCH] chore: fix types --- package.json | 2 +- pnpm-lock.yaml | 32 ++++++++++++++++---------------- src/rollup/plugins/externals.ts | 10 +++++++--- 3 files changed, 24 insertions(+), 20 deletions(-) diff --git a/package.json b/package.json index 92b4a73fa3..d07e5ff571 100644 --- a/package.json +++ b/package.json @@ -149,7 +149,7 @@ "openapi-typescript": "^7.3.0", "pathe": "^1.1.2", "perfect-debounce": "^1.0.0", - "pkg-types": "^1.1.3", + "pkg-types": "^1.2.0", "pretty-bytes": "^6.1.1", "radix3": "^1.1.2", "rollup": "^4.21.0", diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 101694e8d5..cf2b052938 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -171,8 +171,8 @@ importers: specifier: ^1.0.0 version: 1.0.0 pkg-types: - specifier: ^1.1.3 - version: 1.1.3 + specifier: ^1.2.0 + version: 1.2.0 pretty-bytes: specifier: ^6.1.1 version: 6.1.1 @@ -4644,8 +4644,8 @@ packages: resolution: {integrity: sha512-saLsH7WeYYPiD25LDuLRRY/i+6HaPYr6G1OUlN39otzkSTxKnubR9RTxS3/Kk50s1g2JTgFwWQDQyplC5/SHZg==} engines: {node: '>= 6'} - pkg-types@1.1.3: - resolution: {integrity: sha512-+JrgthZG6m3ckicaOB74TwQ+tBWsFl3qVQg7mN8ulwSOElJ7gBhKzj2VkCPnZ4NlF6kEquYU+RIYNVAvzd54UA==} + pkg-types@1.2.0: + resolution: {integrity: sha512-+ifYuSSqOQ8CqP4MbZA5hDpb97n3E8SVWdJe+Wms9kj745lmd3b7EZJiqvmLwAlmRfjrI7Hi5z3kdBJ93lFNPA==} pluralize@8.0.0: resolution: {integrity: sha512-Nc3IT5yHzflTfbjgqWcCPpo7DaKy4FnpB0l/zCAW0Tc7jxAiuqSxHasntB3D7887LSrA93kDJ9IXovxJYxyLCA==} @@ -8123,7 +8123,7 @@ snapshots: ofetch: 1.3.4 pathe: 1.1.2 perfect-debounce: 1.0.0 - pkg-types: 1.1.3 + pkg-types: 1.2.0 scule: 1.3.0 untyped: 1.4.2 transitivePeerDependencies: @@ -8287,7 +8287,7 @@ snapshots: ohash: 1.1.3 pathe: 1.1.2 perfect-debounce: 1.0.0 - pkg-types: 1.1.3 + pkg-types: 1.2.0 rc9: 2.1.2 optionalDependencies: magicast: 0.3.4 @@ -8304,7 +8304,7 @@ snapshots: ohash: 1.1.3 pathe: 1.1.2 perfect-debounce: 1.0.0 - pkg-types: 1.1.3 + pkg-types: 1.2.0 rc9: 2.1.2 optionalDependencies: magicast: 0.3.4 @@ -8386,7 +8386,7 @@ snapshots: ofetch: 1.3.4 open: 9.1.0 pathe: 1.1.2 - pkg-types: 1.1.3 + pkg-types: 1.2.0 scule: 1.3.0 semver: 7.6.3 std-env: 3.7.0 @@ -10227,7 +10227,7 @@ snapshots: local-pkg@0.5.0: dependencies: mlly: 1.7.1 - pkg-types: 1.1.3 + pkg-types: 1.2.0 locate-path@5.0.0: dependencies: @@ -10773,7 +10773,7 @@ snapshots: jiti: 1.21.6 mlly: 1.7.1 pathe: 1.1.2 - pkg-types: 1.1.3 + pkg-types: 1.2.0 postcss: 8.4.41 postcss-nested: 6.2.0(postcss@8.4.41) semver: 7.6.3 @@ -10784,7 +10784,7 @@ snapshots: dependencies: acorn: 8.12.1 pathe: 1.1.2 - pkg-types: 1.1.3 + pkg-types: 1.2.0 ufo: 1.5.4 mri@1.2.0: {} @@ -10879,7 +10879,7 @@ snapshots: consola: 3.2.3 execa: 8.0.1 pathe: 1.1.2 - pkg-types: 1.1.3 + pkg-types: 1.2.0 ufo: 1.5.4 object-assign@4.1.1: {} @@ -11083,7 +11083,7 @@ snapshots: pirates@4.0.6: {} - pkg-types@1.1.3: + pkg-types@1.2.0: dependencies: confbox: 0.1.7 mlly: 1.7.1 @@ -12167,7 +12167,7 @@ snapshots: mkdist: 1.5.4(typescript@5.5.4) mlly: 1.7.1 pathe: 1.1.2 - pkg-types: 1.1.3 + pkg-types: 1.2.0 pretty-bytes: 6.1.1 rollup: 4.21.0 rollup-plugin-dts: 6.1.1(rollup@4.21.0)(typescript@5.5.4) @@ -12234,7 +12234,7 @@ snapshots: magic-string: 0.30.11 mlly: 1.7.1 pathe: 1.1.2 - pkg-types: 1.1.3 + pkg-types: 1.2.0 scule: 1.3.0 strip-literal: 2.1.0 unplugin: 1.12.2 @@ -12331,7 +12331,7 @@ snapshots: magic-string: 0.30.11 mlly: 1.7.1 pathe: 1.1.2 - pkg-types: 1.1.3 + pkg-types: 1.2.0 unplugin: 1.12.2 update-browserslist-db@1.1.0(browserslist@4.23.3): diff --git a/src/rollup/plugins/externals.ts b/src/rollup/plugins/externals.ts index 188d06f990..20eff6c973 100644 --- a/src/rollup/plugins/externals.ts +++ b/src/rollup/plugins/externals.ts @@ -483,10 +483,14 @@ function compareVersions(v1 = "0.0.0", v2 = "0.0.0") { } export function applyProductionCondition(exports: PackageJson["exports"]) { - if (!exports || typeof exports === "string") { + if ( + !exports || + typeof exports === "string" || + Array.isArray(exports) /* TODO: unhandled */ + ) { return; } - if (exports.production) { + if ("production" in exports) { if (typeof exports.production === "string") { exports.default = exports.production; } else { @@ -494,7 +498,7 @@ export function applyProductionCondition(exports: PackageJson["exports"]) { } } for (const key in exports) { - applyProductionCondition(exports[key]); + applyProductionCondition(exports[key as keyof typeof exports]); } }