Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

serverless-offline 9.1.0 Breaking change #60

Closed
mattensor opened this issue Jul 28, 2022 · 10 comments
Closed

serverless-offline 9.1.0 Breaking change #60

mattensor opened this issue Jul 28, 2022 · 10 comments

Comments

@mattensor
Copy link

Overview

I can't get serverless-offline-eventBridge to work with the latest version of serverless-offline.

When I start my dev server I get the following error [ERR_PACKAGE_PATH_NOT_EXPORTED]: Package subpath './dist/lambda' is not defined by "exports" in /Users/me/my-api/node_modules/serverless-offline/package.json

When I remove the package, everything bundles fine and my app runs. I think it may be failing due to the latest node import changes.

Hope to get some help 🙏

Setup

node v16.15.0

// package.json deps

"serverless-dynamodb-local": "^0.2.40",
"serverless-esbuild": "^1.32.5",
"serverless-offline": "^9.1.0",
"serverless-offline-aws-eventbridge": "^1.6.7",
// serverless.yml

plugins:
  - serverless-esbuild
  - serverless-dynamodb-local
  - serverless-offline
  - serverless-offline-aws-eventbridge
// eventbridge.yml

Effect: Allow
Action:
  - events:PutEvents
Resource:
  - '*'

Trace

> serverless offline start --host 0.0.0.0 --httpPort 4000

Environment: darwin, node 16.15.0, framework 3.21.0 (local), plugin 6.2.2, SDK 4.3.2
Docs:        docs.serverless.com
Support:     forum.serverless.com
Bugs:        github.com/serverless/serverless/issues

Error:
Error [ERR_PACKAGE_PATH_NOT_EXPORTED]: Package subpath './dist/lambda' is not defined by "exports" in /Users/me/my-api/node_modules/serverless-offline/package.json
    at new NodeError (node:internal/errors:372:5)
    at throwExportsNotFound (node:internal/modules/esm/resolve:472:9)
    at packageExportsResolve (node:internal/modules/esm/resolve:753:3)
    at resolveExports (node:internal/modules/cjs/loader:482:36)
    at Function.Module._findPath (node:internal/modules/cjs/loader:522:31)
    at Function.Module._resolveFilename (node:internal/modules/cjs/loader:919:27)
    at Function.Module._load (node:internal/modules/cjs/loader:778:27)
    at Module.require (node:internal/modules/cjs/loader:1005:19)
    at require (node:internal/modules/cjs/helpers:102:18)
    at Object.<anonymous> (/Users/me/my-api/node_modules/serverless-offline-aws-eventbridge/src/index.js:9:16)
    at Module._compile (node:internal/modules/cjs/loader:1105:14)
    at Object.Module._extensions..js (node:internal/modules/cjs/loader:1159:10)
    at Module.load (node:internal/modules/cjs/loader:981:32)
    at Function.Module._load (node:internal/modules/cjs/loader:822:12)
    at Module.require (node:internal/modules/cjs/loader:1005:19)
    at require (node:internal/modules/cjs/helpers:102:18)
    at module.exports (/Users/me/my-api/node_modules/serverless/lib/utils/import-module.js:5:12)
    at PluginManager.requireServicePlugin (/Users/me/my-api/node_modules/serverless/lib/classes/plugin-manager.js:171:14)
    at PluginManager.resolveServicePlugins (/Users/me/my-api/node_modules/serverless/lib/classes/plugin-manager.js:198:29)
    at async PluginManager.loadAllPlugins (/Users/me/my-api/node_modules/serverless/lib/classes/plugin-manager.js:136:36)
    at async Serverless.init (/Users/me/my-api/node_modules/serverless/lib/serverless.js:141:5)
    at async /Users/me/my-api/node_modules/serverless/scripts/serverless.js:591:7
@rubenkaiser
Copy link
Owner

Unfortunately the new version of Serverless-offline does not export the required lambda files. There are several serverless-offline packages that are not working anymore. I'm keeping an eye on the following thread: CoorpAcademy/serverless-plugins#217

@mattensor
Copy link
Author

Thanks @rubenkaiser

@rubenkaiser
Copy link
Owner

I've just released a beta version 2.0.0-beta.0 in which I've put a bit of a hack to remove the serverless-offline export automatically. At this point serverless-offline may crash the first time but running it again should make it work.

For now this may fix your local env but I'm hoping they will remove the export themselves to solve this issue for all other plugins as well.

@mattensor
Copy link
Author

🙏 Thank you @rubenkaiser!

@dnalborczyk
Copy link
Contributor

@rubenkaiser it was unbeknownst to me that other plugins were reaching into the lambda functionality of serverless-offline but it's the perfect thing to do. I was always hoping this would happen, albeit currently lacking documentation.

that said, I'm a bit surprised that instead of working around the package exports "problem", you wouldn't just file an issue with serverless-offline . we could have resolved this fairly quickly and early on 😉

I think the right thing to do would be instead of removing package exports altogether we would be either adding an additional export path to exports, or we would add a named export to index.js (which might be better). that way, stuff can be refactored inside the package, as long as the contract (which also officially doesn't exist [yet]) does not change. we would just need to define a contract and document it.

@rubenkaiser
Copy link
Owner

rubenkaiser commented Aug 25, 2022

You're right @dnalborczyk . I thought this issue was enough but now I see I never commented in your project. My bad. I think exporting an array of files is possible, however I saw that sqs for example is importing several things.

@rubenkaiser
Copy link
Owner

rubenkaiser commented Aug 25, 2022

PR for exporting the lambda code in a named export: dherault/serverless-offline#1552

@rubenkaiser
Copy link
Owner

[email protected] was just released and can be used with serverless-offline > 10.0.0

@davidgarvie
Copy link

Thanks for the release @rubenkaiser, great work :) Have you considered tags / releases on github so the community has an easy way to get notified of new releases?

@rubenkaiser
Copy link
Owner

@davidgarvie considering the amount of downloads nowadays I will start using the released as well. Good suggestion, thanks.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants