Giter VIP home page Giter VIP logo

Comments (6)

floydspace avatar floydspace commented on May 14, 2024 1

Hey @andreasgrimm @mattjennings I think this fix would close this issue. Feel free to reopen if you still encounter it

from serverless-esbuild.

andreasgrimm avatar andreasgrimm commented on May 14, 2024

https://github.com/serverless-heaven/serverless-webpack/pull/813/files

serverless-webpack moved from bestzip to nativeZip, nodeZip because of the same error happing there.
Are you able to fix that in the same way?
Or would you be open to accept a PR?

from serverless-esbuild.

vamche avatar vamche commented on May 14, 2024

I'd like to suggest a workaround until the root cause is investigated/fixed. Since the issue seems to be because of the large number of files (externals), is deleting some of the unecessary files in node_modules is an option for you? You can utilize a tool like clean-modules or node-prune to clean up before zipping/packaging.

You can achieve this with esbuild.packagerOptions.scripts, here is an example. For more info about clean-modules npm package, please check https://www.npmjs.com/package/clean-modules

    packagerOptions:
      scripts:
        - npm install -g clean-modules
        - clean-modules -y --exclude \"test.js\" \"**/*.map.js\" --include \"**/*.d.ts\"

from serverless-esbuild.

mattjennings avatar mattjennings commented on May 14, 2024

A coworker and I ran into this on the same monorepo project. Packaging worked for me, but didn't for them. Same node (14.17.3), yarn (1.18.0), npm (6.14.13) versions. I'm on macOS 11.4, they're on macOS 10.15.7.

I ended up making a patch for patch-package that changed the zip method to nodeZip. We tried nativeZip but it threw the same error.

Add this under patches/serverless-esbuild+1.16.1.patch

diff --git a/node_modules/serverless-esbuild/dist/utils.js b/node_modules/serverless-esbuild/dist/utils.js
index 2b0be27..580c65c 100644
--- a/node_modules/serverless-esbuild/dist/utils.js
+++ b/node_modules/serverless-esbuild/dist/utils.js
@@ -94,7 +94,7 @@ const humanSize = (size) => {
 exports.humanSize = humanSize;
 const zip = (zipPath, filesPathList, workingDir) => {
     fs.mkdirpSync(path.dirname(zipPath));
-    return bestzip_1.bestzip({
+    return bestzip_1.nodeZip({
         source: filesPathList.map((file) => file.localPath),
         destination: zipPath,
         cwd: workingDir || process.cwd()

from serverless-esbuild.

floydspace avatar floydspace commented on May 14, 2024

Hey @andreasgrimm thanks for the issue, yes we're welcome to PRs. It would be good if provide a hint how to reproduce the issue. Unfortunately, I don't have such a big workload.

@mattjennings was the fix you made with patch-package good enough to resolve the issue?

from serverless-esbuild.

mattjennings avatar mattjennings commented on May 14, 2024

@floydspace yeah we haven't had any issues since using it

from serverless-esbuild.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.