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

[core] Do not append types field to packages without index.d.ts #33952

Merged
merged 1 commit into from
Aug 31, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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