Skip to content
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

Exception while trying to minify moment.js and jquery.inputmask #86

Closed
xumix opened this issue Apr 27, 2016 · 17 comments
Closed

Exception while trying to minify moment.js and jquery.inputmask #86

xumix opened this issue Apr 27, 2016 · 17 comments
Labels
Milestone

Comments

@xumix
Copy link

xumix commented Apr 27, 2016

2016-04-27 17:59:41,587 [27] ERROR Umbraco.Web.UI.CdfLogger - [Thread 24] Could not write file C:\Projects\Portal\External Portal\EIIP\EIIP\scripts\moment-with-locales.min.js contents to stream. EXCEPTION: Error: JSMIN unterminated string literal: -1

System.Exception: Error: JSMIN unterminated string literal: -1

   at ClientDependency.Core.CompositeFiles.JSMin.action(Int32 d) in x:\Projects\ClientDependency\ClientDependency\ClientDependency.Core\CompositeFiles\JSMin.cs:line 183
   at ClientDependency.Core.CompositeFiles.JSMin.jsmin() in x:\Projects\ClientDependency\ClientDependency\ClientDependency.Core\CompositeFiles\JSMin.cs:line 135
   at ClientDependency.Core.CompositeFiles.JSMin.Minify(String src) in x:\Projects\ClientDependency\ClientDependency\ClientDependency.Core\CompositeFiles\JSMin.cs:line 62
   at ClientDependency.Core.CompositeFiles.Providers.BaseCompositeFileProcessingProvider.MinifyFile(String fileContents, ClientDependencyType type) in x:\Projects\ClientDependency\ClientDependency\ClientDependency.Core\CompositeFiles\Providers\BaseCompositeFileProcessingProvider.cs:line 587
   at ClientDependency.Core.CompositeFiles.DefaultFileWriter.WriteContentToStream(BaseCompositeFileProcessingProvider provider, StreamWriter sw, String content, ClientDependencyType type, HttpContextBase context, String originalUrl) in x:\Projects\ClientDependency\ClientDependency\ClientDependency.Core\CompositeFiles\DefaultFileWriter.cs:line 65
   at ClientDependency.Core.CompositeFiles.DefaultFileWriter.WriteToStream(BaseCompositeFileProcessingProvider provider, StreamWriter sw, FileInfo fi, ClientDependencyType type, String origUrl, HttpContextBase http) in x:\Projects\ClientDependency\ClientDependency\ClientDependency.Core\CompositeFiles\DefaultFileWriter.cs:line 22
@xumix
Copy link
Author

xumix commented Apr 27, 2016

Including inputmask

Html.RequiresJs("~/scripts/jquery.inputmask/inputmask.min.js", 20, 100);
        Html.RequiresJs("~/scripts/jquery.inputmask/jquery.inputmask.min.js", 210, 100);
        Html.RequiresJs("~/scripts/jquery.inputmask/inputmask.extensions.min.js", 220, 100);
        Html.RequiresJs("~/scripts/jquery.inputmask/inputmask.numeric.extensions.min.js", 230, 100);
        Html.RequiresJs("~/scripts/jquery.inputmask/inputmask.regex.extensions.min.js", 240, 100);

gives this on client:

18:02:09.795 TypeError: b is undefined
<anonymous> js:8
<anonymous> js:8
<anonymous> js:8
1 js:8:283

@Shazwazza
Copy link
Owner

What version are you using? 1.9.0-beta? https://www.nuget.org/packages/ClientDependency/1.9.0-beta

@xumix
Copy link
Author

xumix commented Apr 28, 2016

Same for 1.9-beta

2016-04-28 11:43:45,417 [83] INFO  umbraco.BusinessLogic.Log - [Thread 93] Log scrubbed.  Removed all items older than 2016-02-28 11:43:45
2016-04-28 11:43:49,005 [83] ERROR Umbraco.Web.UI.CdfLogger - [Thread 93] Could not write file C:\Projects\Portal\External Portal\EIIP\EIIP\scripts\jquery.inputmask\inputmask.min.js contents to stream. EXCEPTION: Error: JSMIN Unterminated Regular Expression literal: -1

System.Exception: Error: JSMIN Unterminated Regular Expression literal: -1

   at ClientDependency.Core.CompositeFiles.JSMin.HandleRegexLiteral() in X:\Projects\ClientDependency\ClientDependency\ClientDependency.Core\CompositeFiles\JSMin.cs:line 505
   at ClientDependency.Core.CompositeFiles.JSMin.Action(Int32 d) in X:\Projects\ClientDependency\ClientDependency\ClientDependency.Core\CompositeFiles\JSMin.cs:line 233
   at ClientDependency.Core.CompositeFiles.JSMin.ExecuteJsMin() in X:\Projects\ClientDependency\ClientDependency\ClientDependency.Core\CompositeFiles\JSMin.cs:line 192
   at ClientDependency.Core.CompositeFiles.JSMin.Minify(TextReader reader) in X:\Projects\ClientDependency\ClientDependency\ClientDependency.Core\CompositeFiles\JSMin.cs:line 97
   at ClientDependency.Core.CompositeFiles.JSMin.CompressJS(Stream stream) in X:\Projects\ClientDependency\ClientDependency\ClientDependency.Core\CompositeFiles\JSMin.cs:line 63
   at ClientDependency.Core.CompositeFiles.Providers.BaseCompositeFileProcessingProvider.MinifyFile(Stream fileStream, ClientDependencyType type) in X:\Projects\ClientDependency\ClientDependency\ClientDependency.Core\CompositeFiles\Providers\BaseCompositeFileProcessingProvider.cs:line 612
   at ClientDependency.Core.CompositeFiles.DefaultFileWriter.WriteContentToStream(BaseCompositeFileProcessingProvider provider, StreamWriter sw, Stream stream, ClientDependencyType type, HttpContextBase context, String originalUrl) in X:\Projects\ClientDependency\ClientDependency\ClientDependency.Core\CompositeFiles\DefaultFileWriter.cs:line 110
   at ClientDependency.Core.CompositeFiles.DefaultFileWriter.WriteToStream(BaseCompositeFileProcessingProvider provider, StreamWriter sw, FileInfo fi, ClientDependencyType type, String origUrl, HttpContextBase http) in X:\Projects\ClientDependency\ClientDependency\ClientDependency.Core\CompositeFiles\DefaultFileWriter.cs:line 23

@xumix
Copy link
Author

xumix commented Apr 28, 2016

Same error for not minified inputmask:

2016-04-28 11:46:34,651 [83] ERROR Umbraco.Web.UI.CdfLogger - [Thread 127] Could not write file C:\Projects\Portal\External Portal\EIIP\EIIP\scripts\jquery.inputmask\inputmask.js contents to stream. EXCEPTION: Error: JSMIN Unterminated Regular Expression literal: -1

System.Exception: Error: JSMIN Unterminated Regular Expression literal: -1

   at ClientDependency.Core.CompositeFiles.JSMin.HandleRegexLiteral() in X:\Projects\ClientDependency\ClientDependency\ClientDependency.Core\CompositeFiles\JSMin.cs:line 505
   at ClientDependency.Core.CompositeFiles.JSMin.Action(Int32 d) in X:\Projects\ClientDependency\ClientDependency\ClientDependency.Core\CompositeFiles\JSMin.cs:line 233
   at ClientDependency.Core.CompositeFiles.JSMin.ExecuteJsMin() in X:\Projects\ClientDependency\ClientDependency\ClientDependency.Core\CompositeFiles\JSMin.cs:line 192
   at ClientDependency.Core.CompositeFiles.JSMin.Minify(TextReader reader) in X:\Projects\ClientDependency\ClientDependency\ClientDependency.Core\CompositeFiles\JSMin.cs:line 97
   at ClientDependency.Core.CompositeFiles.JSMin.CompressJS(Stream stream) in X:\Projects\ClientDependency\ClientDependency\ClientDependency.Core\CompositeFiles\JSMin.cs:line 63
   at ClientDependency.Core.CompositeFiles.Providers.BaseCompositeFileProcessingProvider.MinifyFile(Stream fileStream, ClientDependencyType type) in X:\Projects\ClientDependency\ClientDependency\ClientDependency.Core\CompositeFiles\Providers\BaseCompositeFileProcessingProvider.cs:line 612
   at ClientDependency.Core.CompositeFiles.DefaultFileWriter.WriteContentToStream(BaseCompositeFileProcessingProvider provider, StreamWriter sw, Stream stream, ClientDependencyType type, HttpContextBase context, String originalUrl) in X:\Projects\ClientDependency\ClientDependency\ClientDependency.Core\CompositeFiles\DefaultFileWriter.cs:line 110
   at ClientDependency.Core.CompositeFiles.DefaultFileWriter.WriteToStream(BaseCompositeFileProcessingProvider provider, StreamWriter sw, FileInfo fi, ClientDependencyType type, String origUrl, HttpContextBase http) in X:\Projects\ClientDependency\ClientDependency\ClientDependency.Core\CompositeFiles\DefaultFileWriter.cs:line 23

@Shazwazza
Copy link
Owner

Which inputmask version files are you using so i can test?

@xumix
Copy link
Author

xumix commented Apr 28, 2016

The latest one: 3.2.3, same here for moment.js

@Shazwazza
Copy link
Owner

I cannot replicate this with 3.2.3, however the 'latest' version is 3.3.1 from here which i can replicate: https://github.com/RobinHerbots/jquery.inputmask/releases/tag/3.3.1

I've tested with your exact configuration:

Html.RequiresJs("~/scripts/jquery.inputmask/inputmask.min.js", 20, 100);
        Html.RequiresJs("~/scripts/jquery.inputmask/jquery.inputmask.min.js", 210, 100);
        Html.RequiresJs("~/scripts/jquery.inputmask/inputmask.extensions.min.js", 220, 100);
        Html.RequiresJs("~/scripts/jquery.inputmask/inputmask.numeric.extensions.min.js", 230, 100);
        Html.RequiresJs("~/scripts/jquery.inputmask/inputmask.regex.extensions.min.js", 240, 100);

The problem seems to be some syntax in inputmask.min.js which is unsupported for some reason.

It's worth noting that older versions of input mask don't have this issue, it's also worth nothing that the original JsMin has this bug along with the updated version of JsMin I've been supporting (which is part of 1.9.0-beta) https://github.com/shazwazza/jsminsharp

@Shazwazza Shazwazza added the bug label Apr 30, 2016
@Shazwazza Shazwazza added this to the 1.9.0 milestone Apr 30, 2016
@Shazwazza
Copy link
Owner

And just to note why this error is happening. It's due to the minifier that this library is using which ends up just executing a regex statement for no reason on a single line:

Specifically this one right at the end

/android.*safari.*/i.test(i)&&!k;

which actually performs no function, this is a no-op function so can only assume it's an issue with the minifier used for this library or an error with the original code. In any case, JsMin should still be able to deal with this so i'll fix up.

@Shazwazza
Copy link
Owner

I've fixed the issue: Shazwazza/JsMinSharp#8 will port this over to CDF very soon.

@Shazwazza
Copy link
Owner

I'll post up a new beta version soon

@xumix
Copy link
Author

xumix commented Apr 30, 2016

That is great! However, I've had this issue with non minified version too. Same error with moment. Js without inputmask

@Shazwazza
Copy link
Owner

@Shazwazza
Copy link
Owner

I just tested with the non-min version and all works, haven't checked moment yet but if it's the same error I think it's the same issue

@xumix
Copy link
Author

xumix commented Apr 30, 2016

Well, now it has no exception, but still has the error on client after minification
I've attached the minified demo
Archive.zip

@Shazwazza
Copy link
Owner

did you bump your cdf version in config to make sure nothing is coming from a corrupted cached version?

@xumix
Copy link
Author

xumix commented Apr 30, 2016

wow! thank you so much :)

@Shazwazza
Copy link
Owner

Great! Thanks for reporting, i'll release a non-beta version soon

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants