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
I notice that react-babylonjs export as ES Module now, but it only defines a “module” field in package.json, that’s nonstandard, in Node.js ES Module Documents, should define a exports field and shipping .mjs files or set type field to module in package.json.
Node.js will treat the following as ES modules when passed to node as the initial input, or when referenced by import statements within ES module code:
Files ending in .mjs.
Files ending in .js when the nearest parent package.json file contains a top-level field "type" with a value of "module".
Strings passed in as an argument to --eval, or piped to node via STDIN, with the flag --input-type=module.
Package Entry Points
In a package’s package.json file, two fields can define entry points for a package: "main" and "exports". The "main" field is supported in all versions of Node.js, but its capabilities are limited: it only defines the main entry point of the package.
The "exports" field provides an alternative to "main" where the package main entry point can be defined while also encapsulating the package, preventing any other entry points besides those defined in "exports". This encapsulation allows module authors to define a public interface for their package.
If both "exports" and "main" are defined, the "exports" field takes precedence over "main". "exports" are not specific to ES modules or CommonJS; "main" will be overridden by "exports" if it exists. As such "main" cannot be used as a fallback for CommonJS but it can be used as a fallback for legacy versions of Node.js that do not support the "exports" field.
The text was updated successfully, but these errors were encountered:
Thanks for this info - I will set type to module. I removed the UMD export when I redid packaging and fixed dependencies from 2.0.6 to 2.1.0 (the package went from 22.8MB to 1.8MB - and a lot of the 1.8 is typings).
Thanks also for the reference documentation. I will be doing a release on Saturday that is a big cleanup and will make sure this is addressed.
I notice that react-babylonjs export as ES Module now, but it only defines a “module” field in package.json, that’s nonstandard, in Node.js ES Module Documents, should define a
exports
field and shipping.mjs
files or settype
field tomodule
inpackage.json
.Partial content of Node.js ES Module Documents:
Node.js will treat the following as ES modules when passed to
node
as the initial input, or when referenced byimport
statements within ES module code:.mjs
..js
when the nearest parentpackage.json
file contains a top-level field"type"
with a value of"module"
.--eval
, or piped tonode
viaSTDIN
, with the flag--input-type=module
.Package Entry Points
In a package’s
package.json
file, two fields can define entry points for a package:"main"
and"exports"
. The"main"
field is supported in all versions of Node.js, but its capabilities are limited: it only defines the main entry point of the package.The
"exports"
field provides an alternative to"main"
where the package main entry point can be defined while also encapsulating the package, preventing any other entry points besides those defined in"exports"
. This encapsulation allows module authors to define a public interface for their package.If both
"exports"
and"main"
are defined, the"exports"
field takes precedence over"main"
."exports"
are not specific to ES modules or CommonJS;"main"
will be overridden by"exports"
if it exists. As such"main"
cannot be used as a fallback for CommonJS but it can be used as a fallback for legacy versions of Node.js that do not support the"exports"
field.The text was updated successfully, but these errors were encountered: