purs-loader icon indicating copy to clipboard operation
purs-loader copied to clipboard

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

Open coot opened this issue 7 years ago • 7 comments

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

coot avatar May 17 '17 22:05 coot

Thanks for the report. I will take a look.

On Wed, May 17, 2017 at 18:38 Coot [email protected] wrote:

If you change bundle to true in the example https://github.com/ethul/purescript-webpack-example and modify non-entry point the webpack will not rebuild purescript code.

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/ethul/purs-loader/issues/94, or mute the thread https://github.com/notifications/unsubscribe-auth/AAVYyz8U_PONBzMdDp7i2UxOL70KJS7Lks5r63bIgaJpZM4Nehka .

ethul avatar May 18 '17 01:05 ethul

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!

ethul avatar Jun 04 '17 21:06 ethul

this fixed all my watching and bundling woes:

in webpack.config.js

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

aztecrex avatar Jun 26 '17 04:06 aztecrex

@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.

coot avatar Jun 27 '17 10:06 coot

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.

ethul avatar Jun 27 '17 12:06 ethul

@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

coot avatar Jun 27 '17 16:06 coot

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.

jerbaroo avatar Mar 31 '21 14:03 jerbaroo