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

onScriptComplete is not defined under Firefox 40 #7263

Closed
aleen42 opened this issue May 10, 2018 · 3 comments · Fixed by #7411
Closed

onScriptComplete is not defined under Firefox 40 #7263

aleen42 opened this issue May 10, 2018 · 3 comments · Fixed by #7411

Comments

@aleen42
Copy link
Contributor

aleen42 commented May 10, 2018

Bug report

What is the current behavior?

During bootstrap, onScriptComplete has an error script when runing under Firefox 40+

If the current behavior is a bug, please provide the POC.

Error script was thrown by the script generated by lib/web/JsonpMainTemplatePlugin.js.

I have tested that it did not seem the problem of hoisted, as the following snippet has worked under Firefox 40:

(function () {
    console.log(test);
    function test() {}
})();

The real reason is that function onScriptComplete has been declared inside a condition block rather than a function block (As a common sense, functions declaration must be placed at the root of a function block, no-inner-declaration):

if (true) {
    /** throw an error: func is not defined */
    console.log(func);
    function func () {}
}

Other relevant information:
webpack version: 4.4.1
Node.js version: v7.10.1
Operating System: Windows 10

@aleen42
Copy link
Contributor Author

aleen42 commented May 10, 2018

Someones has created a PR before, #7210, which resolution seems wrong. And is it necessary to create another PR?

@alexander-akait
Copy link
Member

@aleen42 feel free to send pr

@aleen42
Copy link
Contributor Author

aleen42 commented May 15, 2018

The PR #7210 has been waited for merging, and what is the current stage? If it is merged, this issue can be solved at the same time. @

aleen42 pushed a commit to aleen42/webpack that referenced this issue May 28, 2018
aleen42 added a commit to aleen42/webpack that referenced this issue May 28, 2018
aleen42 added a commit to aleen42/webpack that referenced this issue May 28, 2018
aleen42 added a commit to aleen42/webpack that referenced this issue May 29, 2018
revert changes of webpack#7210, and use a varaible declaration outside a condition block instead, according to https://eslint.org/docs/rules/no-inner-declarations
aleen42 added a commit to aleen42/webpack that referenced this issue May 29, 2018
revert changes of webpack#7210, and use a varaible declaration outside a condition block instead, according to https://eslint.org/docs/rules/no-inner-declarations
aleen42 added a commit to aleen42/webpack that referenced this issue May 29, 2018
Use a varaible declaration outside a condition block instead, according to https://eslint.org/docs/rules/no-inner-declarations
aleen42 added a commit to aleen42/webpack that referenced this issue May 29, 2018
Use a varaible declaration outside a condition block instead, according to https://eslint.org/docs/rules/no-inner-declarations
aleen42 added a commit to aleen42/webpack that referenced this issue May 29, 2018
aleen42 added a commit to aleen42/webpack that referenced this issue May 29, 2018
aleen42 added a commit to aleen42/webpack that referenced this issue May 29, 2018
sokra added a commit that referenced this issue May 29, 2018
fix: unsupported function defined inside a condition block. #7263
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants