Unable to ES6 import ChartJS plugin into Aurelia - chart.js

I'm using chart.js in my Aurelia application and it works fine.
I now want to add the chartjs-plugin-deferred plugin as well, and after having npm install:ed it and added it to aurelia.json's dependencies array I now get the following error:
Uncaught TypeError: Cannot read property 'helpers' of undefined
Pointing to the first couple of lines in the plugin code:
var Chart = window.Chart;
var helpers = Chart.helpers;
(Note that I don't even need to use the plugin (import 'chartjs-plugin-deferred'; for the error to appear; as soon as it's added to aurelia.json I get errors).
If I add a console.dir(window.Chart) before the lines that throw errors it is in fact not undefined, and if I try to use the plugin in my charts it actually works fine.
Can someone explain why this error occurs and if there's some way I can get rid of it? I feel uncomfortable shipping code that, while it works as it should, throws errors in the console.
I'm a huge fan of npm and imports etc but more often than not you run into issues such as these which imo is such a hassle and actually makes me miss the good old days of just piling script elements on top of each other.
Edit: I tried with a couple more plugins just to see if perhaps the deferred plugin was the issue here, but every other plugin I tried completely kills the build.
Does anyone have experience importing ChartJS and a ChartJS plugin into Aurelia successfully?

The issue at hand is that the library does not provide any meaningful way to jump in with a module loader and properly first fully load the dependency ChartJS before carrying on with the execution.
It would be the best if the library could wrap its code in a UMD compatible format to satisfy the most common formats at once, amongst those RequireJS, which is used for the Aurelia CLI.
I see you've created a Github Issue, including the libraries author as well. Good work, I've created a small PR to add the missing feature, which then also makes the example work, without throwing the missing helper error.

Related

Object.assign() in add-on in Ember app causes problems in IE11

I have an Ember app that uses several 3rd party add-ons. One of these add-ons uses Object.assign() which causes problem in IE11, specifically the error
Error: Object doesn't support property or method 'assign'
I know why this is happening, but I'm relatively new to Ember, and am not sure of the best way to handle/fix this. Based on my research, some options are:
Option 1: use polyfills (?)
I think there may be some additional libraries I can install, or options in Babel to set that will take care of this, but I have not been able to do so thus far. It's unclear whether any of these options would affect code from add-ons anyway, or if they only apply to code in the primary app.
Option 2: extend the add-on component to avoid Object.assign().
Unfortunately, the problematic lines are in the component's init(). When my extended component calls this._super(), the code I'm trying to avoid is run anyway. Is there a way to 'skip' the base component's init() and go straight to Ember's Component.init() (the add-on's _super()) ?
Option 3: ditch the 3rd party add-on, salvage what I can, and make my own component.
Irritating but do-able. At this point, it probably would have been faster to do that from the start.
Option 4: fix the add-on to remove the problem code. My hesitation here is two fold: 1, if this is something that I should somehow be managing within my app, it doesn't seem correct to make the add-on change (though there is definitely a 'best practices' argument to be made here). The bigger concern is that this is a low activity add-on. Even if I submit a PR with the change, I'm not sure how long it will take for a new release.
In the meantime, what would be the recommended practice? Point my app to a local build and then remember to update it to an 'official' version if/when it is released?
I suspect that Option 1, polyfills and/or build settings, is the most correct course of action, but I'm at a loss for what, specifically, to do.
Additional info:
My app was developed with Ember 2.7, and I am in the process of updating it to Ember 3.1. This issue exists in both builds.
You can include polyfill:
// ember-cli-build.js
let app = new EmberApp(defaults, {
'ember-cli-babel': {
includePolyfill: true
}
});

How to use different IDE with Netsuite

I'm admittedly new to Netsuite, so this may be obvious, although I've been unable to find anything specific one way or the other. In fact, I don't even attend any training until next week, but I'm trying to get part of my development environment setup with one of the editors/IDEs I prefer. I know that Netsuite offers an Eclipse plugin, but I'm not an Eclipse fan. I'd prefer to use either WebStorm or TextMate. (I'm on MacOS Sierra)
I tried installing the WebStorm plugin, but it's throwing an exception and is not functional. I submitted a bug on GitHub, but what I'd really like to know is if it's possible for me to write my own script to upload/download files to the cabinet, so I could just roll my own feature in TextMate. Is this possible, and if so, how? (Just a link to the docs is perfectly fine)
In other words, is it possible via their API, to submit changes to a script I've been working on in another editor/IDE? Or interact with our cabinet? (Not sure if I'm using the proper NS verbiage, but hopefully you get my intent) I'm thinking about writing a Python script, that accepts a local script path as a parameter, that will then get submitted to our cabinet. Thanks for the help in advance.
I wrote a plugin for JetBrains IDEs (I use WebStorm specifically though) that mimics NetSuite's Eclipse plugin. Feel free to take a look. It is open source and has ~1500 downloads at the current moment.
https://plugins.jetbrains.com/plugin/8305?pr=
If you are the same person that opened this issue (https://github.com/Topher84/NetSuite-Tools-For-WebStorm/issues/7), it has been closed and was due to using an older version of WebStorm.
I don't like eclipse personally, so I just make my scripts in whatever and use Netsuite's script backend to upload the scripts as 'new' when I'm done. If I want to change them, simply use their backend again to 'edit' the script. You'll see a simple editor, where you can change things, or you just copy and paste what you have in there. It's a little more work than something integrated, but it does work..

Meteor Tinytest packages dependencies

I like to test my code. I like to compartmentalize my code into packages. And I like Meteor. Now I'm trying Meteor Tinytest meteor test-packages, but I'm getting some weirdness. For example:
TypeError: Cannot read property 'Email' of undefined
Because of SimpleSchema.RegEx.Email. But this code works when it's not tested. Also, SimpleSchema is an object at this point (checked through console.log), and SimpleSchema.RegEx is undefined indeed, but this is completely not what I expected.
Adding api.use('aldeed:simple-schema', ['server']); to the onTest section of package.js doesn't do anything, which is kind of expected. But I'm not sure what I am to do to fix this issue.
Apparently there's a bug: Package.js api.use() loads very old versions, which (mostly) doesn't matter for your application but it matters a lot when you're testing packages individually.
to be updated

How to write ember.js components work require.js

No code involved yet, so morning to show. I am trying to get into it.
I am writing an ember.js application, using require.js as AMD. I am trying to wrote an ember component, and having a hard time deciding what goes where.
The templates are in their own directory and loaded by need using text.js (in the 'define' statement of require), and compiled in the ember view.
As far as I understand, the components need to be in /components directory, which I have done. But what from there? At what route/view/controller do I load them, and how do I compile them? I tried just loading and compiling in the view, but that have me an error, complaining about env not being there. I tried extending Ember.Component and compiling there, but I he l got the same error.
Did someone ever implement components using require.js? Can you me a skeleton of how it looks like?
I haven't done it with require.js per se but if you download Ember App Kit, they're using EcmaScript 6 Modules.
Still, the modules are transpiled to require.js modules by es6-module-transpiler, so I assume it has to be similar. Moreover, you're free to use require.js inside the files as well.
Remember that the component's name has to be in the form: my-name, at least one dash (-) included.
Out of curiosity: why don't you use ember-cli or aforementioned Ember App Kit?

What is spy.js often seen in the console

Sorry if this is obvious but i cannot find a straight forward answer on the net so far...
What exactly is spy.js?
I keep seeing it in the console sometimes of firefox or chrome... is it somehow related to spry.js
I understand that spry is a js framework from adobe though..
spy.js is file within a firebug based development tool meant for debugging a website with nice tools (http://code.google.com/p/fbug/source/browse/branches/firebug1.4/content/firebug/spy.js?r=2796)
My guess is that spry, an ajax framework, is at times calling some jsonp that uses functions defined inside of spy.js, thus throwing a console error for the missing file if it wasn't properly loaded.
Checking that all of your dependencies are properly loaded will likely solve the problem. But i'm just guessing.