pubkey / rxdb

A fast, local first, reactive Database for JavaScript Applications https://rxdb.info/
https://rxdb.info/
Apache License 2.0
21.12k stars 1.03k forks source link

Do not publish *.ts file on NPM #5984

Closed Xample closed 2 months ago

Xample commented 3 months ago

Hi, as .ts source files might be imported by mistake (often because of webstorm or VS but not only) it is generally considered a good practice not to include them into the NPM package.

I spent a few minutes searching for the faulty import into my code, I ended up deleting the "rxdb/src" folder to refine the search which directly lead me to the faulty import.

pubkey commented 3 months ago

When you delete the src folder, which import suggestions does your IDE give you? Are they correct or are they from the dist-folder?

jwallet commented 3 months ago

you can in the meantime prevent it with eslint

"no-restricted-imports": [
  "error",
  {
    "patterns": [
      {
        "group": [
          "rxdb/src/**"
        ],
        "message": "RxDB src imports are not allowed"
      },
    ],
  }
]
Xample commented 3 months ago

Before deleting:

image

none is correct.

After deleting I've a mix of 'rxdb' and 'rxdb/dist/types/types' for instance this is what is automatically imported

import {
  MangoQuerySelector,
  MangoQuerySortDirection,
  MangoQuerySortPart,
} from 'rxdb/dist/types/types';
import { MangoQuery } from 'rxdb';

I manually had to change to

import {
    MangoQuery,
    MangoQuerySelector,
    MangoQuerySortDirection,
    MangoQuerySortPart,
} from 'rxdb';

To get the imports from the main 'rxdb' bucket properly.

pubkey commented 3 months ago

Hmm, so the default import would not be correct anyway, no matter if the src folder is in the package or not. I do not want it to remove it in that case.

There are the correct exports listed in the package.json and I am hoping that the IDEs use that in the future.

jwallet commented 3 months ago

It looks like you are using WebStorm, can you try your repo in vscode cause you should have it like so

image

pubkey commented 3 months ago

I do not have Webstorm, only vscode and there the import suggestions are wrong, both with and without having the src folder. I tried several things like removing legacy main/module fields but that did not help.

Xample commented 3 months ago

and I'm not using vscode on my side

stale[bot] commented 3 months ago

This issue has been automatically marked as stale because it has not had recent activity. It will be closed soon. Please update it or it may be closed to keep our repository organized. The best way is to add some more information or make a pull request with a test case. Also you might get help in fixing it at the RxDB Community Chat If you know you will continue working on this, just write any message to the issue (like "ping") to remove the stale tag.

stale[bot] commented 2 months ago

Issues are autoclosed after some time. If you still have a problem, make a PR with a test case or to prove that you have tried to fix the problem.