Open ryan-roemer opened 4 years ago
@ryan-roemer Thanks for picking this up and carding it properly for me
Really impressed by serverless-jetpack so far. While building 31 functions, we've gone from 9 minutes with serverless-webpack to less than 2 minutes with serverless-jetpack. So we're more than happy to run with workarounds for now!
sanitize-html
have upgraded their build process: https://github.com/apostrophecms/sanitize-html/blob/main/CHANGELOG.md#backwards-compatibility-breaks - as of 2.0 it no longer requires any special tracing configuration and just works with jetpack :+1:
From https://github.com/FormidableLabs/serverless-jetpack/issues/116#issuecomment-674876195, it looks like
browserify
will bundle code that uses the actual function namerequire
to import the code in the bundle and is not meant to be the actual Node.jsrequire
. This is as opposed to webpack, which has the unambiguous__webpack_require__()
function for the same thing.So this creates a lot of false missing files. In the
sanitize-html
case, there's lodash and other deps bundled in that then run afoul withrequire()
s of code that's actually in the bundle. See, e.g., https://unpkg.com/sanitize-html@1.27.3/dist/sanitize-html.jsExample
Looking at the source in https://unpkg.com/sanitize-html@1.27.3/dist/sanitize-html.js we have:
... and it does look like that that is the real lodash apply code within
sanitize-html
bundle that you'd normally find here: https://unpkg.com/lodash@4.17.20/_apply.js. SMy guess is that all of the four dependencies specified at https://github.com/apostrophecms/sanitize-html/blob/main/package.json#L29-L32 are actually included in that browserified bundle and you should be fine. Upon spot checking, lodash and postcss appear.
Task