You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The current UMD wrapper checks that all of require, module, and exports have been defined in order to export knockout as a CommonJS module (relevant line).
This causes a problem with some module bundlers (such as webpack) because require may not be defined as a function if a module has no dependencies, as is the case with knockout. If require is not defined, knockout's UMD logic will fall through to the 'global' export method rather than CommonJS.
Since require is not actually used by knockout (again, no dependencies) it is unnecessary to check for its existence; module and exports should be sufficient to detect CommonJS.
The text was updated successfully, but these errors were encountered:
I am under the impression that we would be going for returnExportsGlobal style wrapper. Or are we aiming for (is there a reason to aim for) something more lodashy?
Incidentally, as @jgoz points out, it's okay to not check require; the jQuery library only checks module and exports.
I am under the impression that we would be going for returnExportsGlobal style wrapper. Or are we aiming for (is there a reason to aim for) something more lodashy?
I'm not familiar with all of knockout's supported execution environments, but I would think the 'simplified' returnExports would be a closer match to what you have now, while still resolving this issue.
The current UMD wrapper checks that all of
require
,module
, andexports
have been defined in order to export knockout as a CommonJS module (relevant line).This causes a problem with some module bundlers (such as webpack) because
require
may not be defined as a function if a module has no dependencies, as is the case with knockout. Ifrequire
is not defined, knockout's UMD logic will fall through to the 'global' export method rather than CommonJS.Since
require
is not actually used by knockout (again, no dependencies) it is unnecessary to check for its existence;module
andexports
should be sufficient to detect CommonJS.The text was updated successfully, but these errors were encountered: