summaryrefslogtreecommitdiff
path: root/dev/build-libs.js
diff options
context:
space:
mode:
authorDarius Jahandarie <djahandarie@gmail.com>2023-12-06 03:53:16 +0000
committerGitHub <noreply@github.com>2023-12-06 03:53:16 +0000
commitbd5bc1a5db29903bc098995cd9262c4576bf76af (patch)
treec9214189e0214480fcf6539ad1c6327aef6cbd1c /dev/build-libs.js
parentfd6bba8a2a869eaf2b2c1fa49001f933fce3c618 (diff)
parent23e6fb76319c9ed7c9bcdc3efba39bc5dd38f288 (diff)
Merge pull request #339 from toasted-nutbread/type-annotations
Type annotations
Diffstat (limited to 'dev/build-libs.js')
-rw-r--r--dev/build-libs.js19
1 files changed, 13 insertions, 6 deletions
diff --git a/dev/build-libs.js b/dev/build-libs.js
index 8320a947..5caabec7 100644
--- a/dev/build-libs.js
+++ b/dev/build-libs.js
@@ -26,19 +26,26 @@ import {fileURLToPath} from 'url';
const dirname = path.dirname(fileURLToPath(import.meta.url));
const extDir = path.join(dirname, '..', 'ext');
-async function buildLib(p) {
+/**
+ * @param {string} scriptPath
+ */
+async function buildLib(scriptPath) {
await esbuild.build({
- entryPoints: [p],
+ entryPoints: [scriptPath],
bundle: true,
minify: false,
sourcemap: true,
target: 'es2020',
format: 'esm',
- outfile: path.join(extDir, 'lib', path.basename(p)),
- external: ['fs']
+ outfile: path.join(extDir, 'lib', path.basename(scriptPath)),
+ external: ['fs'],
+ banner: {
+ js: '// @ts-nocheck'
+ }
});
}
+/** */
export async function buildLibs() {
const devLibPath = path.join(dirname, 'lib');
const files = await fs.promises.readdir(devLibPath, {
@@ -52,12 +59,12 @@ export async function buildLibs() {
const schemaDir = path.join(extDir, 'data/schemas/');
const schemaFileNames = fs.readdirSync(schemaDir);
- const schemas = schemaFileNames.map((schemaFileName) => JSON.parse(fs.readFileSync(path.join(schemaDir, schemaFileName))));
+ const schemas = schemaFileNames.map((schemaFileName) => JSON.parse(fs.readFileSync(path.join(schemaDir, schemaFileName), {encoding: 'utf8'})));
const ajv = new Ajv({schemas: schemas, code: {source: true, esm: true}});
const moduleCode = standaloneCode(ajv);
// https://github.com/ajv-validator/ajv/issues/2209
- const patchedModuleCode = "import {ucs2length} from './ucs2length.js';" + moduleCode.replaceAll('require("ajv/dist/runtime/ucs2length").default', 'ucs2length');
+ const patchedModuleCode = "// @ts-nocheck\nimport {ucs2length} from './ucs2length.js';" + moduleCode.replaceAll('require("ajv/dist/runtime/ucs2length").default', 'ucs2length');
fs.writeFileSync(path.join(extDir, 'lib/validate-schemas.js'), patchedModuleCode);
}