-
Notifications
You must be signed in to change notification settings - Fork 27
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
To solve the npm package size issue #252
Conversation
This pull request introduces 2 alerts when merging 83fb37d into e9bd55f - view on LGTM.com new alerts:
|
scripts/build.js
Outdated
// There is no native code, we are not building from source. | ||
(async () => { | ||
// AWS common runtime aws-crt-nodejs cloudfront distribution. | ||
const url = "http://d332vdhbectycy.cloudfront.net/"; |
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.
We can use github release asset instead of cloudfront deployment when we release. But, AWS is easier to test for now.
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.
Seems reasonable but unless I'm missing something we should test this cloudfront-sourced build on all three platforms just as a sanity check.
It's a bit tricky to test it. What I did is download the packed tarball from
I tested it on mac manually, and it works. I can test it on linux and windows for sure. |
README.md
Outdated
@@ -40,6 +40,8 @@ You can either add it to package.json (if using a tool like webpack), or just im | |||
npm install aws-crt | |||
``` | |||
|
|||
To reduce the size of package, we put the C source code in the S3 bucket. If the platform you are using doesn't have the prebuilt binary, npm will pull the source from S3 bucket. In case, you don't have the public internet, you can specify the "CRT_SOURCE_CODE_HOST" environment variable for the host of the source code. The build script will fetch source code from that host instead. To fetch the source from S3, you can reach to the cloudfront distribution (Only works for version after v1.9.2) `https://d332vdhbectycy.cloudfront.net/aws-crt-<version>-source.tgz`, the sha256 checksum `https://d332vdhbectycy.cloudfront.net/aws-crt-<version>-source.sha256` |
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.
couple things:
- Let's do "BINARY_HOST" instead of "SOURCE_CODE_HOST" since we know we'll be putting binaries there too soon enough. I mean, hey, .tgz files are binaries whether or not they have source code 😬
- Looks like there is some precedent for letting users customize the host, and it's via the
.npmrc
file, with a variable likeaws_crt_binary_host
, instead of an environment variable
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.
lol, I was confused by the "binary" as those ".node" files are things we talked about a lot.
scripts/build.js
Outdated
const version = package["version"]; | ||
fetch_native_code(url, version, tmp_path).then(() => { | ||
// Clean up temp directory | ||
fs.rmSync(tmp_path, { recursive: true }); |
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.
to be improved in the future: probably better to cache the download, but then we'd need integrity checks to ensure the cached version is good, so this works for now. Here's prebuild-install explaining their caching strategy
This pull request introduces 1 alert when merging 967aa2f into e9bd55f - view on LGTM.com new alerts:
|
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.
Looks good generally, left a few comments
# now get the tag | ||
CURRENT_TAG=$(git describe --tags | cut -f2 -dv) | ||
# convert v0.2.12-2-g50254a9 to 0.2.12 | ||
CURRENT_TAG_VERSION=$(git describe --tags | cut -f1 -d'-' | cut -f2 -dv) |
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.
May be check if the tagged commit at current head? This can prevent updating binaries without bumping versions.
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.
I removed a check that was there for testing. Added it back to check if the tag is release. So, in that case, we can prevent updating binaries without proper release, which will also prevent the version is not updated, I think.
@@ -47,6 +47,7 @@ | |||
"crypto-js": "^4.0.0", | |||
"fastestsmallesttextencoderdecoder": "^1.0.22", | |||
"mqtt": "^4.2.8", | |||
"tar": "^6.1.11", |
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.
We saw customer complaining of the deprecated dependencies too, are those tackled already?
aws/aws-sdk-js-v3#2750
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.
I saw those warnings as well, don't know how to solve them... npm update
and npm audit fix
is not helping... But, we can probably tackle them after
Issue #, if available:
Description of changes:
By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.