sozialhelden / ietf-language-tags

An NPM module that helps you working with IETF language tags as specified by BCP 47 / RFC 5646.
Other
21 stars 1 forks source link

package.json has broken links for `module` and `types` property #17

Open bradkovach opened 11 months ago

bradkovach commented 11 months ago

TypeScript fails to work properly with this package at the moment because the module and types property of the distributed package.json are pointing to non-existent properties.

(PR to come later)

Workarounds

Add a (temporary) path binding to the proper file

When you upgrade your packages later on, this shouldn't break anything, and requires no modification of your code or the installed package.

{
  "compilerOptions": {
    "module": "commonjs",
    "target": "es6",
    "outDir": "dist",
    "rootDir": ".",
    "sourceMap": true,
    "strict": false,
    "esModuleInterop": true,
    "paths": {
      "@sozialhelden/ietf-language-tags": [
        "./node_modules/@sozialhelden/ietf-language-tags/dist/esm/index.js"
      ],
    }
  }
}

Reference the esm module directly from your code

This has the undesirable side effect of adding many ../../ to your code...

import {
    normalizeLanguageTagCasing,
    parseLanguageTag,
} from '../../node_modules/@sozialhelden/ietf-language-tags/dist/esm/';

Update the installed package

If you update node_modules/@sozialhelden/ietf-language-tags/package.json to use the esm outputs, typescript works properly, but this affects the ability to use npm install, so it may not be preferable, esp in CI/CD environments.

{
   "module": "dist/esm/index.js",
   "types": "./dist/esm/index.d.ts"
}
ArthurKnoep commented 6 months ago

Any update on the PR ?