Tom
Aug 21, 2018 05:14
thanks for the help man
Tom
Aug 21, 2018 05:14
ok, I guess I don't really follow what yarn is doing wrong :P I'll have a deeper look
Tom
Aug 21, 2018 05:13
If they would support yarn, there would probably not be a mismatch
Tom
Aug 21, 2018 05:12
Hmmm. So the real problem is just that they don't support yarn.
Tom
Aug 21, 2018 05:11
@MattMcCutchen I think the reason they use the filesystem is just because they are too "lazy" to traverse through all depths of production dependencies in nested package.json files ;)
Tom
Aug 21, 2018 05:10
Ok, my bad
Tom
Aug 21, 2018 05:10
@MattMcCutchen but if a dependency A has a dependency B and that dependency B has a dependency C, then dependency C must also be nohoisted, even though it is 3 levels deep. Or are you not against that? You're only talking about deep dev dependencies?
Tom
Aug 21, 2018 05:04
@MattMcCutchen so your suggestion is that nohoist should only be relevant to production dependencies?
Tom
Aug 21, 2018 04:59
I don't see how yarn could solve that
Tom
Aug 21, 2018 04:59
@MattMcCutchen that's because the ** makes the dependencies of dependencies also nohoisted
Tom
Aug 21, 2018 04:54
So only 2 issues left for which I can create issues at the serverless framework:

- Serverless artifacts contain a few [redundant dependencies](https://github.com/serverless/serverless/pull/3889#issuecomment-414547166)
- Yarn workspace hoisting is currently disabled for [serverless services](https://forum.serverless.com/t/using-serverless-with-yarn-workspaces/4560)
Tom
Aug 21, 2018 04:53
@MattMcCutchen good news is that I managed to remove the source code by changing the exclusion pattern to:

```
package:
exclude:
- ./**
- '!dist/**'
- '!node_modules/**'
```

Defining it this way does not overwrite the dev dependencies exclusion
Tom
Aug 21, 2018 04:46
I can't believe they are hardcoding calls to npm.. I was planning to uninstall npm
Tom
Aug 21, 2018 04:45
Hmmm. I'm confused.
Tom
Aug 21, 2018 04:32
and for some weird reason it is including ts-node, which I guess is a small bug
Tom
Aug 21, 2018 04:30
but that's not a huge issue
Tom
Aug 21, 2018 04:30
which is that I'm not sure how to exclude some redundant source files...
Tom
Aug 21, 2018 04:30
right now there is a small issue left
Tom
Aug 21, 2018 04:30
@MattMcCutchen I am always thinking this...
Tom
Aug 21, 2018 04:29
you rock
Tom
Aug 21, 2018 04:29
:D
Tom
Aug 21, 2018 04:29
yeah...!
Tom
Aug 21, 2018 04:28
@MattMcCutchen

ok if you just comment out everything:

# package:
# exclude:
# - ./**
# include:
# - dist/**
# - node_modules/**
# - '!node_modules/aws-sdk/**'

the bundle is only 77Kb
Tom
Aug 21, 2018 04:24
thanks @MattMcCutchen

honestly right now I am still at a point where I can't really use it

curious where you think it's going wrong? is serverless even able to figure out which of these deep dependencies are dev dependencies?
Tom
Aug 21, 2018 04:22
@MattMcCutchen perhaps. I do expect there to be more use-cases to have a single outputDir, just like typescript has outputFile
Tom
Aug 21, 2018 04:17
it's still at 22MB so I guess the deep dev dependencies are not resolved ?
Tom
Aug 21, 2018 04:16
@MattMcCutchen here https://github.com/Microsoft/types-publisher/issues/81 they say it's better to put them in dependencies

but let me try it
Tom
Aug 21, 2018 04:14
@MattMcCutchen I don't think there is a syntax error though ?
Tom
Aug 21, 2018 04:13
I'm not sure how much of the 22MB is unnecessary though
Tom
Aug 21, 2018 04:13
by changing package.json in the root to:

```
"nohoist": [
"**/serverless-random/**"
]
```

and in serverless-random serverless.yml to:

```
package:
exclude:
- ./**
include:
- dist/**
- node_modules/**
- '!node_modules/aws-sdk/**'
```

the package size became 22MB
Tom
Aug 21, 2018 04:05
There are :'( I'd have to try to solve them
Tom
Aug 21, 2018 04:05
https://yarnpkg.com/blog/2018/02/15/nohoist/

what if I make the nohoist less aggressive ?
Tom
Aug 21, 2018 04:04
That seems uglier than going back to webpack
Tom
Aug 21, 2018 04:04
You mean create a dummy package only for the purpose of packaging serverless-random?
Tom
Aug 21, 2018 04:03
Sure but then I need a dependency graph, which is very complicated
Tom
Aug 21, 2018 04:00
that sounds like a big problem
Tom
Aug 21, 2018 04:00
@MattMcCutchen you're absolutely right.. I just realized that too
Tom
Aug 21, 2018 03:58
@MattMcCutchen I think it's more probable that it's the serverless configuration
Tom
Aug 21, 2018 03:57
Yeah. I suppose aws-sdk is there, and redundant source files, too
Tom
Aug 21, 2018 03:56
@MattMcCutchen

https://kdmmj1rit6.execute-api.us-east-1.amazonaws.com/dev/number

!!!!
Tom
Aug 21, 2018 03:55
changing it to handler: dist/index.fetchRandomNumber and redeploying
Tom
Aug 21, 2018 03:54
handler: dist/serverless-random/src/index.fetchRandomNumber is wrong
Tom
Aug 21, 2018 03:54
ok this is because of my serverless.yml
Tom
Aug 21, 2018 03:54
@MattMcCutchen

```
Unable to import module 'dist/serverless-random/src/index': Error
at Function.Module._resolveFilename (module.js:547:15)
at Function.Module._load (module.js:474:25)
at Module.require (module.js:596:17)
at require (internal/module.js:11:18)
```
Tom
Aug 21, 2018 03:53
got an internal server error.. checking logs now
Tom
Aug 21, 2018 03:51
I'll try to deploy it
Tom
Aug 21, 2018 03:49
@MattMcCutchen the good news is that because of `tsc -b`, @org/random is now also built

previously this was not possible
Tom
Aug 21, 2018 03:48
@MattMcCutchen you are right, so now the challenge is to make the references inside that bundle work
Tom
Aug 21, 2018 03:47
the bundle is 2kb small..