Open mikkel-arturo opened 3 years ago
If size is the main issue, you should really just look into trace mode, which doesn't need any special config for yarn workspaces (other than maybe symlinks which should work fine). You would remove the **/dist/**
package include and just let Jetpack trace dist/stripe-webhook
code and other handlers directly.
Best bet if you're spinning your wheels is if you can get me a public skeleton repository and then I could tweak your config in a PR / diff to tune it.
Here's a good reference configuration using trace mode: https://github.com/FormidableLabs/aws-lambda-dogs/blob/main/serverless.yml
Good luck!
Thanks @ryan-roemer I'll have a try with a skeleton repo tomorrow.
It's clear why size is the issue - it's including aws-sdk and other dev dependencies, even though I have them to not be included (both using ! and also I've tried under exclude).
Ok using trace, this is the best I've gotten: https://github.com/mikkel-pearl/jetpack-test
Service 2 references a function in Service1 and it gives the error Error: Cannot find module '@jetpack-test/service1'
I've tried adding ../service1
to roots but that doesn't seem to be helping.
Any advice? (Also on a side note, I've noticed that it looks like jetpack doesn't support Typescript path aliasing - is that right?(
So you're using legacy mode, which like normal serverless infers dependencies off reading your package.json
. You haven't added @jetpack-test/service1
as a dependency in packages/service2/package.json
.
Also, as a side note, it's best to run serverless from the root of the repo if possible as there are lot of gotchas with having deps below CWD -- see: https://github.com/FormidableLabs/serverless-jetpack#packaging-files-outside-cwd generally. However, Jetpack does support it. But things like package.include
globbing patterns need special extra work to work.
My current working diff that I think does what you want:
diff --git a/packages/service2/package.json b/packages/service2/package.json
index 0c6be05..c55552d 100644
--- a/packages/service2/package.json
+++ b/packages/service2/package.json
@@ -6,9 +6,13 @@
"scripts": {
"build": "npx tsc --project ../service1/tsconfig.json && npx tsc"
},
+ "dependencies": {
+ "@jetpack-test/service1": "*"
+ },
"devDependencies": {
"@types/aws-lambda": "^8.10.81",
"aws-lambda": "^1.0.6",
+ "serverless": "^2.52.1",
"serverless-jetpack": "^0.11.1",
"tsconfig-paths": "^3.10.1",
"typescript": "^4.3.5"
diff --git a/packages/service2/serverless.yml b/packages/service2/serverless.yml
index c3b985c..ae3e8cb 100644
--- a/packages/service2/serverless.yml
+++ b/packages/service2/serverless.yml
@@ -7,8 +7,24 @@ useDotenv: true
frameworkVersion: '2'
package:
include:
+ # Step 2: Service-level configurations
+ #
+ # **NOTE**: When globbing _below_ CWD you need to add a separate pattern
+ # in addition to a normal `**` which won't reach below CWD.
+ #
+ # E.g. for just `aws-sdk`, we need:
+ - "!../../node_modules/aws-sdk/**"
- "!**/node_modules/aws-sdk/**"
+ # Step 3: All the function-level files you need to include.
+ #
+ # I've separated this here because if you have multiple functions, you
+ # would switch to `package.individually = true` and then move this into
+ # `function.{NAME}.package.include`
+ #
+ # Add more for this function here!
+ - "dist/**/*.js"
+
custom:
scriptHooks:
# These are all the places that jetpack could be invoked that would
@@ -16,11 +32,16 @@ custom:
before:package:createDeploymentArtifacts: yarn build
before:package:function:package: yarn build
before:jetpack:package:package: yarn build
+
jetpack:
# Search for hoisted dependencies to one parent above normal.
base: "../.."
- roots:
- - "../service1"
+ preInclude:
+ # Step 1: Start with no files at all.
+ # Serverless by default includes all `**` to start. This custom
+ # Jetpack configuration allows us to override it for a slimmer
+ # starting point.
+ - "!**"
plugins:
- serverless-jetpack
@@ -45,4 +66,4 @@ functions:
- http:
path: '/service2'
method: GET
- cors: true
\ No newline at end of file
+ cors: true
When I build, I use Jetpack's --report
feature to also dump out a report with more insight into the patterns that are actually applying and what ends up in the zip. Very useful for debugging!
Here's a sample run:
$ cd packages/service2
$ yarn serverless --stage dev jetpack package --report
And here's the output as of my diff:
Serverless: [serverless-jetpack] Packaging 0 functions, 1 services, and 0 layers with concurrency 1
Serverless: [serverless-jetpack] Packaged service (dependency mode): .serverless/test.zip (0.47s)
Serverless: [serverless-jetpack]
# Jetpack Bundle Report
## test.zip
- Path: /Users/rye/scm/vendor/jetpack-test/packages/service2/.serverless/test.zip
- Mode: dependency
- Roots: (None)
### Tracing: Configuration
# Ignores (`0`):
# Allowed Missing (`0`):
### Patterns: Include
# Automatically added
- '**'
# Jetpack (`1`): `custom.jetpack.preInclude` + `function.{NAME}.jetpack.preInclude`
- '!**'
# Jetpack (`59`): dependency filtering mode additions
- '!node_modules/**'
- '!node_modules/**'
- '../../node_modules/.bin/esparse'
- '../../node_modules/.bin/esvalidate'
- '../../node_modules/.bin/js-yaml'
- '../../node_modules/.bin/lambda'
- '../../node_modules/.bin/uuid'
- '../../node_modules/@jetpack-test/service1/**'
- '!../../node_modules/@jetpack-test/service1/node_modules/**'
- '../../node_modules/argparse/**'
- '!../../node_modules/argparse/node_modules/**'
- '../../node_modules/aws-lambda/**'
- '!../../node_modules/aws-lambda/node_modules/**'
- '../../node_modules/aws-sdk/**'
- '!../../node_modules/aws-sdk/node_modules/**'
- '../../node_modules/aws-sdk/node_modules/buffer/**'
- '!../../node_modules/aws-sdk/node_modules/buffer/node_modules/**'
- '../../node_modules/aws-sdk/node_modules/buffer/node_modules/ieee754/**'
- '!../../node_modules/aws-sdk/node_modules/buffer/node_modules/ieee754/node_modules/**'
- '../../node_modules/aws-sdk/node_modules/ieee754/**'
- '!../../node_modules/aws-sdk/node_modules/ieee754/node_modules/**'
- '../../node_modules/aws-sdk/node_modules/uuid/**'
- '!../../node_modules/aws-sdk/node_modules/uuid/node_modules/**'
- '../../node_modules/base64-js/**'
- '!../../node_modules/base64-js/node_modules/**'
- '../../node_modules/commander/**'
- '!../../node_modules/commander/node_modules/**'
- '../../node_modules/esprima/**'
- '!../../node_modules/esprima/node_modules/**'
- '../../node_modules/events/**'
- '!../../node_modules/events/node_modules/**'
- '../../node_modules/glob-to-regexp/**'
- '!../../node_modules/glob-to-regexp/node_modules/**'
- '../../node_modules/graceful-fs/**'
- '!../../node_modules/graceful-fs/node_modules/**'
- '../../node_modules/isarray/**'
- '!../../node_modules/isarray/node_modules/**'
- '../../node_modules/jmespath/**'
- '!../../node_modules/jmespath/node_modules/**'
- '../../node_modules/js-yaml/**'
- '!../../node_modules/js-yaml/node_modules/**'
- '../../node_modules/querystring/**'
- '!../../node_modules/querystring/node_modules/**'
- '../../node_modules/sax/**'
- '!../../node_modules/sax/node_modules/**'
- '../../node_modules/sprintf-js/**'
- '!../../node_modules/sprintf-js/node_modules/**'
- '../../node_modules/url/**'
- '!../../node_modules/url/node_modules/**'
- '../../node_modules/url/node_modules/punycode/**'
- '!../../node_modules/url/node_modules/punycode/node_modules/**'
- '../../node_modules/watchpack/**'
- '!../../node_modules/watchpack/node_modules/**'
- '../../node_modules/xml2js/**'
- '!../../node_modules/xml2js/node_modules/**'
- '../../node_modules/xml2js/node_modules/sax/**'
- '!../../node_modules/xml2js/node_modules/sax/node_modules/**'
- '../../node_modules/xmlbuilder/**'
- '!../../node_modules/xmlbuilder/node_modules/**'
# Jetpack (`0`): trace mode additions
# Serverless (`3`): `package.include` + `function.{NAME}.package.include` + internal extras
- '!../../node_modules/aws-sdk/**'
- '!**/node_modules/aws-sdk/**'
- 'dist/**/*.js'
### Patterns: Exclude
# Serverless (`8`): `package.exclude` + `function.{NAME}.exclude` + internal extras
- '.git/**'
- '.gitignore'
- '.DS_Store'
- '.serverless/**'
- '.serverless_plugins/**'
- 'npm-debug.log*'
- 'yarn-error.log*'
- '/Users/rye/scm/vendor/jetpack-test/packages/service2/.serverless_plugins'
### Files (`284`): Included
- ../../node_modules/.bin/esparse
- ../../node_modules/.bin/esvalidate
- ../../node_modules/.bin/js-yaml
- ../../node_modules/.bin/lambda
- ../../node_modules/.bin/uuid
- ../../node_modules/@jetpack-test/service1/dist/index.d.ts
- ../../node_modules/@jetpack-test/service1/dist/index.js
- ../../node_modules/@jetpack-test/service1/dist/index.js.map
- ../../node_modules/@jetpack-test/service1/dist/src/func1.d.ts
- ../../node_modules/@jetpack-test/service1/dist/src/func1.js
- ../../node_modules/@jetpack-test/service1/dist/src/func1.js.map
- ../../node_modules/@jetpack-test/service1/dist/tsconfig.tsbuildinfo
- ../../node_modules/@jetpack-test/service1/index.ts
- ../../node_modules/@jetpack-test/service1/package.json
- ../../node_modules/@jetpack-test/service1/src/func1.ts
- ../../node_modules/@jetpack-test/service1/tsconfig.json
- ../../node_modules/argparse/CHANGELOG.md
- ../../node_modules/argparse/LICENSE
- ../../node_modules/argparse/README.md
- ../../node_modules/argparse/index.js
- ../../node_modules/argparse/lib/action.js
- ../../node_modules/argparse/lib/action/append.js
- ../../node_modules/argparse/lib/action/append/constant.js
- ../../node_modules/argparse/lib/action/count.js
- ../../node_modules/argparse/lib/action/help.js
- ../../node_modules/argparse/lib/action/store.js
- ../../node_modules/argparse/lib/action/store/constant.js
- ../../node_modules/argparse/lib/action/store/false.js
- ../../node_modules/argparse/lib/action/store/true.js
- ../../node_modules/argparse/lib/action/subparsers.js
- ../../node_modules/argparse/lib/action/version.js
- ../../node_modules/argparse/lib/action_container.js
- ../../node_modules/argparse/lib/argparse.js
- ../../node_modules/argparse/lib/argument/error.js
- ../../node_modules/argparse/lib/argument/exclusive.js
- ../../node_modules/argparse/lib/argument/group.js
- ../../node_modules/argparse/lib/argument_parser.js
- ../../node_modules/argparse/lib/const.js
- ../../node_modules/argparse/lib/help/added_formatters.js
- ../../node_modules/argparse/lib/help/formatter.js
- ../../node_modules/argparse/lib/namespace.js
- ../../node_modules/argparse/lib/utils.js
- ../../node_modules/argparse/package.json
- ../../node_modules/aws-lambda/ChangeLog
- ../../node_modules/aws-lambda/LICENSE
- ../../node_modules/aws-lambda/README.md
- ../../node_modules/aws-lambda/bin/lambda
- ../../node_modules/aws-lambda/lib/main.js
- ../../node_modules/aws-lambda/lib/schema.js
- ../../node_modules/aws-lambda/package.json
- ../../node_modules/base64-js/LICENSE
- ../../node_modules/base64-js/README.md
- ../../node_modules/base64-js/base64js.min.js
- ../../node_modules/base64-js/index.d.ts
- ../../node_modules/base64-js/index.js
- ../../node_modules/base64-js/package.json
- ../../node_modules/commander/CHANGELOG.md
- ../../node_modules/commander/LICENSE
- ../../node_modules/commander/Readme.md
- ../../node_modules/commander/index.js
- ../../node_modules/commander/package.json
- ../../node_modules/commander/typings/index.d.ts
- ../../node_modules/esprima/ChangeLog
- ../../node_modules/esprima/LICENSE.BSD
- ../../node_modules/esprima/README.md
- ../../node_modules/esprima/bin/esparse.js
- ../../node_modules/esprima/bin/esvalidate.js
- ../../node_modules/esprima/dist/esprima.js
- ../../node_modules/esprima/package.json
- ../../node_modules/events/.npmignore
- ../../node_modules/events/.travis.yml
- ../../node_modules/events/.zuul.yml
- ../../node_modules/events/History.md
- ../../node_modules/events/LICENSE
- ../../node_modules/events/Readme.md
- ../../node_modules/events/events.js
- ../../node_modules/events/package.json
- ../../node_modules/events/tests/add-listeners.js
- ../../node_modules/events/tests/check-listener-leaks.js
- ../../node_modules/events/tests/common.js
- ../../node_modules/events/tests/index.js
- ../../node_modules/events/tests/legacy-compat.js
- ../../node_modules/events/tests/listener-count.js
- ../../node_modules/events/tests/listeners-side-effects.js
- ../../node_modules/events/tests/listeners.js
- ../../node_modules/events/tests/max-listeners.js
- ../../node_modules/events/tests/modify-in-emit.js
- ../../node_modules/events/tests/num-args.js
- ../../node_modules/events/tests/once.js
- ../../node_modules/events/tests/remove-all-listeners.js
- ../../node_modules/events/tests/remove-listeners.js
- ../../node_modules/events/tests/set-max-listeners-side-effects.js
- ../../node_modules/events/tests/subclass.js
- ../../node_modules/glob-to-regexp/.travis.yml
- ../../node_modules/glob-to-regexp/README.md
- ../../node_modules/glob-to-regexp/index.js
- ../../node_modules/glob-to-regexp/package.json
- ../../node_modules/glob-to-regexp/test.js
- ../../node_modules/graceful-fs/LICENSE
- ../../node_modules/graceful-fs/README.md
- ../../node_modules/graceful-fs/clone.js
- ../../node_modules/graceful-fs/graceful-fs.js
- ../../node_modules/graceful-fs/legacy-streams.js
- ../../node_modules/graceful-fs/package.json
- ../../node_modules/graceful-fs/polyfills.js
- ../../node_modules/isarray/.npmignore
- ../../node_modules/isarray/.travis.yml
- ../../node_modules/isarray/Makefile
- ../../node_modules/isarray/README.md
- ../../node_modules/isarray/component.json
- ../../node_modules/isarray/index.js
- ../../node_modules/isarray/package.json
- ../../node_modules/isarray/test.js
- ../../node_modules/jmespath/.eslintrc
- ../../node_modules/jmespath/.npmignore
- ../../node_modules/jmespath/.travis.yml
- ../../node_modules/jmespath/BASELINE
- ../../node_modules/jmespath/Gruntfile.js
- ../../node_modules/jmespath/LICENSE
- ../../node_modules/jmespath/README.md
- ../../node_modules/jmespath/artifacts/jmespath.min.js
- ../../node_modules/jmespath/bower.json
- ../../node_modules/jmespath/g.sh
- ../../node_modules/jmespath/index.html
- ../../node_modules/jmespath/james.html
- ../../node_modules/jmespath/jmespath.js
- ../../node_modules/jmespath/jp.js
- ../../node_modules/jmespath/l.js
- ../../node_modules/jmespath/package.json
- ../../node_modules/jmespath/perf.js
- ../../node_modules/jmespath/reservedWords.json
- ../../node_modules/jmespath/test/compliance.js
- ../../node_modules/jmespath/test/compliance/basic.json
- ../../node_modules/jmespath/test/compliance/boolean.json
- ../../node_modules/jmespath/test/compliance/current.json
- ../../node_modules/jmespath/test/compliance/escape.json
- ../../node_modules/jmespath/test/compliance/filters.json
- ../../node_modules/jmespath/test/compliance/functions.json
- ../../node_modules/jmespath/test/compliance/identifiers.json
- ../../node_modules/jmespath/test/compliance/indices.json
- ../../node_modules/jmespath/test/compliance/literal.json
- ../../node_modules/jmespath/test/compliance/multiselect.json
- ../../node_modules/jmespath/test/compliance/pipe.json
- ../../node_modules/jmespath/test/compliance/slice.json
- ../../node_modules/jmespath/test/compliance/syntax.json
- ../../node_modules/jmespath/test/compliance/unicode.json
- ../../node_modules/jmespath/test/compliance/wildcard.json
- ../../node_modules/jmespath/test/jmespath.js
- ../../node_modules/js-yaml/CHANGELOG.md
- ../../node_modules/js-yaml/LICENSE
- ../../node_modules/js-yaml/README.md
- ../../node_modules/js-yaml/bin/js-yaml.js
- ../../node_modules/js-yaml/dist/js-yaml.js
- ../../node_modules/js-yaml/dist/js-yaml.min.js
- ../../node_modules/js-yaml/index.js
- ../../node_modules/js-yaml/lib/js-yaml.js
- ../../node_modules/js-yaml/lib/js-yaml/common.js
- ../../node_modules/js-yaml/lib/js-yaml/dumper.js
- ../../node_modules/js-yaml/lib/js-yaml/exception.js
- ../../node_modules/js-yaml/lib/js-yaml/loader.js
- ../../node_modules/js-yaml/lib/js-yaml/mark.js
- ../../node_modules/js-yaml/lib/js-yaml/schema.js
- ../../node_modules/js-yaml/lib/js-yaml/schema/core.js
- ../../node_modules/js-yaml/lib/js-yaml/schema/default_full.js
- ../../node_modules/js-yaml/lib/js-yaml/schema/default_safe.js
- ../../node_modules/js-yaml/lib/js-yaml/schema/failsafe.js
- ../../node_modules/js-yaml/lib/js-yaml/schema/json.js
- ../../node_modules/js-yaml/lib/js-yaml/type.js
- ../../node_modules/js-yaml/lib/js-yaml/type/binary.js
- ../../node_modules/js-yaml/lib/js-yaml/type/bool.js
- ../../node_modules/js-yaml/lib/js-yaml/type/float.js
- ../../node_modules/js-yaml/lib/js-yaml/type/int.js
- ../../node_modules/js-yaml/lib/js-yaml/type/js/function.js
- ../../node_modules/js-yaml/lib/js-yaml/type/js/regexp.js
- ../../node_modules/js-yaml/lib/js-yaml/type/js/undefined.js
- ../../node_modules/js-yaml/lib/js-yaml/type/map.js
- ../../node_modules/js-yaml/lib/js-yaml/type/merge.js
- ../../node_modules/js-yaml/lib/js-yaml/type/null.js
- ../../node_modules/js-yaml/lib/js-yaml/type/omap.js
- ../../node_modules/js-yaml/lib/js-yaml/type/pairs.js
- ../../node_modules/js-yaml/lib/js-yaml/type/seq.js
- ../../node_modules/js-yaml/lib/js-yaml/type/set.js
- ../../node_modules/js-yaml/lib/js-yaml/type/str.js
- ../../node_modules/js-yaml/lib/js-yaml/type/timestamp.js
- ../../node_modules/js-yaml/package.json
- ../../node_modules/querystring/.History.md.un~
- ../../node_modules/querystring/.Readme.md.un~
- ../../node_modules/querystring/.package.json.un~
- ../../node_modules/querystring/.travis.yml
- ../../node_modules/querystring/History.md
- ../../node_modules/querystring/License.md
- ../../node_modules/querystring/Readme.md
- ../../node_modules/querystring/decode.js
- ../../node_modules/querystring/encode.js
- ../../node_modules/querystring/index.js
- ../../node_modules/querystring/package.json
- ../../node_modules/querystring/test/.index.js.un~
- ../../node_modules/querystring/test/common-index.js
- ../../node_modules/querystring/test/index.js
- ../../node_modules/querystring/test/tap-index.js
- ../../node_modules/sax/LICENSE
- ../../node_modules/sax/LICENSE-W3C.html
- ../../node_modules/sax/README.md
- ../../node_modules/sax/lib/sax.js
- ../../node_modules/sax/package.json
- ../../node_modules/sprintf-js/.npmignore
- ../../node_modules/sprintf-js/LICENSE
- ../../node_modules/sprintf-js/README.md
- ../../node_modules/sprintf-js/bower.json
- ../../node_modules/sprintf-js/demo/angular.html
- ../../node_modules/sprintf-js/dist/angular-sprintf.min.js
- ../../node_modules/sprintf-js/dist/angular-sprintf.min.js.map
- ../../node_modules/sprintf-js/dist/angular-sprintf.min.map
- ../../node_modules/sprintf-js/dist/sprintf.min.js
- ../../node_modules/sprintf-js/dist/sprintf.min.js.map
- ../../node_modules/sprintf-js/dist/sprintf.min.map
- ../../node_modules/sprintf-js/gruntfile.js
- ../../node_modules/sprintf-js/package.json
- ../../node_modules/sprintf-js/src/angular-sprintf.js
- ../../node_modules/sprintf-js/src/sprintf.js
- ../../node_modules/sprintf-js/test/test.js
- ../../node_modules/url/.npmignore
- ../../node_modules/url/.travis.yml
- ../../node_modules/url/.zuul.yml
- ../../node_modules/url/LICENSE
- ../../node_modules/url/README.md
- ../../node_modules/url/node_modules/punycode/LICENSE-MIT.txt
- ../../node_modules/url/node_modules/punycode/README.md
- ../../node_modules/url/node_modules/punycode/package.json
- ../../node_modules/url/node_modules/punycode/punycode.js
- ../../node_modules/url/package.json
- ../../node_modules/url/test.js
- ../../node_modules/url/url.js
- ../../node_modules/watchpack/LICENSE
- ../../node_modules/watchpack/README.md
- ../../node_modules/watchpack/lib/DirectoryWatcher.js
- ../../node_modules/watchpack/lib/LinkResolver.js
- ../../node_modules/watchpack/lib/getWatcherManager.js
- ../../node_modules/watchpack/lib/reducePlan.js
- ../../node_modules/watchpack/lib/watchEventSource.js
- ../../node_modules/watchpack/lib/watchpack.js
- ../../node_modules/watchpack/package.json
- ../../node_modules/xml2js/LICENSE
- ../../node_modules/xml2js/README.md
- ../../node_modules/xml2js/lib/bom.js
- ../../node_modules/xml2js/lib/builder.js
- ../../node_modules/xml2js/lib/defaults.js
- ../../node_modules/xml2js/lib/parser.js
- ../../node_modules/xml2js/lib/processors.js
- ../../node_modules/xml2js/lib/xml2js.js
- ../../node_modules/xml2js/node_modules/sax/LICENSE
- ../../node_modules/xml2js/node_modules/sax/README.md
- ../../node_modules/xml2js/node_modules/sax/lib/sax.js
- ../../node_modules/xml2js/node_modules/sax/package.json
- ../../node_modules/xml2js/package.json
- ../../node_modules/xmlbuilder/.npmignore
- ../../node_modules/xmlbuilder/CHANGELOG.md
- ../../node_modules/xmlbuilder/LICENSE
- ../../node_modules/xmlbuilder/README.md
- ../../node_modules/xmlbuilder/lib/Utility.js
- ../../node_modules/xmlbuilder/lib/XMLAttribute.js
- ../../node_modules/xmlbuilder/lib/XMLCData.js
- ../../node_modules/xmlbuilder/lib/XMLComment.js
- ../../node_modules/xmlbuilder/lib/XMLDTDAttList.js
- ../../node_modules/xmlbuilder/lib/XMLDTDElement.js
- ../../node_modules/xmlbuilder/lib/XMLDTDEntity.js
- ../../node_modules/xmlbuilder/lib/XMLDTDNotation.js
- ../../node_modules/xmlbuilder/lib/XMLDeclaration.js
- ../../node_modules/xmlbuilder/lib/XMLDocType.js
- ../../node_modules/xmlbuilder/lib/XMLDocument.js
- ../../node_modules/xmlbuilder/lib/XMLDocumentCB.js
- ../../node_modules/xmlbuilder/lib/XMLElement.js
- ../../node_modules/xmlbuilder/lib/XMLNode.js
- ../../node_modules/xmlbuilder/lib/XMLProcessingInstruction.js
- ../../node_modules/xmlbuilder/lib/XMLRaw.js
- ../../node_modules/xmlbuilder/lib/XMLStreamWriter.js
- ../../node_modules/xmlbuilder/lib/XMLStringWriter.js
- ../../node_modules/xmlbuilder/lib/XMLStringifier.js
- ../../node_modules/xmlbuilder/lib/XMLText.js
- ../../node_modules/xmlbuilder/lib/XMLWriterBase.js
- ../../node_modules/xmlbuilder/lib/index.js
- ../../node_modules/xmlbuilder/package.json
- dist/index.js
- dist/src/func2.js
### Files (`0`): Excluded
### Tracing Dynamic Misses (`0` files): Sources
### Tracing Dynamic Resolved (`0` files): Sources
### Tracing Dynamic Misses (`0` packages): Dependencies
### Tracing Dynamic Resolved (`0` packages): Dependencies
### Collapsed (`0`): Sources
### Collapsed (`0`): Dependencies
Awesome! Thanks so much for getting back so quickly. That is superb.
I now have my test repo working and there is one last bit on my actual repo that is a blocker - which is the ts path aliases. I assume there isn't a clean way to incorporate these, so I've tried a wildcard under allowMissing but that doesn't seem to work:
trace:
allowMissing:
"@jetpack-test/service2":
- "@/**"
It does work if I fully qualify the path, but considering we use type aliasing for every single internal import that's not practical. Is there any way forward here?
If I can get this I'll definitely write a blog post about it and push to get jetpack to become the de facto way of bundling modern monorepos.
Can you update the test repo config and source to exhibit the same type of problem in your actual repo?
Is the resulting transpiled (dist) code actually runnable server-side by Node.js? In your “@jetpack-test/service1” example, that would be runnable in Node. The “@/service1” construct doesn’t look like valid Node code (because it’s a package that could not really exist). Jetpack is meant to package individual files that can run in a Node environment. Unfortunately it looks like your output (dist) code is not Node runnable and instead requires either a build step (webpack, etc) or a different runtime (ts-node, etc.)
If you have a scenario of actual Node runtime compatible files, please do update the example repo and I’ll dig back in!
Yes it is runnable in node with a little trick
I have pushed a commit that compiles and runs a plain node command. You can see it by doing yarn show
I know this is a bit of a stretch, but it looks like tsconfig-paths has gotten it working with various tools that use plain node through preregistering too.
I was concerned that tsconfig-paths was not used very much, but that's not the case:
Ah, so yeah a ts or Babel register actually patches how Node runtime works and are generally discouraged from production usage. (They not only change Node internals but add extra overhead as they mutate code at runtime).
I will take a take a look at your jetpack-test repo if you have an update for me to work with and see if I can get a hack or bandaid or something.
But I would also encourage you to consider transforming your final output code to something that works in straight node for perf and general tooling ease…
OK cool, I've found a different approach where it uses a transformer while compiling the typescript to js. I've just pushed a version using that - I think this should work!
Thanks for all your help
YES! It is working
Thank you for putting in all the time to figure this out with me. I spent over a week trying to get it to work and there are lots of people that have been trying to get similar setups going on the net, but nothing is consistently succeeding. I'll be sure to write this up and show how it's done.
Awesome! Looking forward to the write up.
And thanks for taking the time to push example code to jetpack-test
. Having something we can actually dig into makes debugging so much more tractable and efficient.
Hey there, Jetpack looks great and I am hoping to be able to use it after struggling with serverless-webpack for the last few days.
I have a typescript monorepo using yarn workspaces, and found this issue in which you say to build manually with a script. However, it's not clear how to configure this with Jetpack. Right now I have
This is including my entire hoisted
node_modules
folder (including aws-sdk, typescript, other dev dependencies, etc) and so is too large for lambda. Further, it's not clear how to connect it to the function.Would it be:
???
Any guidance is much appreciated. Thanks