Skip to content
This repository has been archived by the owner on Feb 26, 2024. It is now read-only.

Function declarations in lib/keys.js broken when Webpack is used #194

Closed
ivankashtanov opened this issue Oct 22, 2015 · 3 comments
Closed

Comments

@ivankashtanov
Copy link

Webpack turns function declarations of create in lib/keys.js into function expressions. The relevant part looks like this after Webpack processing:

if (typeof _Symbol !== 'undefined') {
    var _create = function _create(name) {
        return _Symbol(name);
    };
} else {
    var _create2 = function _create2(name) {
        return '_zone$' + name;
    };
}

var commonKeys = {
    addEventListener: create('addEventListener'),
    removeEventListener: create('removeEventListener')
};

As a result, create is not defined when used for properties of commonKeys and it breaks initialzation as far as I understand.
I'm not sure if it's zone.js bug or Webpack's, but JSHint also gives a warning on these two declarations so I decided to report it here. Here's the warning text:
Function declarations should not be placed in blocks. Use a function expression or move the statement to the top of the outer function. (W082)

vicb added a commit to vicb/zone.js that referenced this issue Oct 22, 2015
@vicb
Copy link
Contributor

vicb commented Oct 22, 2015

@ivankashtanov thanks for reporting, could you please test with #195 and let us know how this works - I have included the generated js file in the second commit for now if it could help you.

@ivankashtanov
Copy link
Author

Replaced keys.js file with the new one, app is initialzed without errors now.

@vicb
Copy link
Contributor

vicb commented Oct 22, 2015

Thanks !

@vicb vicb closed this as completed in d44d699 Oct 23, 2015
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants