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

Add Support for ES6 #26

Closed
wruth opened this issue Nov 30, 2016 · 4 comments
Closed

Add Support for ES6 #26

wruth opened this issue Nov 30, 2016 · 4 comments

Comments

@wruth
Copy link

wruth commented Nov 30, 2016

Spur IOC breaks for fat arrow function syntax in ES6. For instance, I got this error when I attempted to run the ES6 code directly without babel transpilation:

/Users/wruth/workspace/ot-microsite-address-validation-service/node_modules/spur-ioc/src/Util.coffee:11
      params = fn.toString().replace(/\n/g, ' ').replace(/_at_/g, '').match(/function\s+\w*\s*\((.*?)\)/)[1].split(/\s*,\s*/);
                                                                                                         ^

TypeError: Cannot read property '1' of null
  at Util.parseDependencies (/Users/wruth/workspace/ot-microsite-address-validation-service/node_modules/spur-ioc/src/Util.coffee:9:46)
  at Function.Dependency.resolvableDependency (/Users/wruth/workspace/ot-microsite-address-validation-service/node_modules/spur-ioc/src/Dependency.coffee:15:29)
  at Injector.ContainerManagement.addResolvableDependency (/Users/wruth/workspace/ot-microsite-address-validation-service/node_modules/spur-ioc/src/ContainerManagement.coffee:16:38)

I believe this is a consequence of Util.js looking for the String 'function' in parseDependencies(), and not being able to find it in these cases.

@acolchado
Copy link
Collaborator

@wruth Thanks for reporting. Yeah, I ran into that when making the changes and documented it, but can't recall where.

I will document the work around and share out in the documentation. Since there is a pretty straight forward workaround, we will not be prioritizing it over the other work scheduled for the libraries. It will be a focus soon enough, but I don't have an ETA for that.

cc @ssetem Any ideas/suggestions?

@ssetem
Copy link
Contributor

ssetem commented Nov 30, 2016

yeh right now the top module.exports=function(dep1, dep2){ ... needs to remain

Have been using spur-ioc alot recently, not much advantage changing the top declaration to es6 syntax

@acolchado
Copy link
Collaborator

@ssetem Yeah. That's what I initial thought, just didn't seem to document.

@morewry
Copy link

morewry commented Dec 8, 2016

I think it's useful in unit tests. See #31 and spur unit tests, where dependencies often get set to this.Dependency in order to make them available from a beforeEach in a later spec. I'd also personally expect to be able to use any valid JavaScript syntax. Just my 2 cents.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants