synergy-design-system / synergy-design-system

Monorepo for the Synergy Design System.
https://synergy-design-system.github.io/
MIT License
18 stars 1 forks source link

fix: 🐛 Better tooling compatability in package.json #594

Open j-o-sh opened 2 months ago

j-o-sh commented 2 months ago

Checklist (for the issue creator)

Version

The bug occurred with the following version of the component library: 2.4.3

Component

The issue arises when using the following component(s):

package.json

Environment

When building a depending application with eslint

Description

Eslint uses thenexports field of any packages to find declarations that an app may have imported and reports findings as a violation to the import/no-unresolved rule.

Unfortunatelly (at least in our version of eslint which is 8.22.0) it seems that eslint is not able to follow the exports/importfield as defined in the synergy components package:

  "exports": {
    ".": {
      "types": "./dist/synergy.d.ts",
      "import": "./dist/synergy.js"
    },
    "./custom-elements.json": "./dist/custom-elements.json",
    "./synergy.js": "./dist/synergy.js",
    "./synergy-autoloader.js": "./dist/synergy-autoloader.js",
    "./components/*": "./dist/components/*",
    "./utilities/*": "./dist/utilities/*",
    "./styles/*": "./dist/styles/*",
    "./themes/utility.css": "./dist/styles/utility.css",
    "./themes/*": "./dist/themes/*",
    "./translations/*": "./dist/translations/*",
    "./index.css": "./dist/styles/index.css"
  },

I already tried playing with this locally and it seems that it would be save to simply have a duplicate of your import field as default without breaking never tooling. This would allowed for older tooling to still find the correct exports:

"exports": {
    ".": {
      "types": "./dist/synergy.d.ts",
      "import": "./dist/synergy.js",
      "default": "./dist/synergy.js"
    },

Is this possible?

Acceptance criteria

schilchSICKAG commented 2 months ago

See https://github.com/import-js/eslint-plugin-import/issues/2495 for a reason for the problem. @kirchsuSICKAG: I think we could savely add this, should not have any side effects