Skip to content

Commit

Permalink
[core] Do not append types field to packages without index.d.ts (mu…
Browse files Browse the repository at this point in the history
  • Loading branch information
michaldudak authored and Daniel Rabe committed Nov 29, 2022
1 parent b97ccb6 commit 015e93a
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions scripts/copy-files.js
Expand Up @@ -102,9 +102,13 @@ async function createPackageFile() {
: './index.js',
}
: {}),
types: './index.d.ts',
};

const typeDefinitionsFilePath = path.resolve(buildPath, './index.d.ts');
if (await fse.pathExists(typeDefinitionsFilePath)) {
newPackageData.types = './index.d.ts';
}

const targetPath = path.resolve(buildPath, './package.json');

await fse.writeFile(targetPath, JSON.stringify(newPackageData, null, 2), 'utf8');
Expand Down Expand Up @@ -149,6 +153,9 @@ async function addLicense(packageData) {

async function run() {
try {
// TypeScript
await typescriptCopy({ from: srcPath, to: buildPath });

const packageData = await createPackageFile();

await Promise.all(
Expand All @@ -162,9 +169,6 @@ async function run() {

await addLicense(packageData);

// TypeScript
await typescriptCopy({ from: srcPath, to: buildPath });

await createModulePackages({ from: srcPath, to: buildPath });
} catch (err) {
console.error(err);
Expand Down

0 comments on commit 015e93a

Please sign in to comment.