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

file watching does not work when bundle option is set to true #94

Open
coot opened this issue May 17, 2017 · 7 comments
Open

file watching does not work when bundle option is set to true #94

coot opened this issue May 17, 2017 · 7 comments

Comments

@coot
Copy link

coot commented May 17, 2017

If you change bundle to true in the example and modify non-entry point the webpack will not rebuild purescript code.

@ethul
Copy link
Owner

ethul commented May 18, 2017 via email

@ethul
Copy link
Owner

ethul commented Jun 4, 2017

Sorry for the delay on this. I just checked, and this is problematic as well back in version 2.4.2 of the loader. However, I am wondering the use-case for bundling when using webpack in watch mode. Would you be able to detail this a bit further?

Thanks!

@aztecrex
Copy link

aztecrex commented Jun 26, 2017

this fixed all my watching and bundling woes:

in webpack.config.js

{
  loader: 'purs-loader',
  options: {
    bundle: !(isWebpackDevServer || isWatch),
    watch: isWebpackDevServer || isWatch,
    // ...
  }
}

@coot
Copy link
Author

coot commented Jun 27, 2017

@aztecrex so you just disabled the bundle option i watching mode, that's not a solution for this issue ;)

I'll try to debug it one day... in the meantime I switched to purs ide compilation - it's much faster, and bundling only in non watching mode.

@ethul
Copy link
Owner

ethul commented Jun 27, 2017

Thanks for the note @aztecrex. That definitely works if one does not need to bundle in watch mode.

@coot I think using purs ide is a good solution. I agree it is faster. I've used this in the past in conjunction with webpack and I remember it working out well. However, I can't recall if it worked for all of my use-cases.

I think I'd like to see if this issue can be resolved in the same way that dependencies are tracked when bundling is turned off. Using addDependency is certainly and option to fix this (as in #95), but I have yet to take a look to see if we can fix this in another way.

@coot
Copy link
Author

coot commented Jun 27, 2017

@ethul that's fine. I don't know webpack internals (more than reading purs-loader code.

purs ide works fine, most of the time. I can see two problems with it:

  • on startup it loads externs files and on subsequent compilation it compiles all the files. My impression is that plugin internal cache is not filled when reading externs files
    On startup:
 purs-loader loading OspreyPlatform.Main +2ms
  purs-loader compile psa [ '--output=output',
  purs-loader   'bower_components/purescript-*/src/**/*.purs',
  purs-loader   'src/**/*.purs' ] +1ms
  purs-loader compiling PureScript... +0ms
  purs-loader finished compiling PureScript. +184ms
  purs-loader loading PureScript source and FFI files from [ 'bower_components/purescript-*/src/**/*.purs', 'src/**/*.purs' ] +4ms
  purs-loader rebuilt module map after compilation +783ms
  purs-loader:verbose loading JavaScript for OspreyPlatform.Main +117ms
  purs-loader loading OspreyPlatform.Action +241ms
  purs-loader:verbose compilation is already finished, loading module OspreyPlatform.Action +0ms
  purs-loader:verbose loading JavaScript for OspreyPlatform.Action +0ms
  purs-loader loading OspreyPlatform.Config +1ms

On subsequent compilation:

  purs-loader:verbose invalidating loader cache +8m
  purs-loader loading Control.Applicative +276ms
  purs-loader ide server: purs [ 'ide', 'server', '--output-directory=output', 'bower_components/purescript-*/src/**/*.purs', 'src/**/*.purs' ] +2ms
  purs-loader loading Control.Bind +28ms
  purs-loader loading Control.Monad.Eff +0ms
  purs-loader loading Control.Monad.Eff.Unsafe +0ms
  purs-loader loading Control.Monad.Eff.Console +0ms
  purs-loader loading DOM +1ms
  purs-loader loading Control.Semigroupoid +0ms
  purs-loader loading DOM.HTML +0ms
  purs-loader loading DOM.HTML.Types +0ms
  purs-loader loading DOM.HTML.Window +0ms
  purs-loader loading DOM.Node.Element +0ms
  purs-loader loading DOM.Node.NonElementParentNode +0ms
  purs-loader loading DOM.Node.Types +1ms
  purs-loader loading Data.Function +5ms
  purs-loader loading Data.Functor +0ms
  purs-loader loading Data.Maybe +0ms
  purs-loader loading Data.Unit +0ms
  purs-loader loading OspreyPlatform.Action +0ms
  purs-loader loading OspreyPlatform.Components.Router +0ms
  purs-loader loading OspreyPlatform.Config +0ms
  purs-loader loading OspreyPlatform.Types +1ms
  purs-loader loading Partial.Unsafe +0ms
  purs-loader loading Prelude +0ms
  purs-loader loading React +0ms
  purs-loader loading React.Redox +4ms
  purs-loader loading React.Router +0ms
  purs-loader loading React.Router.Components +0ms
  purs-loader loading React.Router.Types +0ms
  purs-loader loading ReactDOM +0ms
  purs-loader loading Redox +0ms
  purs-loader loading Redox.Free +0ms
  purs-loader loading Redox.Store +1ms
  purs-loader ide client purs [ 'ide', 'client' ] { command: 'rebuild',
  purs-loader   params: { file: '/home/marcin/repos/gravicus/ospreyui/bower_components/purescript-prelude/src/Control/Bind.purs' } } +1ms
  purs-loader ide client purs [ 'ide', 'client' ] { command: 'rebuild',
  purs-loader   params: { file: '/home/marcin/repos/gravicus/ospreyui/bower_components/purescript-eff/src/Control/Monad/Eff.purs' } } +35ms
  purs-loader ide client purs [ 'ide', 'client' ] { command: 'rebuild',
  purs-loader   params: { file: '/home/marcin/repos/gravicus/ospreyui/bower_components/purescript-eff/src/Control/Monad/Eff/Unsafe.purs' } } +30ms
  purs-loader ide client purs [ 'ide', 'client' ] { command: 'rebuild',
  purs-loader   params: { file: '/home/marcin/repos/gravicus/ospreyui/bower_components/purescript-console/src/Control/Monad/Eff/Console.purs' } } +54ms

and lots of other build commands that follow

  • adding a new file I need to restart the server so that everything is updated
  • sometimes it happens that the parts of the project which got updated are still outdated and an app will crash

@jerbaroo
Copy link

jerbaroo commented Mar 31, 2021

Is there any update on this, or any known workaround?

I am using the following in my webpack configuration:

  plugins   : [ new ExtraWatchWebpackPlugin({files : pursSources()})],
  cache     : false,

Simply using the line with the plugins does cause webpack to recompile, however my PureScript files do not get recompiled, instead webpack simply returns cached modules.

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

Successfully merging a pull request may close this issue.

4 participants