Skip to content

Commit 170d023

Browse files
authored
refactor!: switch to esm-only and update to ml-spectra-fitting@5 (#127)
Refs: https://github.com/cheminfo/generator-cheminfo/blob/main/ts-migration.md Closes: #126
1 parent 9c71d0b commit 170d023

40 files changed

+147
-156
lines changed

.eslintrc.yml

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

.github/workflows/npm-prerelease.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,4 +11,4 @@ jobs:
1111
uses: zakodium/workflows/.github/workflows/npm-prerelease.yml@npm-prerelease-v1
1212
secrets:
1313
github-token: ${{ secrets.BOT_TOKEN }}
14-
npm-token: ${{ secrets.NPM_BOT_TOKEN }}
14+
npm-token: ${{ secrets.NPM_BOT_TOKEN }}

.prettierignore

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,4 @@
1-
src/__tests__/data/*.json
1+
src/__tests__/data/*.json
2+
CHANGELOG.md
3+
lib
4+
examples

eslint.config.mjs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
import { defineConfig, globalIgnores } from 'eslint/config';
2+
import ts from 'eslint-config-cheminfo-typescript/base';
3+
4+
export default defineConfig(
5+
globalIgnores(['coverage', 'lib', 'dist', 'examples']),
6+
ts,
7+
);

package.json

Lines changed: 17 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -2,28 +2,25 @@
22
"name": "ml-gsd",
33
"version": "12.1.8",
44
"description": "Global Spectra Deconvolution",
5-
"main": "./lib/index.js",
6-
"module": "./lib-esm/index.js",
7-
"types": "./lib/index.d.ts",
5+
"type": "module",
6+
"exports": "./lib/index.js",
87
"files": [
98
"lib",
10-
"src",
11-
"lib-esm"
9+
"src"
1210
],
1311
"scripts": {
14-
"build": "npm run tsc-esm && cheminfo-build --entry lib-esm/index.js --root GSD",
12+
"build": "npm run tsc && cheminfo-build --entry lib/index.js --root GSD",
1513
"check-types": "tsc --noEmit",
16-
"clean": "rimraf lib lib-esm",
17-
"eslint": "eslint src --cache",
18-
"eslint-fix": "npm run eslint -- --fix",
14+
"clean": "rimraf lib",
15+
"eslint": "eslint . --cache",
16+
"eslint-fix": "eslint . --cache --fix",
1917
"prepack": "npm run tsc",
20-
"prettier": "prettier --check src",
21-
"prettier-write": "prettier --write src",
18+
"prettier": "prettier --check .",
19+
"prettier-write": "prettier --write .",
2220
"test": "npm run test-only && npm run eslint && npm run prettier && npm run check-types",
2321
"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"
22+
"tsc": "npm run clean && npm run tsc-build",
23+
"tsc-build": "tsc --project tsconfig.build.json"
2724
},
2825
"repository": {
2926
"type": "git",
@@ -54,18 +51,20 @@
5451
"trailingComma": "all"
5552
},
5653
"devDependencies": {
54+
"@types/node": "^24.0.1",
5755
"@vitest/coverage-v8": "^1.6.0",
56+
"@zakodium/tsconfig": "^1.0.1",
5857
"cheminfo-build": "^1.2.0",
59-
"eslint": "^8.57.0",
60-
"eslint-config-cheminfo-typescript": "^12.4.0",
58+
"eslint": "^9.28.0",
59+
"eslint-config-cheminfo-typescript": "^18.0.1",
6160
"esm": "^3.2.25",
6261
"jest-matcher-deep-close-to": "^3.0.2",
6362
"mf-global": "^3.0.20",
6463
"ml-stat": "^1.3.3",
6564
"prettier": "^3.2.5",
6665
"rimraf": "^5.0.6",
6766
"spectrum-generator": "^8.0.11",
68-
"typescript": "^5.4.5",
67+
"typescript": "^5.8.3",
6968
"vitest": "^1.6.0",
7069
"xy-parser": "^5.0.5"
7170
},
@@ -74,7 +73,7 @@
7473
"cheminfo-types": "^1.7.3",
7574
"ml-peak-shape-generator": "^4.1.4",
7675
"ml-savitzky-golay-generalized": "^4.2.0",
77-
"ml-spectra-fitting": "^4.2.4",
76+
"ml-spectra-fitting": "^5.0.1",
7877
"ml-spectra-processing": "^14.5.3"
7978
}
8079
}

src/GSDBroadenPeak.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { Shape1D } from 'ml-peak-shape-generator';
1+
import type { Shape1D } from 'ml-peak-shape-generator';
22

33
export interface GSDBroadenPeak {
44
id?: string;

src/GSDPeakOptimized.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { Shape1D } from 'ml-peak-shape-generator';
1+
import type { Shape1D } from 'ml-peak-shape-generator';
22

33
export interface GSDPeakOptimized {
44
id?: string;

src/__tests__/ethylvinylether.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import { readFileSync } from 'fs';
22

33
import { describe, expect, it } from 'vitest';
44

5-
import { gsd } from '../gsd';
5+
import { gsd } from '../gsd.ts';
66

77
describe('Global spectra deconvolution NMR spectra', () => {
88
// Test case obtained from Pag 443, Chap 8.

src/__tests__/gaussian-noise.test.ts

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,8 @@
11
import type { DataXY } from 'cheminfo-types';
2+
import { generateSpectrum } from 'spectrum-generator';
23
import { describe, expect, it } from 'vitest';
34

4-
import { gsd } from '../gsd';
5-
6-
// eslint-disable-next-line @typescript-eslint/no-var-requires
7-
const { generateSpectrum } = require('spectrum-generator');
5+
import { gsd } from '../gsd.ts';
86

97
describe('smooth:false option', () => {
108
const peaks = [
@@ -18,7 +16,7 @@ describe('smooth:false option', () => {
1816
to: 1,
1917
nbPoints: 101,
2018
},
21-
peaks: {
19+
peakOptions: {
2220
factor: 6,
2321
},
2422
noise: {

src/__tests__/gaussian-noiseParam.test.ts

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,8 @@
11
import type { DataXY } from 'cheminfo-types';
2+
import { generateSpectrum } from 'spectrum-generator';
23
import { describe, expect, it } from 'vitest';
34

4-
import { gsd } from '../gsd';
5-
6-
// eslint-disable-next-line @typescript-eslint/no-var-requires
7-
const { generateSpectrum } = require('spectrum-generator');
5+
import { gsd } from '../gsd.ts';
86

97
describe('smooth:false option', () => {
108
const peaks = [
@@ -18,7 +16,7 @@ describe('smooth:false option', () => {
1816
to: 1,
1917
nbPoints: 101,
2018
},
21-
peaks: {
19+
peakOptions: {
2220
factor: 6,
2321
},
2422
noise: {

0 commit comments

Comments
 (0)