Giter VIP home page Giter VIP logo

Comments (13)

olup avatar olup commented on May 13, 2024 1

I am not sure yet, but as of now I think you are right, we should probably just implement plugins (I wanted to make a PR this week but have been delayed) and leave this as a workaround. This is a true edge-case, I think there is a questionable design from the pg library. But I can only agree with you when you note that it's probably outside of the scope of serverless-esbuild.

from serverless-esbuild.

floydspace avatar floydspace commented on May 13, 2024

@olup I agree, optional peers must be skipped, but I don't think we should manage it with our packaging logic, it should be handled by esbuild, otherwise it would be an unexpected side effect.
See #97 I think this is related somehow, we just need to implement plugin support to handle this case.
Basically it's how all the world does with pg-native:

new IgnorePlugin({
      resourceRegExp: /^pg-native$/,
})

to be honest I do not really like this dirty solution, so maybe it really makes sense to change the world here and incapsulate in our packaging logic. what do you think?

from serverless-esbuild.

floydspace avatar floydspace commented on May 13, 2024

Agreed, let's prioritise plugin support and if it solves the edge case then we are good

from serverless-esbuild.

olup avatar olup commented on May 13, 2024

I'll close it then.

from serverless-esbuild.

mattisdada avatar mattisdada commented on May 13, 2024

I'm also running into this problem :(

For me particularly, JSDom has an optional peer dependency of canvas which is causing all sorts of grief.

My question is though, how is canvas getting downloaded and installed in this process? It's not actually downloaded anywhere else, so npm must be getting called at some point to grab it during watch?

from serverless-esbuild.

olup avatar olup commented on May 13, 2024

Hello ! Can I ask how you use JSDom in your code? Specifically, is it something you bundle as external?

from serverless-esbuild.

mattisdada avatar mattisdada commented on May 13, 2024

Yup, marked as external in serverless.yml

  esbuild:
    bundle: true
    minify: false
    target: es2019
    format: cjs
    external:
      - aws-lambda
      - got
      - keyv
      - jsdom

And merely having jsdom as a dependency causes canvas to be pulled into node_modules in the build (it's an optional peer dependency of jsdom, if it's pulled in it changes the behavior and we do not need it). I even fully removed jsdom from code, and it's only listed in dependencies in package.json.

Although if never importing jsdom in code doesn't create the cascade of problems bringing in canvas has, but it's still in the .ebuild/.build/node_modules folder for whatever reason

from serverless-esbuild.

olup avatar olup commented on May 13, 2024

Yes, that's the thing, check : #104

External are pulled with their optionals peer dependencies as of now. Plugins support will provide a workaround. But we might do something more backed in.

from serverless-esbuild.

mattisdada avatar mattisdada commented on May 13, 2024

We are on #104 :)

Yeah I had a peek of the code and it does just pull down all peers without any condition. Simply removing that chunk did resolve it for me.... What was the rationale of grabbing all the peers like that? Seems like it'll likely cause more issues than solve

from serverless-esbuild.

olup avatar olup commented on May 13, 2024

Lol sorry, answering too early after wake up. Yes, as you read, we are thinking of some ways to fine tune this, I am not sure myself why this was added in the first place.

By the way, plugin support is here so if you need a quick fix you can use that to exclude the peer dep.

from serverless-esbuild.

olup avatar olup commented on May 13, 2024

@floydspace thinking about it more, it might actually be our responsibility to not install optional peer deps in the case of externals as we are the one installing them in the first place, don't you think ?

@mattisdada it's expected our our packaging to include the peer dependencies of the external modules, however I agree optionals could probably be skipped, and let user include them if needed.

from serverless-esbuild.

floydspace avatar floydspace commented on May 13, 2024

@olup you might be right, if we choose not to bundle a certain dep (with optional peers), our packager comes to the game which has to do the job right

from serverless-esbuild.

olup avatar olup commented on May 13, 2024

@mattisdada what about #113 ? Is that solving your problem ?

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.