-
Notifications
You must be signed in to change notification settings - Fork 44
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
Can't use jsnlog from ES6 client application #24
Comments
So it looks like this typescript:
compiles into this js:
And exports will always be undefined so the export is never made. If I remove the
|
I understand you fixed the problem :-) Do you want to answer your SO question as well with your solution, so if someone else has the same issue and finds your SO questions, they benefit from your solution? |
It's not really fixed since I had to modify the jsnlog.js file as per above. My understanding of TypeScript and CommonJS modules is limited, but I can't see how your code would ever execute the |
Ok, I will have to look into this a bit deeper. I do want JSNLog to work seamlessly with Aurelia. Please let me know where I can find your project on Github, so I can reproduce the issue. |
My project is private so it isn't available, but I have recreated my issue by using the basic Aurelia ES6 skeleton app from the website. Using this as a basis I've update the app.js to be this: import jsnlog from 'jsnlog';
export class App {
configureRouter(config, router) {
var jsnLogger = jsnlog.JL();
jsnLogger.info(`configureRouter!`);
config.title = 'Aurelia';
config.map([
{ route: ['', 'welcome'], name: 'welcome', moduleId: 'welcome', nav: true, title: 'Welcome' },
{ route: 'users', name: 'users', moduleId: 'users', nav: true, title: 'Github Users' },
{ route: 'child-router', name: 'child-router', moduleId: 'child-router', nav: true, title: 'Child Router' }
]);
this.router = router;
}
} Which gives this error:
If I manually edit the jsnlog.js from your distribution (as I described above) and comment out the "var exports" then the logger works: //var exports;
if (typeof exports !== 'undefined') {
exports.JL = JL;
} This fixes the issue because the if can never be true since "var exports" defines exports and thus the code never executes and the JL function is never exported. |
Crap, didn't mean to close this... |
Sorry for the late reply. Thanks for pointing out this issue. I just released version 2.17.1 which implements your change (removing "var exports"). In the event that this latest version still doesn't work for you, please let me know. |
I've been struggling with how to import jsnlog in my Aurelia/ES6 application. Asked a question on SO also. One of the recommendations was to have a separate build output where typescript is set to output to ES6.
Is this a possibility or is there something I'm missing (likely).
The text was updated successfully, but these errors were encountered: