Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This PR leaves the bundle exactly identical as the one we're currently generating, but brings some improvements to the way we were bundling the SDK:
Bundling changes
The
external
packages are now all taken from package.jsondependencies
field. The only exception is@vocdoni/proto/vocdhain
, since the import does not match with the field in package.json.Other than that, right now deciding if a dependency should be bundled or not is just a matter of placing it in
devDependencies
ordependencies
.Also, sourcemap generation has been set to be only done if
NODE_ENV == 'development'
, since the final npm package should not have sourcemaps. Rollup.js' documentation is not very clear about what node env is being used during--watch
mode, so right now it may be causing the same effect as having it set tofalse
.Entry point changes
The entry point has been changed to
src/index.ts
. This is done this way because, while developing, having the typescript as an entry point allows us to link the SDK to other projects and directly make changes to the SDK without requiring us to build in-between. This, of course, requires the end-developer to be bundling with something that is typescript compatible.Since we don't need to build in-between anymore, the
prepare
npm script has been removed too.To properly have the entry points defined for the npm package, a
prepack
script callingclean-package
has been added. This script will ensure to modify the package.json file and add the entries required to access the bundled packages (exactly as we had it).Note: due to this
prepack
script, runningyarn pack
locally will result in a modified package.json that should not be committed, ever. Apostpack
script will ensure to leave your package.json file like it was before the pack process.Things I think this PR may address
We had issues in the past dealing with packages like axios, and I think that was due to the confusing way we were defining external packages, and because we were (accidentally) trying to bundle it into our SDK. Axios should not be bundled into our final package, instead, it should be defined as a dependency. Doing it this way, and given the changes done to the bundling configuration, this package shouldn't give any problems whatsoever.
Note:
peerDependencies
were not considered into the bundling because we're not using them here (and I don't see a reason for it tbh).Why draft?
Because everything I've said is right except for the UMD/IIFE package (we're only bundling a UMD package). The idea behind a UMD package is that it should work without other external dependencies, so I should properly check it's being built that way. We can also consider dumping this version for now, since it doesn't seem to be a real need from the community for it.