Skip to content
This repository has been archived by the owner on Feb 22, 2023. It is now read-only.

Reset entire module cache on change to any file that is part of the project #399

Open
jkelvie opened this issue Nov 3, 2017 · 2 comments
Assignees
Labels

Comments

@jkelvie
Copy link
Member

jkelvie commented Nov 3, 2017

Per these changes on the serverless-plugin:
https://github.com/breathe/serverless-plugin-bespoken/blob/ea4ed854f91cb569862c4cf9f1016ba349a3083c/src/ServerlessPluginBespoken.ts#L20

And per this discussion:
screen shot 2017-11-03 at 5 52 18 pm

I believe the best course is to fully reset the cache, regardless of what directory it is in (though we still want to exclude node_modules), when any file that is part of the project has changed.

This means, when we detect a change in ModuleManager:

  • resetCache on NodeUtil can be called right away
  • There is no need for a dirty flag
  • We should not need the modules variable either - instead calling module should just immediately call require(filePath)

In this way, we can significantly simplify the logic while improving the functionality.

@dmarvp
Copy link
Contributor

dmarvp commented Sep 2, 2018

@jkelvie @jperata is this still valid as of today?

@jkelvie
Copy link
Member Author

jkelvie commented Sep 3, 2018

It is still valid. The behavior we would like is that any time a file changes in the project, the modules cache is completely replaced.

Currently, when someone changes a file OTHER than the main lambda, the change is only "hot-loaded" when the user happens to also change the main lambda (i.e., index.js).

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

No branches or pull requests

3 participants