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
We have been using ES Module syntax (#47), but we currently use this in .js files. While the docusaurus build works due to it using babel+webpack, this is not compatible with Jest, which requires us to use either .mjs or add "type": "module" to package.json.
Using "type": "module" makes the build fail, as docusaurus emits CJS under .js and ESM under .mjs.
Context
The easiest solution is to ensure that all JS files using CommonJS syntax have the .js file extension, and those using ES Module syntax have the .mjs extension.
Alternatively, if it is trivial to change docusaurus' emit preference we could use .js for ESM and .cjs for CJS, allowing us to use type: module. Everything below still applies.
We should not mix CJS and ESM in a single file.
Test files should use the same extension and module syntax as the file(s) being imported.
To resolve this issue, we need to document our policy/standard for using CommonJS and ES Module files:
Another solution may be possible with additional configuration of babel or webpack, but after testing a couple options I am not confident this is easy or sound to do.
The text was updated successfully, but these errors were encountered:
Problem
We have been using ES Module syntax (#47), but we currently use this in
.js
files. While the docusaurus build works due to it using babel+webpack, this is not compatible with Jest, which requires us to use either.mjs
or add"type": "module"
topackage.json
.Using
"type": "module"
makes the build fail, as docusaurus emits CJS under.js
and ESM under.mjs
.Context
The easiest solution is to ensure that all JS files using CommonJS syntax have the
.js
file extension, and those using ES Module syntax have the.mjs
extension..js
for ESM and.cjs
for CJS, allowing us to use type: module. Everything below still applies.We should not mix CJS and ESM in a single file.
Test files should use the same extension and module syntax as the file(s) being imported.
To resolve this issue, we need to document our policy/standard for using CommonJS and ES Module files:
Another solution may be possible with additional configuration of babel or webpack, but after testing a couple options I am not confident this is easy or sound to do.
The text was updated successfully, but these errors were encountered: