Open micahblu opened 7 years ago
The issue is happening when referencing src/tml-angular, using dist/tml-angular I received an undefined module. I think I found the issue, the export code checks for module.exports === 'object' before the amd check and somehow is triggering first when being loaded by the browser? When I move the amd if statement above the exports check I get the proper object. Also I had to update facory to factory()
Hey, thanks for reaching out!
The version in /dist already contains tml-js-browser and tml-js.
AMD support was never quite finished, in the mean time, we recommend using the library with CommonJS with something like browserify/webpack if possible.
The dist version however should work standalone, you can try loading the dist version before require.js or whatever you use for AMD, so it falls through to the 3rd condition, which is defining a global tml
object, that will have an init()
method.
Hi thanks for the quick response!
I kind of found out the hard way that the AMD support was unfinished. After going back to using dist/tml-angular I was getting an anonymous define error, which I fixed only to get
tml-angular.js?bust=1484242288417:1998 Uncaught TypeError: Cannot read property 'config' of undefined at tml-angular.js?bust=1484242288417:1998
Which is due to var tml = require('tml-js-browser');
@line 1807 in dist returning an empty object. The good news is AMD supports window global modules. I guess the short term solution would be to get rid of the logic that exports the library as an AMD module and instead export as a window global until the AMD support is finished.
Can you describe your environment? What bundler or script loader are you using?
From your last message I didn't understand if you tried my suggestion of loading the dist version outside of the bundler.
We use r optimizer to bundle all the amd modules. The issue though is present in development environment before it is ever bundled. Essentially the dist version of tml-angular is using require() which to my understanding it should not, those deps should be present in the dist file already imported. I guess you could use require() in your dist but would need to define those modules so requirejs would know where to load them from.
tml-js-angular
requirestml-js-browser
which doesn't export properly and itself depends ontml-js
which has no apparent dist ready js file.