mainfield is the standard target for
package.jsonfiles and is flagshipped by Node.
modulefield (formally the
jsnext:mainfield) is flagshipped by rollup.
importsyntax rather than the
requiresyntax). The benefit to bundlers is that the explicit and static exporting and importing within ES Modules allows bundlers to build smaller and faster bundles that have more used code and less unused code in them. The bundle can then be compiled down to the lowest possible common demonator of features that the web browsers of the consumers audience supports.
importsyntax for use in environments that only support ratified ES features, to which degree is unknown. Adding staging or alternative features (e.g. JSX) to this target increases complexity for the consumers of your package, as their environments, tooling or configurations may not support non-ratified features.
importsyntax and only uses ratified ES features. Compiler presets such as babel-preset-latest will do the job. We do not currently recommend publishing an edition for this field if your source code did not originally use the ES Module syntax.
browserfield is flagshipped by browserify.
module.exportssyntax) to combine all the files across different modules into a single bundle file, for use in the web browser.
modulefield has been introduced, as seen earlier.
requiresyntax. Compiling ES2015 and newer features down to ES5 is difficult as operational parity may not exist, causing such conversions to be error prone. Compiling other features or other languages may not have this issue. Consumer polyfills to emulate any missing ES2015 features are also an option. As such: