spencermountain / compromise

modest natural-language processing
http://compromise.cool
MIT License
11.49k stars 655 forks source link

Unable to import this into an ESM project #1153

Closed Stono closed 1 month ago

Stono commented 1 month ago

Hey, My app is ESM for starters (yay, the pain) and i'm trying to import the module. It fails, however:

Screenshot 2024-10-15 at 19 45 04

There are types at '/Users/karl.stoney/git/autotrader/ai-gateway/node_modules/compromise-speech/index.d.ts', but this result could not be resolved when respecting package.json "exports". The 'compromise-speech' library may need to update its package.json or typings.

I believe all it needs is for types to be added to the exports:

  "exports": {
    ".": {
      "import": "./src/plugin.js",
      "require": "./builds/compromise-speech.cjs",
      "types": "./index.d.ts"
    }
  },
Stono commented 1 month ago

Apologies i wasn't clear, this was for compromise-speech

spencermountain commented 1 month ago

hey Karl - thanks for the heads up. The esm build should work - happy to make a change https://github.com/spencermountain/compromise/blob/master/plugins/speech/package.json maybe my eyes are going blurry, but isn't that the same exports info, as you suggested? PR welcome, if you can spot a change cheers

Stono commented 1 month ago

That is so odd.... this is the content of it in my node_modules folder!:

Screenshot 2024-10-15 at 20 19 49

Installed from here: https://www.npmjs.com/package/compromise-speech

Stono commented 1 month ago

Not here either: https://www.npmjs.com/package/compromise-speech/v/0.1.0?activeTab=code

spencermountain commented 1 month ago

thanks, that is weird. I can do a dummy release for the plugin tomorrow, and see if that helps. cheers

Stono commented 1 month ago

👍 Thanks for the quick replies!

spencermountain commented 1 month ago

looks like it was my bad, and they appear to be there now in 0.1.1 thanks for the help cheers