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

Do not publish *.ts file on NPM #5984

Open
Xample opened this issue May 13, 2024 · 8 comments
Open

Do not publish *.ts file on NPM #5984

Xample opened this issue May 13, 2024 · 8 comments
Labels

Comments

@Xample
Copy link

Xample commented May 13, 2024

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

pubkey commented May 13, 2024

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

jwallet commented May 13, 2024

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

Xample commented May 14, 2024

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

pubkey commented May 15, 2024

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

jwallet commented May 15, 2024

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

image

@pubkey
Copy link
Owner

pubkey commented May 15, 2024

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

Xample commented May 15, 2024

and I'm not using vscode on my side

Copy link

stale bot commented May 22, 2024

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 stale bot added the stale label May 22, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants