Git Product home page Git Product logo

Comments (18)

speedskater avatar speedskater commented on June 11, 2024

@srph It seems that this issue is related to #57
as well as #62. As soon as a new version is available which sould happen within the next hours this should solve your issue.

from babel-plugin-rewire.

srph avatar srph commented on June 11, 2024

Really, really thanks 💘 . Looking forward to it 😄

from babel-plugin-rewire.

speedskater avatar speedskater commented on June 11, 2024

@srph :). Could you please try the beta version 0.1.23-beta-3. And let me know if this fixes the issue for you?

from babel-plugin-rewire.

srph avatar srph commented on June 11, 2024

I got new errors:

Uncaught TypeError: Cannot assign to read only property '__GetDependency__' of [object Object]

from babel-plugin-rewire.

speedskater avatar speedskater commented on June 11, 2024

@srph . Thanks for testing. Could you please provide a toy example or a PR with the sample, such that i can reproduce your error and provide a fix.

from babel-plugin-rewire.

srph avatar srph commented on June 11, 2024

Hmm, weird. I got the error around these lines.

exports['default'] = _defaultExport;
exports.__GetDependency__ = _GetDependency__; // this one
exports.__get__ = _GetDependency__;
exports.__Rewire__ = _Rewire__;
exports.__set__ = _Rewire__;
exports.__ResetDependency__ = _ResetDependency__;
exports.__RewireAPI__ = _RewireAPI__;

from babel-plugin-rewire.

dmwyatt avatar dmwyatt commented on June 11, 2024

I'm hitting the original issue in this thread. I can try out any beta versions, or if @speedskater can describe the source of the issue in more detail, I might take a shot at a PR to fix the problem...

from babel-plugin-rewire.

speedskater avatar speedskater commented on June 11, 2024

@dmwyatt did 0.1.23-beta-3 solve your issue?
@srph is this the generated or is this your code?

from babel-plugin-rewire.

srph avatar srph commented on June 11, 2024

@speedskater It is the generated code, and it seems to be from this plugin.

Honestly, I can see hints, but no concrete idea because I haven't seen the internals. I apologize if I can't be much of a help 😞

from babel-plugin-rewire.

speedskater avatar speedskater commented on June 11, 2024

@srph thanks for the feedback. I am more interested in the original not in the generated source code. So if you could create a simple toy example which results in the error it would be perfect. This would help me to reproduce the error.

from babel-plugin-rewire.

srph avatar srph commented on June 11, 2024

Noted 👌 . I'll work on it. I'll report anything I find.

from babel-plugin-rewire.

speedskater avatar speedskater commented on June 11, 2024

@srph Thanks 👍

from babel-plugin-rewire.

srph avatar srph commented on June 11, 2024

I found out something. It'll be a little bit long, so hang on. Like I said, AFAICR, I'm using Webpack and Karma. I forgot to mention that I'm also using Sinon and Chai. I am intensively using Sinon.

This was my webpack config for finding all test files:

// build/tests/webpack.files.js
/**
 * Setup context module
 * http://webpack.github.io/docs/context.html
 */
var ctx = require.context('../../common/', true, /\.spec\.js$/);
ctx.keys().forEach(ctx);

Instead of running all tests, I made a dummy suite:

// build/tests/dummy.spec.js
describe('test', () => {
  it('should not fail', () => {
    expect(1).to.equal(1);
  });
});

And change my webpack config (for resolving spec files):

// build/tests/webpack.files.js
var ctx = require.context('./', true, /\.spec\.js$/);
ctx.keys().forEach(ctx);

No error occured.

Like I said, I am intensively using Sinon. My first clue (although not concrete) is that this plugin is having issues with Sinon. But I have yet to prove this.

from babel-plugin-rewire.

srph avatar srph commented on June 11, 2024

I'm sending a demo in a few minutes. It seems that I was correct.

// x.js
var x = {
  yolo: () => {

  }
};
// dummy.spec.js
import x  from './x';

describe('x', () => {
  it('should be called', () => {
    let sandbox = sinon.sandbox.create();
    sandbox.stub(x, 'yolo'); // error occurs
    // x.yolo();
    // expect(x.yolo.called).to.be.true;
    // sandbox.restore();
  });
});

Edit: False positive.

from babel-plugin-rewire.

srph avatar srph commented on June 11, 2024

Aha, I think I found out. This makes the error:

export const 'hello' = 'world';
export default exports; // The error triggers whenever I uncomment this line

Edit: I don't think this is an issue of the library. Closing this one. Sorry about the commotion, @speedskater. Also, thanks 👌

from babel-plugin-rewire.

dmwyatt avatar dmwyatt commented on June 11, 2024

@speedskater Yes, 0.1.23-beta-3, does fix the issue for me.

from babel-plugin-rewire.

speedskater avatar speedskater commented on June 11, 2024

@srph thanks for testing. Could you provide the whole sample file which contains "export default exports;" I would like to analyze if this could be a an error in certain edge cases.

from babel-plugin-rewire.

srph avatar srph commented on June 11, 2024

You can just copy-paste it. My sample is as it is. It bugged with that exact sample :)

from babel-plugin-rewire.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.