AMD and CommonJS modules don't have the same API

AMD and CommonJS modules don't have the same API

jruppjrupp Posts: 1Questions: 1Answers: 0

From what I can tell, it looks like the AMD and CommonJS modules have a different API. The AMD module is the result of calling factory(...), while the CommonJS module is a function that when called, will return the result of factory(...).

This causes problems for a control library that uses datatables.net and is consumed by two different apps - one of which uses CommonJS-style loading and one that's using AMD-style.

Is this difference intentional? Is there a recommended way to deal with this?

Answers

  • allanallan Posts: 61,732Questions: 1Answers: 10,110 Site admin

    Yes it was intentional. I had assumed that AMD style will be primarily browser based while CommonJS might be server-side or headless (and thus you would want to pass in your own window object).

    Presumably you aren't using compiling the same code for both CommonJS and AMD? So you'd have the opportunity to use the different styles in the different code paths.

    Allan

This discussion has been closed.