Repository navigation
Closed
Description
Input Code
/**
* Dependencies
*/
import $ from 'jquery';
import $doc from '../../shared/$doc.js';
/**
* User panel service
*/
class UserPanelService {
/**
* Constructor
*/
constructor() {
//ID
this.id = 'UserPanel';
//Classes
this.cToggle = 'UserPanelToggle';
}
/**************************************************************************
* Initialisation
***/
/**
* Initialisation
*/
init() {
this.findElements();
this.bindToggleHandlers();
this.bindGlobalCloseHandler();
}
/**
* Find elements
*/
findElements() {
this.$userPanel = $(`#${this.id}`);
}
/**
* Bind toggle handlers
*/
bindToggleHandlers() {
$doc
.on('click', `.${this.cToggle}`, () => {
this.toggle();
});
}
/**
* Bind global close handler
*/
bindGlobalCloseHandler() {
$doc
.on('click', event => {
//Not visible?
if (!this.isVisible()) {
return;
}
//Get target
const $target = $(event.target);
const $parents = $target.parents(`.${this.cToggle}`);
//Clicked on user panel
if (this.$userPanel[0].contains($target[0])) {
return;
}
//Clicked on toggle
if ($target.hasClass(this.cToggle) || $parents.length > 0) {
return;
}
//Hide
this.hide();
});
}
/**************************************************************************
* Panel visibility
***/
/**
* Check if visible
*/
isVisible() {
return this.$userPanel.is(':visible');
}
/**
* Toggle the user panel
*/
toggle() {
this.$userPanel.toggle();
}
/**
* Hide the user panel
*/
hide() {
this.$userPanel.hide();
}
/**
* Show the user panel
*/
show() {
this.$userPanel.show();
}
}
/**
* Export service singleton
*/
export default new UserPanelService();Forgive me, it's using jQuery, I had to for this project 😩
Actual Output
TypeError: app/components/app/header/user-panel.service.js: Cannot read property 'add' of undefined
at ScopeTracker.addReference (/node_modules/babel-plugin-minify-mangle-names/lib/scope-tracker.js:55:36)
at ReferencedIdentifier (/node_modules/babel-plugin-minify-mangle-names/lib/index.js:191:28)
at newFn (/node_modules/babel-traverse/lib/visitors.js:318:17)
at bfsTraverse (/node_modules/babel-plugin-minify-mangle-names/lib/bfs-traverse.js:34:43)
at Mangler.collect (/node_modules/babel-plugin-minify-mangle-names/lib/index.js:270:9)
at Mangler.run (/node_modules/babel-plugin-minify-mangle-names/lib/index.js:70:14)
at PluginPass.exit (/node_modules/babel-plugin-minify-mangle-names/lib/index.js:590:19)
at newFn (/node_modules/babel-traverse/lib/visitors.js:276:21)
at NodePath._call (/node_modules/babel-traverse/lib/path/context.js:76:18)
at NodePath.call (/node_modules/babel-traverse/lib/path/context.js:48:17)
error An unexpected error occurred: "Command failed.\nExit code: 1\nCommand: sh\nArguments: -c babel app --out-file dist/app.min.js --ignore spec.js".
Expected Output
Compiled JS
Details
My .babelrc
{
"presets": [
["env", {
"targets": {
"browsers": ["last 2 versions"]
}
}],
"minify"
],
"env": {
"production": {
"presets": ["minify"]
}
},
"plugins": [
["module-resolver", {
"alias": {
"app": "./app/components"
}
}]
]
}
Versions:
"babel-cli": "^6.26.0",
"babel-core": "^6.26.0",
"babel-plugin-module-resolver": "^3.0.0",
"babel-preset-env": "^1.6.1",
"babel-preset-minify": "^0.3.0",
Reacted by Muneeb Baderoen and Stas
Metadata
Metadata
Assignees
Labels
No labels
Activity
[-]TypeError: app/components/app/header/user-panel.service.js: Cannot read property 'add' of undefined[/-][+]TypeError: Cannot read property 'add' of undefined[/+]sriksm19 commentedon Feb 14, 2018
any update on this?
StK88 commentedon Feb 16, 2018
Looks like it's related to #556
adamreisnz commentedon Feb 16, 2018
Yeah looks like it might be actually, I wonder why it has been closed though as it's clearly still an issue.
cilliemalan commentedon Feb 23, 2018
babel-minify-webpack-plugin worked for me (and it uses
babel-preset-minify)boopathi commentedon Feb 28, 2018
Duplicate of #556. This was fixed with babel-7 and now
masteris using babel-7.To get latest canary release - https://github.com/babel/minify/tree/master/docs#canary-version
If you still face this error in the latest master, please comment here to reopen the issue.
Add missing scopes when adding reference to scope tracker