rxdb icon indicating copy to clipboard operation
rxdb copied to clipboard

Do not publish *.ts file on NPM

Open Xample opened this issue 1 year ago • 8 comments

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.

Xample avatar May 13 '24 13:05 Xample

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

pubkey avatar May 13 '24 14:05 pubkey

you can in the meantime prevent it with eslint

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

jwallet avatar May 13 '24 15:05 jwallet

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.

Xample avatar May 14 '24 05:05 Xample

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.

pubkey avatar May 15 '24 13:05 pubkey

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

image

jwallet avatar May 15 '24 14:05 jwallet

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.

pubkey avatar May 15 '24 15:05 pubkey

and I'm not using vscode on my side

Xample avatar May 15 '24 15:05 Xample

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] avatar May 22 '24 17:05 stale[bot]

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.

stale[bot] avatar Jun 12 '24 20:06 stale[bot]