-
Notifications
You must be signed in to change notification settings - Fork 81
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
NullReferenceException and expected identifiers/expressions with const+module.exports #94
Comments
Same here. If you can switch from package to code, then for a quick workaround you can replace the body of the first if statement at NUglify.JavaScript.JSParser.PeekCanBeModule: original:
replacement:
|
Ah, then it looks like NUglify is parsing out the ECMA version before going further. That makes sense. The bundle I was trying to minify with BuildBundlerMinifier had one file that was essentially vendor code that was pre-compiled into lower ECMA code and then pre-minified, and another file that was our raw JS code that was only minified. One solution would be to split these into different bundles, or at least more strongly define ECMA versions and keep bundles at similar versions. However, I think that a NullReferenceException is still a red flag here. |
This looks like it relates to #80 |
isn't valid JS, because you shouldn't be redefining Admittedly NUglify shouldn't explode because of this, so I'll try and fix that. |
This also fixes cases like this
|
@devIceMan Is there any need for this in your code
Shouldnt that whole block just be return false? i.e. if you have It seems any variable named |
@trullock yes, you right - in "module.ANYTHING" situation it should returning false without any futher check |
Agree, just pushed 1.6.3 with this change in |
I am getting two errors that are unexpected. One is a NullReferenceException, and the other is "Expected expression: ." and "Expected identifier: ." in a couple scenarios.
I've been able to narrow down the issue to make small snippets.
First, a passing scenario:
This compiles to
function test(n){n.exports=function(){}}var test="1";
.Failure 1: NullReferenceException
Change
var test
toconst test
.I get a NullReferenceException in https://github.com/xoofx/NUglify/blob/v1.5.14/src/NUglify/JavaScript/Syntax/MemberExpression.cs#L70 because
Root
is null.Failure 2: Expected expression/identifier
Change
function () { }
to"1"
.The location of these two errors are on the dot after
module
.As far as I know, neither module nor exports are not reserved keywords in JavaScript. I am not sure what is going wrong here. This particular issue was with the combination of a plain .js file that happens to use
const
here and there, bundled with (see: BundleBuilderMinifier) a .min.js file that happens to use module and exports as function parameters/arguments.The solution for now is to not use
const
. I was under the impression that this wasn't a new JS addition, and that it would make something like NUglify parse it any different. We are moving away from a runtime-bundling of our files withMicrosoft.Ajax.Utilities.Minifier
and instead using build-time-bundling with BundleBuilderMinifier, and this may cause issues with certain bundles.Any help would be appreciated!
The text was updated successfully, but these errors were encountered: