philihp / openskill.js

A faster, open-license alternative to Microsoft TrueSkill
https://www.npmjs.com/package/openskill
MIT License
203 stars 19 forks source link

chore(deps): add missing export for models #687

Closed eddyfidel closed 1 month ago

eddyfidel commented 1 month ago

This change addresses an issue where the OpenSkill model definitions (bradleyTerryFull, bradleyTerryPart, plackettLuce, thurstoneMostellerFull, and thurstoneMostellerPart) were not properly exported, making them inaccessible through standard import paths. The new configuration in the package.json allows users to directly import these models in their projects using different module formats (ES Modules, CommonJS, and TypeScript types).

Change Details: The exports section in the package.json was updated to include a dedicated path for the models directory:

"exports": {
  ".": {
    "require": "./dist/index.cjs",
    "import": "./dist/index.js",
    "types": "./dist/index.d.ts"
  },
  "./models": {
    "require": "./dist/models/index.cjs",
    "import": "./dist/models/index.js",
    "types": "./dist/models/index.d.ts"
  }
}

This addition ensures that the various models can now be imported using a simplified syntax and are compatible with different module systems. The following import variants can now be used:

  1. ES Modules:

    import {
     bradleyTerryFull,
     bradleyTerryPart,
     plackettLuce,
     thurstoneMostellerFull,
     thurstoneMostellerPart
    } from "openskill/models";
  2. CommonJS (Require Syntax):

    const {
     bradleyTerryFull,
     bradleyTerryPart,
     plackettLuce,
     thurstoneMostellerFull,
     thurstoneMostellerPart
    } = require("openskill/models");
  3. TypeScript Imports:

    import type {
     bradleyTerryFull,
     bradleyTerryPart,
     plackettLuce,
     thurstoneMostellerFull,
     thurstoneMostellerPart
    } from "openskill/models";

Impact: This enhancement provides a more convenient and modular import path, allowing users to access the rating models independently from the main library, improving usability and maintaining compatibility with various module systems.

eddyfidel commented 1 month ago

Hi @philihp, please when you get a chance review this PR and let me know if I'm missing something or all good, thanks!

philihp commented 1 month ago

Thank you so much for providing this fix! Apologies for the mistake, this is great work :)

coveralls commented 1 month ago

Coverage Status

coverage: 100.0%. remained the same when pulling 4100e8b0125afb85ccdda5f2e87cc0c45b1c8f79 on eddyfidel:feature/missing-models-export into 4f78c217425f0d48182ab6f0e7a135cbb495c821 on philihp:main.