atom-ide-purescript icon indicating copy to clipboard operation
atom-ide-purescript copied to clipboard

Detect when a build is required

Open serin-delaunay opened this issue 8 years ago • 5 comments

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.

serin-delaunay avatar Aug 25 '16 22:08 serin-delaunay

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.

kritzcreek avatar Aug 25 '16 23:08 kritzcreek

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.

nwolverson avatar Aug 26 '16 09:08 nwolverson

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.

serin-delaunay avatar Aug 26 '16 09:08 serin-delaunay

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 avatar Aug 26 '16 10:08 nwolverson

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

nwolverson avatar Jan 01 '17 21:01 nwolverson