ietf-language-tags icon indicating copy to clipboard operation
ietf-language-tags copied to clipboard

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

Open bradkovach opened this issue 1 year ago • 1 comments

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"
}

bradkovach avatar Aug 03 '23 20:08 bradkovach