Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
bradkovach opened this issue Aug 3, 2023 · 1 comment
Open

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

bradkovach opened this issue Aug 3, 2023 · 1 comment

Comments

@bradkovach
Copy link

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
Copy link

Any update on the PR ?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants