avoid loading an app that its env was not loaded yet #9194
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This PR fixes an issue of app data not being saved after running "create component" and then "snap" from the extension. The reason it happened is complex. It involves node.js caching package.json info and an API call of "getCompsMetadata" that was executed during the "create component" call.
Because "getCompsMetadata" gets app-data, it tries to load the apps as plugins, which makes node access its package.json. At this stage, the package.json didn't have the "type: module" yet, so node.js assumes this is a CJS file.
Later, bit re-write the package.json with the data from the env, which includes "type: module", but it's too late. Node.js already cached the package.json and refuses to see the change.
This fix block the access to the app files unless the env is fully loaded, which then we assume the package.json is correct.