-
Notifications
You must be signed in to change notification settings - Fork 915
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
Fix #570 missing package not resolved #611
Fix #570 missing package not resolved #611
Conversation
This pull request is being automatically deployed with Vercel (learn more). 🔍 Inspect: https://vercel.com/pikapkg/snowpack/6qwk7t830 |
Another thinking here is whether it's possible to run the |
This is a good start, but adding it to the |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
commented!
Can, will add a warning in terminal |
Hmmm the logs will be cleared somehow, may be related to #558 ? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is definitely closer, but we still want to avoid pushing the package name into config.knownEntrypoints
and should treat config
as readonly.
One other tricky part of this is that exists
could be true if the package was installed, and then this is now the first use of it in your application. In that case, the user doesn't need to add it to knownEntrypoints.
Here's the solution that I think would work for both usecases:
const doesPackageExist = !!depManifestLoc;
+const doesImportExist = scanImportsFromFiles().some((target => target.specifier === spec);
missingWebModule = {
spec: spec,
pkgName: packageName,
+ packageExists: doesPackageExist,
+ importExists: doesImportExist
};
Then, the paint function would have all it need:
- if
!doesImportExist
, then tell the user to add toinstall: []
in their config. - if
!doesPackageExist
, then tell the user to "npm install" the package. - otherwise, it's safe to run a run an automatic "snowpack install" for them.
src/commands/dev.ts
Outdated
id: fileLoc, | ||
data: missingWebModule, | ||
}); | ||
if (missingWebModule) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
looks like missingWebModule is always null here, since you return immediately after setting missingWebModule = { ...
PS: apologies for the noise, but we just converted this project to a monorepo. We tried to preserve history in the repo, so you should be able to rebase/merge to get the latest changes. |
Thanks, I will try later. |
1 similar comment
Thanks, I will try later. |
Hi @FredKSchott , I've removed the mutation on config object. Then I find the reason why And for |
Update: We ended up running into separate issues with this "auto install missing packages" workflow and the new dev output tracked in #648, which forced us to just remove it entirely for now. I went ahead and added this message about Thanks again for your work here! if you are able to test against master and see anything still not working, please let me know and I'll take a look. Looking forward to getting this released and fixing the macros issue! |
Noted thanks |
Changes
To support babel macros.
In dev mode, before reinstalling dependencies, do add the missing entry points to
knownEntrypoints
as reinstall will only install the dependencies from configuration, and imports scanned from the source code.Before:
After:
Testing
Tested here: https://github.com/JennieJi/snowpack/pull/3
I only reproduced this via babel macros, but installing babel plugin will add too many files. And I didn't have a good idea of how to use the current test runners to test the dev mode... Thus I chose not to add in this branch. @FredKSchott need some advice about this.