-
Notifications
You must be signed in to change notification settings - Fork 29
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
Distribute package as source #213
Conversation
Codecov Report
@@ Coverage Diff @@
## master #213 +/- ##
=========================================
Coverage 100.00% 100.00%
=========================================
Files 27 27
Lines 512 512
=========================================
Hits 512 512
Flags with carried forward coverage won't be shown. Click here to find out more. Continue to review full report at Codecov.
|
We can take this approach to the whole family of Sinon libraries and for Adopting this approach would make it easier to adopt JSDoc to create API docs and |
@mshaaban0 would you mind taking this for a spin in a TypeScript project to see if the type hints are still working? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This setup means that we have to run npm run build
to have the source files in the right place when linking locally. I'm wondering if it wouldn't be better to keep everything in lib
and ship the generated type definitions in a typings
folder instead of merging everything in dist
. This isn't a TypeScript project after all, we just want to ship types along with the library. WDYT?
Do you mean when using it with |
Yes. And generally, I'm not sure the copy step is needed. Type definitions don't have to sit next to the implementation, AFAIK. |
If they don't, then we could distribute a @mshaaban0 what do you think? Do the types have to sit next to the source files? |
These options suggest that we could easily put the output somewhere else. I'll try updating the PR and @mshaaban0 can help verify that it's still working well. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This library is not meant for writing end user applications or even for being used directly when writing tests. It is not meant to be loaded directly by browsers. Consumers of this package are assumed to use their own bundlers, should they need to bundle code for use in browsers or workers. Therefore, it is safe to distribute the package as source files and not bundle them up. This allows us to remove the bundler and its transitive dependencies, which reduces the maintenance burden of managing the library.
3666ece
to
94db34d
Compare
@hexeberlin and I have pushed new commits for this, using the @mshaaban0 would you mind doing the test again? ❤️ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Works, thank you 👍
This has been published to the npm registry as |
@khamiltonuk and I spent some time trying to replace
rollup
withesbuild
only to discover that it drops comments. That would bundling withesbuild
and providing.d.ts
files mutually exclusive.I realised that we don't actually need bundling at all in this project.
This library is not meant for writing end user applications or even for being used directly when writing tests. It is not meant to be loaded directly by browsers.
Consumers of this package are assumed to use their own bundlers, should they need to bundle code for use in browsers or workers.
Therefore, it is safe to distribute the package as source files and not bundle them up.
This allows us to remove the bundler and its transitive dependencies, which reduces the maintenance burden of managing the library.
Background
.d.ts
files, to allow improved experience for TypeScript usersSolution
.d.ts
files from the source filesHow to verify
npm ci
npm run build
.d.ts
files in thetypes/
foldernpm pack
.d.ts
files are included in the packagenpm link
sinon
checkout:npm link @sinonjs/samsam
npm test