forked from rnag/rust.aws-cdk-lambda
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
v1.2.0: add "skip build" option and functionality (rnag#14)
* package version updates * allow options to skip build step * fix so we don't build when `cdk destroy` etc. is run * update Settings with `SKIP_BUILD` * check for `build` context value passed when invoking `cdk` * update sample CDK apps to use `swc` when deploying `cdk` -- minor optimization * update docs * update CHANGELOG.md etc * Update CHANGELOG.md * update docs
- Loading branch information
Showing
21 changed files
with
21,306 additions
and
21,510 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -64,6 +64,8 @@ echo '\n# Rust lambda build directory\n.build' >> .gitignore | |
|
||
## Local Development and Testing | ||
|
||
> _Note_: See the [New Approach](#new-approach) below which obviates the need to update the `import` statements. | ||
In case it's desirable to uncomment the following import in the `lib/` folder of a sample CDK app, for local testing purposes: | ||
|
||
```ts | ||
|
@@ -87,3 +89,53 @@ For example, here are the important ones you'd need to verify: | |
├── [email protected] | ||
├── [email protected] | ||
``` | ||
|
||
### New Approach | ||
|
||
As per [this article](https://stackoverflow.com/a/18778516/10237506) I found that explains how a local module can be installed with `npm link`, this is a slightly different approach to commenting out and then un-commenting an `import` statement as mentioned above. | ||
|
||
This does also have a few unavoidable side-effects, but hopefully such a method should yield an overall better (developer) experience. | ||
|
||
Here then, is the updated approach which leverages `npm link` under the hood to locally install an NPM module. | ||
|
||
First, `cd` into the local directory of a sample CDK app. | ||
|
||
Within this folder, run the npm script `link` (alias: `l`) to automatically link to the local `rust.aws-cdk-lambda` module -- i.e. the project folder two levels up: | ||
|
||
```shell | ||
npm run l | ||
``` | ||
|
||
If all is well, you should see that the _linking_ is successful. | ||
|
||
To confirm: | ||
|
||
```shell | ||
npm list | ||
``` | ||
|
||
The result should be something like: | ||
|
||
```plaintext | ||
... | ||
├── [email protected] -> ./../.. | ||
... | ||
``` | ||
|
||
That means everything is set up correctly! CDK code should reference the definitions under `../../dist/`, i.e. under the root folder. | ||
|
||
Next -- open a new terminal window, and from the project root folder `$root`, run the following command: | ||
|
||
```shell | ||
npm run watch | ||
``` | ||
|
||
This will listen for any changes to the project TypeScript code, and automatically run `tsc` to down-compile it to JS code, which it places in the `dist/` folder. | ||
|
||
These changes will also be reflected in the sample CDK project, thanks to `npm link` which was run earlier. | ||
|
||
To _unlink_ the local module and use the remote one installed as a dependency listed in the `package.json`, simply run the following from the root of a sample CDK app: | ||
|
||
```shell | ||
npm run ul | ||
``` |
Oops, something went wrong.