stealjs / steal-tools

Build easy. Load fast.

Home Page:https://stealjs.com/docs/steal-tools.html

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Circular deps does not resolve a module in built version

ilyavf opened this issue · comments

The case is reproduced here: https://github.com/ilyavf/bug-circular-dep-built-issue (a newly created donejs app using donejs v1.1.0).

I have 3 modules:
A -> B -> C

Dependencies:

  • A depends on B
  • B depends on C
  • C depends on A

Module A has a function that requires module C. But when its called module C is just a plain object.

In development mode everything works well:

Module Portfolio resolved
Module Session resolved
Module Utils resolved

But in production mode after a regular build it throws an error:

TypeError: n.default.inCurrency is not a function

image

The issue stems from the fact that the babel transpiled code checks for the __esModule flag at module-execution time. Since steal detects the circular dependency it provides an empty object at execution time. What should happen is the empty object should have a __esModule property flagged. I think we can detect the __esModule stuff as part of module detection.