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

circular dependencies not resolving correctly in production build #382

Closed
dbleier opened this issue Feb 17, 2016 · 4 comments
Closed

circular dependencies not resolving correctly in production build #382

dbleier opened this issue Feb 17, 2016 · 4 comments
Assignees
Labels
Milestone

Comments

@dbleier
Copy link

dbleier commented Feb 17, 2016

foo.js

import Map from 'can/map/';
import 'can/map/define/'; 
import bar from 'myproject/src/bar/';

export const foo = Map.extend({
  define: {
    propA: {
      get() { return bar.attr('propA'); }
    },
    propB: {
     get() { return 'Hello World!'; }
  }
});

bar.js

import Map from 'can/map/';
import 'can/map/define/'; 
import foo from 'myproject/src/foo/';

export const bar = Map.extend({
  define: {
    propA: {
      get() { return 'Hello World!';  }
    },
    propB: {
     get() { return foo.attr('propB'); }
  }
});

this works in development. However in production,
the define for foo calls

var _bar = _interopRequireDefault(_myprojectBar);

If the define for foo is called before the define for bar, then _bar === { 'default': {} }

After bar is define, it seems that _bar in the foo define is not updated so that when foo.attr('propA') is called, it returns an undefined TypeError

@matthewp
Copy link
Member

Thanks! This is an excellent test case.

@matthewp matthewp added the bug label Feb 17, 2016
@dylanrtt
Copy link

main.js

import foo from './foo';

// true in dev, false in production
console.log(foo.getBar().getFoo() === foo);

foo.js

import bar from './bar';

export default {
    name: 'foo',
    getBar() { return bar; }
}

bar.js

import foo from './foo';

export default {
    name: 'bar',
    getFoo() { return foo; }
}

@matthewp
Copy link
Member

Thanks for the simplified test case. Think we probably need stealjs/transpile#11 for this is my guess.

@matthewp
Copy link
Member

Fixed by #535

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

No branches or pull requests

3 participants