Skip to content

Commit 76f36b3

Browse files
committed
feat!: migrate to type:module
1 parent 92f9341 commit 76f36b3

38 files changed

+231
-221
lines changed

eslint.config.mjs

Lines changed: 3 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,4 @@
1-
import cheminfo from 'eslint-config-cheminfo-typescript';
2-
import globals from 'globals';
1+
import { defineConfig, globalIgnores } from 'eslint/config';
2+
import ts from 'eslint-config-cheminfo-typescript';
33

4-
export default [
5-
...cheminfo,
6-
{
7-
languageOptions: {
8-
globals: {
9-
...globals.node,
10-
},
11-
},
12-
rules: {},
13-
},
14-
];
4+
export default defineConfig(globalIgnores(['coverage', 'lib']), ts);

jsconfig.json

Lines changed: 0 additions & 3 deletions
This file was deleted.

package.json

Lines changed: 21 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -2,16 +2,16 @@
22
"name": "arraybuffer-xml-parser",
33
"version": "1.0.0",
44
"description": "Parse XML files contained in an array buffer",
5-
"main": "./lib/index.js",
6-
"module": "./lib-esm/index.js",
7-
"types": "./lib/index.d.ts",
5+
"type": "module",
6+
"exports": {
7+
".": "./lib/index.js"
8+
},
89
"files": [
9-
"src",
1010
"lib",
11-
"lib-esm"
11+
"src"
1212
],
1313
"scripts": {
14-
"build": "npm run tsc-esm && cheminfo-build --entry lib-esm/index.js --root XMLParser",
14+
"build": "npm run tsc-build && cheminfo-build --entry lib/index.js --root XMLParser",
1515
"check-types": "tsc --noEmit",
1616
"clean": "rimraf lib lib-esm",
1717
"eslint": "eslint src",
@@ -21,9 +21,8 @@
2121
"prettier-write": "prettier --write src",
2222
"test": "npm run test-only && npm run eslint && npm run prettier && npm run check-types",
2323
"test-only": "vitest run --coverage",
24-
"tsc": "npm run clean && npm run tsc-cjs && npm run tsc-esm",
25-
"tsc-cjs": "tsc --project tsconfig.cjs.json",
26-
"tsc-esm": "tsc --project tsconfig.esm.json"
24+
"tsc": "npm run clean && npm run tsc-build",
25+
"tsc-build": "tsc --project tsconfig.build.json"
2726
},
2827
"repository": {
2928
"type": "git",
@@ -38,22 +37,23 @@
3837
"homepage": "https://github.com/cheminfo/arraybuffer-xml-parser#readme",
3938
"devDependencies": {
4039
"@types/he": "^1.2.3",
41-
"@vitest/coverage-v8": "2.1.7",
42-
"cheminfo-build": "^1.2.0",
43-
"eslint": "^9.16.0",
44-
"eslint-config-cheminfo-typescript": "^17.0.0",
45-
"globals": "^15.13.0",
40+
"@vitest/coverage-v8": "4.0.12",
41+
"@zakodium/tsconfig": "^1.0.2",
42+
"cheminfo-build": "^1.3.1",
43+
"eslint": "^9.39.1",
44+
"eslint-config-cheminfo-typescript": "^21.0.1",
45+
"globals": "^16.5.0",
4646
"he": "^1.2.0",
47-
"iobuffer": "^5.3.2",
48-
"ml-spectra-processing": "^14.8.0",
47+
"ml-spectra-processing": "^14.18.1",
4948
"pako": "^2.1.0",
50-
"prettier": "^3.4.1",
51-
"rimraf": "^6.0.1",
52-
"typescript": "^5.7.2",
53-
"uint8-base64": "^0.1.1",
54-
"vitest": "^2.1.7"
49+
"prettier": "^3.6.2",
50+
"rimraf": "^6.1.2",
51+
"typescript": "^5.9.3",
52+
"uint8-base64": "^1.0.0",
53+
"vitest": "^4.0.12"
5554
},
5655
"dependencies": {
56+
"@types/node": "^24.10.1",
5757
"dynamic-typing": "^1.0.1"
5858
}
5959
}

src/XMLNode.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import type { TagValueProcessor } from './traversable/defaultOptions';
1+
import type { TagValueProcessor } from './traversable/defaultOptions.js';
22

33
export type XMLNodeValue = string | Uint8Array | number | boolean;
44
export type XMLAttributeValue = string | number | boolean;

src/__tests__/arrayModeSpec.test.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
import { describe, it, expect } from 'vitest';
1+
import { describe, expect, it } from 'vitest';
22

3-
import { parse } from '../parse';
3+
import { parse } from '../parse.js';
44

55
const encoder = new TextEncoder();
66

@@ -224,6 +224,7 @@ describe('XMLParser with arrayMode enabled', () => {
224224
arrayMode: /inventory|item/,
225225
ignoreAttributes: false,
226226
});
227+
227228
expect(regExResult).toStrictEqual(expected);
228229

229230
const cbExResult = parse(xmlData, {
@@ -232,6 +233,7 @@ describe('XMLParser with arrayMode enabled', () => {
232233
},
233234
ignoreAttributes: false,
234235
});
236+
235237
expect(cbExResult).toStrictEqual(expected);
236238
});
237239

src/__tests__/arrayWithExtendedPrototypePropsSpec.test.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
import { describe, it, expect } from 'vitest';
1+
import { describe, expect, it } from 'vitest';
22

3-
import { parse } from '../parse.ts';
3+
import { parse } from '../parse.js';
44

55
const encoder = new TextEncoder();
66

@@ -23,6 +23,7 @@ describe('XMLParser array with extended prototype props', () => {
2323
arrayMode: false,
2424
ignoreAttributes: false,
2525
});
26+
2627
//console.log(JSON.stringify(result, null, 4));
2728
expect(result).toStrictEqual(expected);
2829
});

src/__tests__/attributesSpec.test.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
import { describe, it, expect } from 'vitest';
1+
import { describe, expect, it } from 'vitest';
22
// import he from 'he';
33

4-
import { parse } from '../parse';
4+
import { parse } from '../parse.js';
55

66
const encoder = new TextEncoder();
77

src/__tests__/base64.test.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { decode as base64decode } from 'uint8-base64';
2-
import { test, expect } from 'vitest';
2+
import { expect, test } from 'vitest';
33

4-
import { parse } from '../parse.ts';
4+
import { parse } from '../parse.js';
55
// library to convert base64 <--> arrayBuffer: https://github.com/niklasvh/base64-arraybuffer/blob/master/src/index.ts
66

77
const encoder = new TextEncoder();
@@ -24,6 +24,7 @@ test('base64 parsing', () => {
2424
return new Float64Array(decoded.buffer);
2525
},
2626
});
27+
2728
expect(result.binaryDataArray.binary).toStrictEqual(
2829
Float64Array.from([1, 2, 3]),
2930
);

src/__tests__/cdataSpec.test.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
import { readFileSync } from 'node:fs';
22
import { join } from 'node:path';
33

4-
import { describe, it, expect } from 'vitest';
4+
import { describe, expect, it } from 'vitest';
55

6-
import { parse } from '../parse';
6+
import { parse } from '../parse.js';
77

88
const encoder = new TextEncoder();
99

@@ -21,8 +21,10 @@ patronymic</person></root>`);
2121
person: 'lastname\nfirstname\npatronymic',
2222
},
2323
};
24+
2425
expect(result).toStrictEqual(expected);
2526
});
27+
2628
it('should parse tag having CDATA', () => {
2729
const xmlData = encoder.encode(`<?xml version='1.0'?>
2830
<any_name>

src/__tests__/cheminfo.test.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
import { describe, it, expect } from 'vitest';
1+
import { describe, expect, it } from 'vitest';
22

3-
import { parse } from '../parse';
3+
import { parse } from '../parse.js';
44

55
describe('XMLParser', () => {
66
it('Try to parse a very simple example', () => {

0 commit comments

Comments
 (0)