Enigmatic-Smile / serverless-plugin-optimize

⛔️ DEPRECATED ⛔️ Bundle with Browserify, transpile and minify with Babel automatically to your NodeJS runtime compatible JavaScript
https://www.npmjs.com/package/serverless-plugin-optimize
MIT License
130 stars 53 forks source link

module.require is not a function #83

Open jasonlimantoro opened 5 years ago

jasonlimantoro commented 5 years ago

Without the plugin, the deployed functions work well. However, after enabling the plugin, although it's significantly smaller, invoking the API yields the error module.require is not a function, yielding 5xx HTTP status code.

I'm using serverless 4.1.0-rc.1

Any ideas?

luaneyed commented 5 years ago

I got same error. In my case, it was resolved after matching serverless runtime (which was node 8) with local runtime (node 10).

But I can't say it's just runtime problem with confidence, because executing the result of sls package in local made same error.

montamal commented 4 years ago

Still a problem even with matching runtime versions, it plays badly with some modules. In my case it was apollo-server-lambda@2.10, reported the issue to them but turns out it was this plugin.

This is worth looking into.

EDIT: Investigating a bit, I found that Browserify doesn't expose module.require. Authors seem to think this opens hacky overrides and won't merge this PR that was open in 2013: https://github.com/browserify/browser-pack/pull/19

juanpujol commented 4 years ago

Have the same issue with apollo-server-lambda@2.16.1 the package is huge w/o serverless-plugin-optimize

gastonrey commented 3 years ago

Hi, any news on this? Anyone got it working at some point? Am getting "errorMessage": "require.resolve is not a function" error and it's probably related.