-
-
Notifications
You must be signed in to change notification settings - Fork 2.3k
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
Incomplete refactoring of function names #2107
Comments
I just briefly scanned over the source of parcel and I think it does not process inline javascript expressions put inside tags like However I found a temporary workaround, which is to just explicitly attach it to Workaround code<!DOCTYPE html>
<html>
<head>
<script>
window.exampleFunction = function exampleFunction(string) {
console.log(string.toUpperCase());
}
</script>
</head>
<body>
<input type="text" onInput="exampleFunction(this.value)">
</body>
</html> Transformed code (I beautified it because
|
Issue is still present in Parcel |
Issue is still present. |
@pizzafox I assume this has actually been fixed in Parcel 2 as we now process inline scripts properly |
Issue is still present in Parcel The output has now changed to the following (formatted): <!DOCTYPE html>
<html>
<head>
<script>
//# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJtYXBwaW5ncyI6IiIsInNvdXJjZXMiOltdLCJzb3VyY2VzQ29udGVudCI6W10sIm5hbWVzIjpbXSwidmVyc2lvbiI6MywiZmlsZSI6ImluZGV4LkhBU0hfUkVGXzA1ZmIzNmVkNWI2YTU1NTFmNWQ2OTk1YmU4OTI2YzE3LmpzLm1hcCJ9
</script>
</head>
<body>
<input type="text" oninput="exampleFunction(this.value)" />
</body>
</html> |
Appears to be fixed in the latest nightlies (as of #6247). We now treat script tags without |
🐛 bug report
Parcel minimizes JavaScript in script tags by renaming functions, but doesn't change the original function names in fields like
oninput
.🎛 Configuration
parcel build index.html
🤔 Expected Behavior
Minimize JavaScript and rename
exampleFunction
toa
. Rename references toexampleFunction
toa
as well.😯 Current Behavior
Just minimizes
exampleFunction
, not any references. This causes errors saying how that function doesn't exist.🔦 Context
I defined a function in a script tag that I wanted to refer to later in
oninput
fields on HTML tags. Since this doesn't work, I can't minimize my JavaScript with Parcel.💻 Code Sample
Open up the web inspector console and type some characters in the text box.
Now do the same with the result of
parcel build index.html
Here's the compressed code from parcel (I beautified it):
As you can see, the
oninput
field was left unchanged, causing it to error.🌍 Your Environment
The text was updated successfully, but these errors were encountered: