Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Repo info
Activity
    Andrew Throener
    @trainerbill

    changed to master branch and getting:

    TypeError in plugin 'gulp-babel'
    Message:
    Filename must be a string

    speedskater
    @speedskater
    @trainerbill I think you can just use the main branch and run 1.0.0-rc-1 as this is the current default version. the babel6-support branch is quite old
    Eli White
    @TheSavior
    @speedskater I’m pretty excited about this version but it looks like it doesn’t quite work with our system at work yet
    Andrew Throener
    @trainerbill
    @speedskater Yeah I got it working. I also had rewire installed which it was choking on.

    @speedskater on thing I am noticing is that Rewire isn't available on a * import:

    import * as mymodule from './mymodule;

    mymodule.Rewire is undefined. if I have a export default fallback it seems to work. Is that your suggested use?

    Andrew Throener
    @trainerbill

    @speedskater came across an edge case. I am getting:

    Duplicate declaration "typeOfOriginalExport" (This is an error on an internal node. Probably an internal error)

    and I think its because it is doing the rewire twice. I am using gulp babel and also a build procedure with a dynamic require. Is there a check to see if the import/require has already been rewired?

    Eli White
    @TheSavior
    @trainerbill Did you search the issues? speedskater/babel-plugin-rewire#106
    Andrew Throener
    @trainerbill
    thx @TheSavior. Did you find a work around?
    Eli White
    @TheSavior
    Nope. We are still on babel5 because of it
    I’m curious how similar of an environment you are in to us
    Are you using browserify with babelify?
    Andrew Throener
    @trainerbill
    no. I am working on the server side in Node
    Eli White
    @TheSavior
    Did you look at the repro repo that I put up?
    You should see if you have a similar situation of requires
    Andrew Throener
    @trainerbill
    but i have a build process that builds to a folder, then I have a dynamic require(cause I can't get systemjs to work) and I am requiring a file out of the build folder which is now rewiring twice. once in the build and once again in the gulp test process with mocha
    Eli White
    @TheSavior
    If not, you should comment out all of the code in your project until the error goes away and put up the smallest test repo you can
    It would help us make sure both of our situations are taken care of
    Andrew Throener
    @trainerbill
    that would be tough... I am going to look through the plugin code and see if I can fix it quick. will report back
    there is a wasProcessed
    so it seems like this was at least thought of
    Eli White
    @TheSavior
    It shouldn’t be that hard to track down. There is one file in your require tree that if you require that, it has requires that fail. Just gotta find that file, and which require it fails on
    Andrew Throener
    @trainerbill
    I know what one it is... I have a glob that dynamically imports custom modules
    but I am writing tests for it so I kinda need it in there...
    Andrew Throener
    @trainerbill
    @TheSavior So when I just do a straight build should i not see the __noRewire somewhere? It seems like that is what prevents the plugin from trying to rewire again... but on my builds I am not seeing it anywhere.
    Eli White
    @TheSavior
    Truthfully, I’m not sure
    Andrew Throener
    @trainerbill
    just spit balling to try and get a resolution so they can fix it faste
    speedskater
    @speedskater
    @trainerbill Can you provide your sample file in a PR (similar to the existing samples) ?
    Regarding the wildcard import. This is intentional. The reason is by allowing to import the rewire to exist on a wildcard import it may break existing code. E.g. it would be possible another module using your module expectes that only certain functions or objects are exported and breaks on the rewiring api. But you can use a named import to get to the API.
    Jason English
    @jasonenglish
    Does rewire work with external libs? I'm able to get it to work with my existing modules, but when trying to rewire a lib I import, none of the rewire api exists.
    speedskater
    @speedskater
    @jasonenglish Theoretically if you transform the code of the external library it should work as well. What is your reason to do this?
    Jason English
    @jasonenglish
    @speedskater jasmine unit tests where it expects that the method is called with the correct arguments
    @speedskater is there a better practice for testing function calls from external libraries?
    speedskater
    @speedskater
    @jasonenglish Maybe. Assume you want to test your module A, which has a dependency to module B, where B is an external module. In this case you only have to transform module A because. By transforming module A you are able to rewire the dependencies to methods of B within A. This allows you to track and spy on the external calls. Does this answer your question?
    Jason English
    @jasonenglish
    @speedskater I think it might, I'll try doing that. thanks!
    Richard Marks
    @RichardMarks

    I am trying to get babel-plugin-rewire@1.0.0-rc-2 to work on a babel 6 karma mocha webpack setup, and I have followed the instructions in the readme, and I am ending up with the following error

    Uncaught TypeError: Cannot read property 'Rewire' of undefined

    Any advice/assistance would be most appreciated

    that is double underscore Rewire double underscore ... gitter interpreted it as markdown oops
    Uncaught TypeError: Cannot read property '__Rewire__' of undefined
    there
    Gavri (Gabriel) Guy
    @gavriguy
    I tried to search for it but couldn’t get a clear answer - is there a way to rewire an es6 class instance method?
    speedskater
    @speedskater
    @RichardMarks do you have a sample for your problem?
    @gavriguy rewireing only instance methods is not possible. But you can rewire the class itself.
    @TheSavior a new version rc-3 is out there with your PR.
    @/all I will again have a look at some issues on the upcoming monday.
    Eli White
    @TheSavior
    @speedskater Thank you very much!
    Robert Stiff
    @uatec
    greetings
    speedskater
    @speedskater
    Hi. And sorry to everybody for the delays. I was quite busy due to a release at my company. I will be on hollidays for the upcoming two weeks and will try to work on issues and PR in the week starting at Monday June 27th.
    David Fox-Powell
    @dtothefp
    having issues with dynamic require in es6 file yelling that require is undefined
    //entry.js
    import thingToRewire from './thing'
    
    //thing.js
    export default thing () {
      require('./stuff')
    }
    speedskater
    @speedskater
    @dtothefp can you provide a sample project with your exact configuration?
    @/all published 1.0.0-rc-4
    Vincent Schramer
    @scvnc
    Sort of unrelated discussion: I really enjoy the testing patterns that rewire enables.. does anyone know about some strategies for applying it to TypeScript? Is there a way to use this with TypeScript or some typescript-plugin-rewire equivalent?
    Uladzimir Havenchyk
    @havenchyk
    Hi there! Is it possible to mock out the import from imported component?