netlify / zip-it-and-ship-it

Intelligently prepare Node.js Lambda functions for deployment
https://www.npmjs.com/package/@netlify/zip-it-and-ship-it
MIT License
316 stars 35 forks source link

This does not work with Parcel #206

Open ehmicky opened 4 years ago

ehmicky commented 4 years ago

Background at https://community.netlify.com/t/netlify-plugin-functions-core-fails-on-dependencies-that-are-bundled-already/22836

Parcel produces bundles like this one where all required dependencies are included in a single file. The require() function is injected. For example, the following line:

https://gist.github.com/Industrial/60aed2605953206ab04c9dde62ddc60b#file-markets-js-L162

Uses the require function defined here:

https://gist.github.com/Industrial/60aed2605953206ab04c9dde62ddc60b#file-markets-js-L1

Which ends up calling the other bundled file:

https://gist.github.com/Industrial/60aed2605953206ab04c9dde62ddc60b#file-markets-js-L48

With our current algorithm, the require() statement will not find the dependent file and create a build-time error.

When we detect that a Function file is a Parcel bundle, we should instead skip dependencies crawling. We should make sure this does not break any existing Parcel bundled Functions.

ehmicky commented 3 years ago

@eduardoboucas Would this work with the new esbuild flow?