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
After trying to implement #7329, Jest's ESM requires that every module file be moved to .mjs or switch the package to a module. So, moving to Vite/Jest may be split into three different PRs, with the first one switching this repo to a module (which should help with bundle sizes). Using Karma + ESM relies on a (small CJS workaround). This should also unblock #6591 and #6592
The text was updated successfully, but these errors were encountered:
@LeoDog896 Would you be capable of providing a quick guide for folks on how you went through this process? We'd like to ensure that the consumers of Open MCT as a dependency (we know of at least 20) follow your established practices of migrating to ESM
@LeoDog896 Would you be capable of providing a quick guide for folks on how you went through this process? We'd like to ensure that the consumers of Open MCT as a dependency (we know of at least 20) follow your established practices of migrating to ESM
Sure! Generally, the steps I followed went like this:
Break everything first by establishing "type": "module" in package.json
Add .js to all js/ts imports (you can use codemods for this; I used a regex that matched some form of from './*'
Begin moving all files to not use require (vscode has code mods for this); to track them down, find all mentions of require( in your IDE
Do the same with all module. calls
Note: Dynamic imports are quite finicky, since ESM requires the use of await import instead of require; Optimally, dynamic imports should be avoided and moved to the top level.
@LeoDog896 this is great! We'll add it to our Github Discussions so that the consumers of Open MCT can make changes.
I'm wondering what your thoughts are on the errors we were seeing on akhenry/openmct-yamcs#411 when we tried to do import installYamcsPlugin from 'openmct-yamcs'; Did we miss a step by not defining a default export for ESM and CJS users of Open MCT?
Summary
After trying to implement #7329, Jest's ESM requires that every module file be moved to
.mjs
or switch the package to a module. So, moving to Vite/Jest may be split into three different PRs, with the first one switching this repo to a module (which should help with bundle sizes). Using Karma + ESM relies on a (small CJS workaround). This should also unblock #6591 and #6592The text was updated successfully, but these errors were encountered: