purs-loader
purs-loader copied to clipboard
compilation gets repeated several times on each rebuild
env
- OS: macOS 10.12.3
- PureScript: 0.11.6
- Webpack: 3.4.1
- purs-loader: 3.0.0
- purescript-psa: 0.5.1
- pulp: 11.0.0
loader config
{
test: /\.purs$/,
loader: 'purs-loader',
options: { bundle: true },
}
problem
Each time I run webpack --config webpack.config --watch
, the compilation gets repeated several times (at least 5) before it shows webpack: Compiled successfully.
. And when I modify source code to trigger rebuild, the compilation gets repeated again (less times than first startup, though).
Thanks for the report. I haven't tried the purs-loader on webpack 3.x or too much on 2.x. Perhaps there is some kind of incompatibility. I will have to investigate this further. Are you able to provide your webpack config?
I've updated the dependencies of the example and didn't notice recompilation occurring with or without bundling. Are you able to reproduce this issue using the purescript-webpack-example
?
Thanks!
Note that I did see the invalid
plugin hook being called multiple times in watch mode; however I am not sure if this is causing any issue.
I have the same issue with the config like (I left some comments there so it's easy to see which options I tried to resolve the problems):
'use strict';
const path = require('path');
const webpack = require('webpack');
const isWebpackDevServer = process.argv.filter(a => path.basename(a) === 'webpack-dev-server').length;
const isWatch = process.argv.filter(a => a === '--watch').length
const plugins =
isWebpackDevServer || !isWatch ? [] : [
function(){
this.plugin('done', function(stats){
process.stderr.write(stats.toString('errors-only'));
});
}
]
;
module.exports = {
// devtool: 'eval-source-map',
devServer: {
contentBase: '.',
port: 4008/*,
stats: 'errors-only'*/
},
entry: './src/Main.purs',
output: {
path: path.resolve(__dirname, 'output'),
publicPath: '/output/',
pathinfo: true,
filename: 'app.js'
},
module: {
rules: [
{
test: /\.purs$/,
use: [
{
loader: 'purs-loader',
options: {
exclude: /output/,
src: [
'bower_components/purescript-*/src/**/*.purs',
'src/**/*.purs'
],
bundle: true,
pscBundleArgs: {
main: "Main"
},
psc: 'psa',
watch: isWebpackDevServer || isWatch,
pscIde: false
}
}
]
},
]
},
resolve: {
modules: [ 'node_modules', 'bower_components' ],
//root: [ path.resolve('./src') ],
extensions: [ '.purs', '.js']
},
// devServer : {
// contentBase : './output'
// },
plugins: [
new webpack.LoaderOptionsPlugin({
debug: true
})
].concat(plugins)
};
I think the issue could be connected with a single entry module which is what I am trying to make work now — so without bundle: true
there is no sense in passing pscBundleArgs
(see #33). And when I do, it goes into infinite rebuild.
My bundle is located in output/app.js
file. Without a bundle
flag, It gets re-compiled well, as I see in the sources, but lacks the call of Main module, so the page is empty.
On the contrary, pulp server
is working fine with this configuration :).
Thanks for the report and config example. Out of curiosity, what version of PureScript, purs-loader, webpack, node, etc., are you using?