Hi all,
This isn’t directly related to Elm, but as there is lots of helpful and friendly knowledge around here, I thought I’d ask.
I have an Elixir/Phoenix app that I’ve been working on for most of this year, and have just hit an issue that prevents me from deploying to production. The front end is an Elm SPA.
I would normally build my assets/js with Webpack using Terser to mangle the JS etc…
The build command is:
npm run deploy --prefix assets/
This would compile the Elm files to JS, minify and mangle the JS etc.
My issue is simple - if I change any of my Elm code, or my JS, npm run ...
compiles Elm to JS, but then hangs - I’m guessing it’s a Terser issue, but not sure.
It doesn’t matter if I add, change or remove any code, simply changing a variable name, or changing a character in a string
causes npm run...
to hang and not complete - it’s almost as if there’s a cache somewhere that needs rebuilding - but I’ve not been able to find it.
Node: 14.2.0
Phoenix: 1.5.7
Webpack:
const path = require('path');
const glob = require('glob');
const TerserPlugin = require('terser-webpack-plugin');
const CopyWebpackPlugin = require('copy-webpack-plugin');
module.exports = (env, options) => {
const devMode = options.mode !== 'production';
return {
optimization: {
minimizer: [
new TerserPlugin({
terserOptions: {
ecma: 5,
compress: {
pure_funcs: [
"F2",
"F3",
"F4",
"F5",
"F6",
"F7",
"F8",
"F9",
"A2",
"A3",
"A4",
"A5",
"A6",
"A7",
"A8",
"A9"
],
pure_getters: true,
keep_fargs: false,
unsafe_comps: true,
unsafe: true,
passes: 2
},
mangle: true
}
}),
]
},
entry: {
'app': glob.sync('./vendor/**/*.js').concat(['./js/app.js'])
},
output: {
filename: '[name].js',
path: path.resolve(__dirname, '../priv/static/js'),
publicPath: '/js/'
},
devtool: devMode ? 'eval-cheap-module-source-map' : undefined,
module: {
rules: [
{
test: /\.js$/,
exclude: /node_modules/,
use: {
loader: 'babel-loader'
}
},
{
test: /\.elm$/,
exclude: [/elm-stuff/, /node_modules/],
use: {
loader: 'elm-webpack-loader',
options: {
cwd: __dirname,
debug: false, //options.mode === "development",
optimize: options.mode === "production"
}
}
}
]
},
plugins: [
new CopyWebpackPlugin([{ from: 'static/', to: '../' }])
]
}
};
I’m struggling on how to resolve this, so any suggestions would be greatly appreciated.
What I don’t understand is why simply changing a character in a string
would cause this process to fail, unless there’s some sort of lock file preventing the process from completing.