Skip to content

Commit

Permalink
fix: properly resolve types when using TypeScript's latest module res…
Browse files Browse the repository at this point in the history
…olution strategy (#300)

* fix: properly resolve types when using TypeScript's latest module resolution strategy

* chore(deps): update `@prismicio/richtext`

* chore: remove `.d.ts` files from Size Limit output
  • Loading branch information
angeloashmore authored May 22, 2023
1 parent 92b1701 commit a2b1084
Show file tree
Hide file tree
Showing 3 changed files with 38 additions and 23 deletions.
35 changes: 22 additions & 13 deletions .size-limit.cjs
Original file line number Diff line number Diff line change
@@ -1,21 +1,30 @@
const pkg = require("./package.json");

function getObjectValues(input, acc = []) {
if (typeof input === "string") {
return input;
} else {
return [
...acc,
...Object.values(input).flatMap((value) => getObjectValues(value)),
];
}
}

module.exports = [
...new Set([
pkg.main,
pkg.module,
...Object.values(pkg.exports).flatMap((exportTypes) => {
if (typeof exportTypes === "string") {
return exportTypes;
} else {
return Object.values(exportTypes);
}
}),
]),
...new Set([pkg.main, pkg.module, ...getObjectValues(pkg.exports)]),
]
.sort()
.filter((path) => {
return path && path !== "./package.json";
return path && path !== "./package.json" && !path.endsWith(".d.ts");
})
.map((path) => {
return { path };
return {
path,
modifyEsbuildConfig(config) {
config.platform = "node";

return config;
},
};
});
14 changes: 7 additions & 7 deletions package-lock.json

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

12 changes: 9 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,14 @@
"type": "module",
"exports": {
".": {
"require": "./dist/index.cjs",
"import": "./dist/index.js"
"require": {
"types": "./dist/index.d.ts",
"default": "./dist/index.cjs"
},
"import": {
"types": "./dist/index.d.ts",
"default": "./dist/index.js"
}
},
"./package.json": "./package.json"
},
Expand Down Expand Up @@ -53,7 +59,7 @@
"test": "npm run lint && npm run types && npm run unit && npm run build && npm run size"
},
"dependencies": {
"@prismicio/richtext": "^2.1.4",
"@prismicio/richtext": "^2.1.5",
"imgix-url-builder": "^0.0.3"
},
"devDependencies": {
Expand Down

0 comments on commit a2b1084

Please sign in to comment.