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

Detect when a build is required #128

Open
serin-delaunay opened this issue Aug 25, 2016 · 5 comments
Open

Detect when a build is required #128

serin-delaunay opened this issue Aug 25, 2016 · 5 comments

Comments

@serin-delaunay
Copy link

On Windows, if I do the following steps:

  1. Terminate all psc-ide-server processes
  2. Make a new folder
  3. Do pulp init in the new folder
  4. Open Atom
  5. Open the new folder in Atom (by dragging it onto the Atom window)
  6. Open src/Main.purs
  7. Save src/Main.purs (with no changes)
    Then Atom reports as an error that Control.Monad.Eff is an unknown module. The error disappears after a short time.
    If I then add import Math (sqrt) to the end of the imports, I again get the error Unknown module Math, as expected.
    If I now do bower install purescript-math --save-dev, and save src/Main.purs again, the error should stop and compilation should be successful, but there's no change.
    For comparison, if I do pulp -w build --to bundle.js in the same folder it builds successfully with no errors (just warnings about unused imports). I can add an index.html file, run lserver, and successfully run a bundle.js compiled with the Math module.
    The Atom package's build command is the default: pulp.cmd build --no-psa --json-errors
    If I exit Atom and open it again, when I save Main.purs it builds successfully, with only warnings about redundant imports. It's good that I can work around the problem, but I shouldn't have to restart Atom to import a new module.
@kritzcreek
Copy link
Contributor

kritzcreek commented Aug 25, 2016

You have to run a pulp build command before psc-ide can pick up your fresh dependencies. It's available inside atom behind the keybinding Ctrl-o b or you can run it from the command palette searching for IdePureScript: Build

Edit: Once your dependencies are built, atom will keep them up to date and reflect changes right away, but the initial build needs to be triggered manually.

@nwolverson
Copy link
Owner

What @kritzcreek says is correct. Open to suggestions for better UX for this case - my concern is I don't want to automatically run a full build on save in certain cases that may not trigger correctly, and may not be obvious that/why it's happening.

@serin-delaunay
Copy link
Author

A full build fixes the problem, thanks.
I wasn't aware that there was a difference between the build-on-save and a full build. Some issues can be expanded to show additional information and possible fixes. Could something about making a full build be added to the unknown module error? At the moment it doesn't expand to anything.

@nwolverson
Copy link
Owner

If you have "Use fast rebuild" configured then a single-file rebuild will be done via psc-ide-server, which for larger projects is much faster than a full build.

The unknown module error is from the compiler itself, so this will not change, but what would be more realistic is detecting when there are no externs present (ie no/empty output dir) when doing a rebuild, and throw up some info somehow in this case. I'm not sure we can detect anything more subtle than this all/nothing though (other occasions you may need to do a full build due to making interdependent changes, installing further dependencies, etc).

I guess we could augment unknown module with a "full build" text or quick-fix action, but I'm not sure what the hit rate is for that - probably is a good chance that a rebuild might fix it? Or at least you would know whether it should.

@nwolverson nwolverson changed the title "Unknown module" for [bower installed] modules which are detected by pulp build -w Detect when a build is required Jan 1, 2017
@nwolverson
Copy link
Owner

From discussion there's a possibility this is something psc-ide might do in the future

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

No branches or pull requests

3 participants