Skip to content

webpack doesn't always report compilation errors with --watch #66

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

Closed
pbrant opened this issue Aug 18, 2016 · 19 comments
Closed

webpack doesn't always report compilation errors with --watch #66

pbrant opened this issue Aug 18, 2016 · 19 comments
Assignees

Comments

@pbrant
Copy link

pbrant commented Aug 18, 2016

Steps to reproduce:

  1. Run webpack with --watch
  2. Break a file in two places (error is reported)
  3. Fix one of the problems (error isn't reported, only clue is that webpack didn't create the final bundle)
  4. Fix the other error (bundle is created)

At this point, a new error will be reported (i.e. steps 2 through 4 can be repeated indefinitely).

I've done a bit of snooping around, but I'm not sure what the appropriate fix is. The after-compile plugin callback is called and cache.errors is populated, but just adding it to compilation.errors apparently isn't enough to tell webpack to display it.

@ethul
Copy link
Owner

ethul commented Aug 19, 2016

Thanks for the report. I will take a look. What version of purescript, purs-loader, webpack, etc., are you using?

@pbrant
Copy link
Author

pbrant commented Aug 19, 2016

Sorry, I should have included that before:

  • webpack 1.13.2
  • purescript 0.9.3
  • purs-loader 2.0.0-rc.1 ('next' in package.json)

along with a local clone of psa with the PureScript 0.9.x changes. I see the same behavior with plain psc though.

@ethul
Copy link
Owner

ethul commented Aug 19, 2016

Great! Thanks for the info.

On Thursday, 18 August 2016, Peter Brant [email protected] wrote:

Sorry, I should have included that before:

  • webpack 1.13.2
  • purescript 0.9.3
  • purs-loader 2.0.0-rc.1 ('next' in package.json)

along with a local clone of psa with the PureScript 0.9.x changes. I see
the same behavior with plain psc though.


You are receiving this because you commented.
Reply to this email directly, view it on GitHub
#66 (comment),
or mute the thread
https://github.com/notifications/unsubscribe-auth/AAVYy4K7u-iGrZb1kcWEMH43AeQ5VI6Aks5qhSHigaJpZM4Jn9-c
.

@ethul ethul self-assigned this Oct 12, 2016
@ethul
Copy link
Owner

ethul commented Nov 20, 2016

Resolved inadvertently in b683b0b

Should be fixed in 2.1.1. Let me know if this is still an issue.

@ethul ethul closed this as completed Nov 20, 2016
@pbrant
Copy link
Author

pbrant commented Nov 24, 2016

I think this might still be a problem. Here is what I tried:

Starting with a fresh clone of purescript-webpack-example:

  • After installing, ran npm run webpack:watch, compilation finishes successfully
  • Edited src/example/Header.purs to add a second copy of the header function named header2
  • Changed DOM.text to DOM.textXX in both functions
  • Rewarded with ERROR in [1/2 UnknownName] src/Example/Header.purs:12:18 and [2/2 UnknownName] src/Example/Header.purs:18:18
  • Fixed one of the two functions, but nothing happened
  • Fixed the second one, bundle is created

@ethul
Copy link
Owner

ethul commented Nov 24, 2016 via email

@ethul ethul reopened this Nov 24, 2016
ethul added a commit that referenced this issue Feb 19, 2017
Similar to the way psc-ide support works, the purs-loader now tolerates
compiler errors when the `watch` option is true. When webpack is being
run in watch mode the user can set `watch` to true in order to avoid
failing the webpack bundle creation when the PureScript compiler fails.

Resolves issue #66

Resolves issue #73

Resolves issue #74
@ethul
Copy link
Owner

ethul commented Feb 20, 2017

I've published a beta release that should fix this issue. If you are willing to give it a try, that would be great! You can install the release under the beta dist tag.

npm install purs-loader@beta

In this release, there is a new option called watch. Please set this to true in your webpack config if you are running webpack in watch mode.

Thanks!

@pbrant
Copy link
Author

pbrant commented Feb 20, 2017

Is there a particular version of webpack I should be using? For me with the beta version of purs-loader, webpack 1.14.0 and watch: true, it looks like errors aren't reported at all and the bundle isn't created after the initial run.

I've included the console output below with DEBUG=purs-loader (with a bit of additional logging added). This is a successful initial compilation, breaking Header.purs in two places (as above), and then fixing both.

Hash: 7c9b05e95ac6ed0c0772  
Version: webpack 1.14.0
Time: 4192ms
    Asset     Size  Chunks             Chunk Names
bundle.js  3.48 MB       0  [emitted]  main
   [1] ./src/Example.js 260 bytes {0} [built]
 [336] ./src/Example/Footer.js 46 bytes {0} [built]
    + 335 hidden modules

WARNING in            Src   Lib   All
Warnings   0     0     0  
Errors     0     0     0  

  purs-loader invalidating loader cache +846ms
  purs-loader invalidating loader cache +9s
 10% 0/1 build modules  purs-loader loader called Example.Header +427ms
  purs-loader spawning compiler psa [ '--output=output', 'bower_components/purescript-*/src/**/*.purs', 'src/**/*.purs' ] +0ms
  purs-loader compiling PureScript... +1ms
  purs-loader finished compiling PureScript (code = 1) +957ms
  purs-loader emitting error +0ms
  purs-loader watch is true, calling resolve(psModule) +0ms
  purs-loader loading PureScript source and FFI files from [ 'bower_components/purescript-*/src/**/*.purs', 'src/**/*.purs' ] +0ms
  purs-loader rebuilt module map +83ms
  purs-loader loading JavaScript for Example.Header +1ms
  purs-loader imports [ 'Prelude', 'React', 'React.DOM' ] +0ms
  purs-loader replaced imports [ 'Prelude', 'React', 'React.DOM' ] +0ms
  purs-loader additional imports for Example.Header: [] +1ms
  purs-loader invalidating loader cache +5s
 10% 0/1 build modules  purs-loader loader called Example.Header +428ms
  purs-loader spawning compiler psa [ '--output=output', 'bower_components/purescript-*/src/**/*.purs', 'src/**/*.purs' ] +0ms
  purs-loader compiling PureScript... +0ms
  purs-loader finished compiling PureScript (code = 0) +1s
  purs-loader loading PureScript source and FFI files from [ 'bower_components/purescript-*/src/**/*.purs', 'src/**/*.purs' ] +0ms
  purs-loader rebuilt module map +82ms
  purs-loader loading JavaScript for Example.Header +0ms
  purs-loader imports [ 'Prelude', 'React', 'React.DOM' ] +1ms
  purs-loader replaced imports [ 'Prelude', 'React', 'React.DOM' ] +0ms
  purs-loader additional imports for Example.Header: [] +0ms

@ethul
Copy link
Owner

ethul commented Feb 20, 2017

My mistake. There was a typo which caused the bundle not to be generated. Please update to 2.4.0-beta.1 if you have a chance and give it a go.

Thanks!

@pbrant
Copy link
Author

pbrant commented Feb 20, 2017 via email

@ethul
Copy link
Owner

ethul commented Feb 20, 2017

Thanks for giving this another try. I am testing using webpack 1.13, but 1.14 I suspect should also work. In the output above, it looks like webpack is does produce a bundle:

bundle.js  3.48 MB       0  [emitted]  main

Which npm script are you using? npm run webpack:server:debug?

Also, just to make sure that I follow the test-case. Is it that when you break the Header.purs, webpack is not recompiling at all or is webpack rebuilding but no purescript error is reported?

Thanks!

@ethul
Copy link
Owner

ethul commented Feb 20, 2017

Quick update: I was just able to reproduce your issue. It seems that with just webpack watch we get this issue, but with the webpack dev server, things seem to work as expected. Let me take a look.

@pbrant
Copy link
Author

pbrant commented Feb 20, 2017 via email

@ethul
Copy link
Owner

ethul commented Feb 20, 2017

Welcome. Thanks for testing this out. I will have to investigate this further. It seems the compilation error is being reported to webpack, but is not displayed. If I add the following plugin to the webpack.config.js, then the error is displayed:

  plugins: [
    function() {
      this.plugin('done', function(stats){
        if (stats.compilation.errors && stats.compilation.errors.length) {
          stats.compilation.errors.forEach(function(error){
            process.stderr.write(error);
          });
        }
      });
    }
  ]

@ethul
Copy link
Owner

ethul commented Feb 20, 2017

Simplified this a little bit:

  plugins: [
    function(){
      this.plugin('done', function(stats){
        process.stderr.write(stats.toString('errors-only'));
      });
    }
  ]

If you add the above to report the compilation error, does the beta version fix this issue for you?

As a note, the bundle will not be modified if you are fixing type-related errors. It is produced if text changes, for example.

@ethul
Copy link
Owner

ethul commented Feb 20, 2017

If adding the plugin to report the error does work for you, I may track this as a limitation and consider this issue resolved.

@pbrant
Copy link
Author

pbrant commented Feb 20, 2017 via email

@ethul
Copy link
Owner

ethul commented Feb 20, 2017

Thanks for confirming! I've added a note about this plugin in the readme. Thanks again for your help.

@ethul
Copy link
Owner

ethul commented Feb 25, 2017

@ethul ethul closed this as completed Feb 25, 2017
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

2 participants