Due to the way conditions are checked top-to-bottom, the module definition has no chance to take precedence over import and require—which is typically the whole point of including module. Bundler implementations may chose to not respect definition order (so some bundlers may work despite the incorrect order of the module field), but it's not the way the conditions are supposed to be checked. By enforcing module to appear before import and/or require, this problem is circumvented and should work in all bundlers.
The fix for the above is to move the "module" definition up:
This provides a fix for common bugs like this:
Due to the way conditions are checked top-to-bottom, the
module
definition has no chance to take precedence overimport
andrequire
—which is typically the whole point of includingmodule
. Bundler implementations may chose to not respect definition order (so some bundlers may work despite the incorrect order of themodule
field), but it's not the way the conditions are supposed to be checked. By enforcingmodule
to appear beforeimport
and/orrequire
, this problem is circumvented and should work in all bundlers.The fix for the above is to move the
"module"
definition up:Based on this description of how conditions work.