swagger icon indicating copy to clipboard operation
swagger copied to clipboard

refactor(main) Added main and types entries to package.json…

Open boenrobot opened this issue 4 years ago • 2 comments

Added main and types entries to package.json, and removed index.ts and plugin.ts files from repo root (as they were merely pointers to those files).

PR Checklist

Please check if your PR fulfills the following requirements:

  • [x] The commit message follows our guidelines: https://github.com/nestjs/nest/blob/master/CONTRIBUTING.md
  • [x] Tests for the changes have been added (for bug fixes / features) (no new tests required; existing tests pass)
  • [N/A] Docs have been added / updated (for bug fixes / features)

PR Type

What kind of change does this PR introduce?

[ ] Bugfix
[ ] Feature
[ ] Code style update (formatting, local variables)
[x] Refactoring (no functional changes, no api changes)
[ ] Build related changes
[ ] CI related changes
[ ] Other... Please describe:

What is the current behavior?

There are index.ts and plugin.ts files in the repo root, but they are out of the scope of tsconfig.json, meaning they don't get compiled into .js files.

Issue Number: N/A

What is the new behavior?

/dist/index.js is set as main in package.json. This removes the need for the index.ts at the repo root. Since plugin is a folder inside /dist and has its own index, there's also no need for plugin.ts anymore.

Does this PR introduce a breaking change?

[ ] Yes
[x] No

Not unless someone has explicitly added a ".ts" extension in their plugin reference. If not using an extension, the change from a ".ts" file to a folder containing an index should be invisible.

Other information

boenrobot avatar Jan 14 '20 15:01 boenrobot

Nest CLI plugin resolves plugins by exact paths. Hence, removing plugin related files from the root will break it.

kamilmysliwiec avatar Jan 18 '20 09:01 kamilmysliwiec

This seems like an oversight on nest-cli's side. I've made nestjs/nest-cli#538 to make it use use node's internal resolution, same as tsc when it loads plugins, and as the average node user would expect.

Tbh, I don't use nest-cli's compilation capabilities, which is why I didn't noticed earlier. I use tsc directly, and use nest-cli just for the generate command.

boenrobot avatar Jan 21 '20 18:01 boenrobot