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

Add missing typescript esm types #1623

Merged
merged 3 commits into from
Nov 12, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
### Changed

### Fixed
- Updated ESM build with missing types.

## [6.1.2]

Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@
"scripts": {
"build": "npm run build:lib && npm run build:amd && npm run build:es && npm run build:es6",
"build:amd": "tsc -p src/tsconfig-amd.json",
"build:es": "tsc -p src/tsconfig-es.json",
"build:es": "tsc -p src/tsconfig-es.json && node ./scripts/writeEsmPackageJson.mjs ./es",
"build:es6": "tsc -p src/tsconfig-es6.json",
"build:lib": "tsc -p src/tsconfig.json",
"clean": "rimraf amd es es6 lib",
Expand Down
43 changes: 43 additions & 0 deletions scripts/writeEsmPackageJson.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
#!/usr/bin/env node

import fs from 'node:fs/promises';
import { argv } from 'node:process';
import path from 'node:path';
import { writeFile } from 'node:fs/promises';

/**
* @param {string} path
* @returns {Promise<boolean>}
*/
async function pathExists(path) {
try {
await fs.access(path);
return true;
} catch (_err) {
return false;
}
}

const directory = argv[2];

if (directory === undefined) {
throw new Error('Expected a path');
}

const directoryExists = await pathExists(directory);

if (!directoryExists) {
throw new Error(`Path ${directory} not found`);
}

const filePath = path.join(directory, 'package.json');

const packageJsonFileContent = JSON.stringify(
{
type: 'module',
},
undefined,
2,
);

await writeFile(filePath, packageJsonFileContent);
2 changes: 0 additions & 2 deletions src/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,6 @@
],
"extends": "../tsconfig.json",
"compilerOptions": {
"composite": true,
"declaration": true,
"outDir": "../lib",
"rootDir": "."
},
Expand Down
1 change: 1 addition & 0 deletions tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
"allowUnusedLabels": false,
"alwaysStrict": true,
"assumeChangesOnlyAffectDirectDependencies": true,
"declaration": true,
"emitDecoratorMetadata": true,
"esModuleInterop": true,
"exactOptionalPropertyTypes": true,
Expand Down