Open webcodepl opened 6 years ago
Which AMD module loader do you use? I am using the ember-cli/loader.js library. Maybe that's why there are errors?
I am using requirejs. Maybe that is a problem but It would be nice if it worked with requirejs too :)
Thanks.
@tomaszpupiec I am interested though in why that would not work with requirejs
since they should be compatible with each other.
@tomaszpupiec I am running in the same problem using a "real async" AMD loader like requirejs.
There is is a fork by @rtasarz with an "alternate syntax for require" 5ea10423cca4309f119a6854fe1811adfbf3297f that works for me. https://github.com/rtasarz/babel-plugin-dynamic-import-amd
@frederikbosch AMD defines async callback-style and synchron string-style of require. I have to use callback-style to load modules async in the browser.
I confirm, this fork works for me too. Thanks.
In my case plugin produces this code:
new Promise(resolve => resolve(require(['TestController']))).then(TestController => { let controller = new TestController(); })
Browser reports: "Unhandled promise rejection TypeError: TestController is not a constructor"
When i changed this code manualy to:
new Promise(resolve => require(['TestController'], (TestController) => resolve(TestController))).then(TestController => { let controller = new TestController(); })
Works ok.