Skip to content

Commit

Permalink
Allow export of default entrypoints
Browse files Browse the repository at this point in the history
  • Loading branch information
jacoblee93 committed Jan 13, 2025
1 parent 574dcbb commit e1824bb
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions js/scripts/create-entrypoints.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,10 @@ const entrypoints = {
"singletons/traceable": "singletons/traceable",
};

const defaultEntrypoints = [
"vitest/reporter"
];

const updateJsonFile = (relativePath, updateFunction) => {
const contents = fs.readFileSync(relativePath).toString();
const res = updateFunction(JSON.parse(contents));
Expand All @@ -38,6 +42,17 @@ const generateFiles = () => {
const nrOfDots = key.split("/").length - 1;
const relativePath = "../".repeat(nrOfDots) || "./";
const compiledPath = `${relativePath}dist/${value}.js`;
if (defaultEntrypoints.includes(key)) {
return [
[
`${key}.cjs`,
`module.exports = require('${relativePath}dist/${value}.cjs').default;`,
],
[`${key}.js`, `export { default } from '${compiledPath}'`],
[`${key}.d.ts`, `export { default } from '${compiledPath}'`],
[`${key}.d.cts`, `export { default } from '${compiledPath}'`],
];
}
return [
[
`${key}.cjs`,
Expand Down

0 comments on commit e1824bb

Please sign in to comment.