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
Runtime error after build with --optimize #64
Comments
Hi!
Another guess is that this is an uglify-js bug, or a bug in my example configuration of uglify-js. |
Thank you for fast response! the issue goes away if I remove this line from my elm-watch.json:
So seems related to uglify or the postprocess.js file |
Yeah I've had encountered something similar – strangely always and only when more than one elm-ui element inside a centered column/row is centered.
I'd say this is highly likely, especially because configurations with for example only eol2 don't break the app in these situations. |
aha.. The error goes away if i replace my Input.text element with (text "test") |
It would be amazing if you could reduce your code into a small example that reproduces the issue. Then we could dig deeper into uglify-js:
|
Here is a small example that crashes: Main.elm module Main exposing (main)
import Element
import Element.Input as Input
type Msg
= NoOp
main =
Element.layout [] -- Converts from Element to Html
(Input.text
[]
{ label = Input.labelHidden ""
, onChange = always NoOp
, placeholder = Nothing
, text = ""
}
) Other files for reference: Index.html <!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>example-minimal</title>
</head>
<body>
<div id="root"></div>
<script src="./build/main.js"></script>
<script>
Elm.Main.init({ node: document.getElementById("root") });
</script>
</body>
</html> package.json {
"type": "module",
"devDependencies": {
"esbuild": "^0.18.0",
"uglify-js": "^3.17.4"
}
} elm-watch.json {
"postprocess": ["elm-watch-node", "postprocess.js"],
"targets": {
"My target name": {
"inputs": ["src/Main.elm"],
"output": "build/main.js"
}
}
} elm.json {
"type": "application",
"source-directories": [
"src"
],
"elm-version": "0.19.1",
"dependencies": {
"direct": {
"elm/browser": "1.0.2",
"elm/core": "1.0.5",
"elm/html": "1.0.0",
"mdgriffith/elm-ui": "1.1.8"
},
"indirect": {
"elm/json": "1.1.3",
"elm/time": "1.0.0",
"elm/url": "1.0.0",
"elm/virtual-dom": "1.0.3"
}
},
"test-dependencies": {
"direct": {},
"indirect": {}
}
} And the postprocess.js file is alos copied from this repo/example |
Small update so far: By trial and error I have found that if I comment out |
Other notes:
$mdgriffith$elm_ui$Element$Input$hasFocusStyle = function (attr) {
- return (
- 4 === attr.$ &&
- 11 === attr.b.$ &&
- !attr.b.a &&
- ((attr = attr.b), attr.a, true)
- );
+ return attr.b.a, 4 === attr.$ && 11 === attr.b.$ && !attr.b.a && true;
}, That transformation is wrong. Currently trying to reduce the compiled JS to make a small example that can be reported to uglify (or searched for in their issue tracker). |
New finding: Adding |
I managed to make a bug report for uglify: mishoo/UglifyJS#5794 |
First of all, Amazing tool !
Works perfect for me in development, but tried to build a production version just now and got this error:
( Seems to be a elm-ui text input )
I am using the postprocess.js file from the example here with no modifications.
Any idea what can cause this?
Also, the editor shows an error here. (But no errors when building)
dependency versions:
The text was updated successfully, but these errors were encountered: