feat: remove need for babel (except for mocha tests) #9337
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Description of what you did:
This updates the way we prescan the plugins so as to remove any need for CJS modules. We can thus remove one of the last remaining uses of babel. All that remains is the mocha tests. Porting these will be a huge pain:
function(this: Common.ISuite)
. it fails to recognize our override of mocha's Suite type. admittedly this is probably just bad code on our part. if we wanted to use ts-node, we'd have to update every single test file to ... somehow do this differently.mjs
(which is not possible in typescript Support.mjs
output microsoft/TypeScript#18442), or that the tests are in a"type": "module"
module (which would require substantial changes to our entire code base)so... we are left with babel for the tests at the moment; the first option is the most attractive in terms of expediency (at least.. this would only affect the test files), while the second is what is really needed to make Kui ESM-native.
In summary: with this change, the kui build no longer generates any CJS modules (unless you use
@kui-shell/test
, and then only when you run the tests), but does not yet mandate the use of ESM from clients (because it is not yet ESM-native).What is missing to be fully ESM? all imports need to specify the
.js
file, e.g. import('./foo/index.js'); we cannot use require.resolve; we'd have to find and fix any CJS-only npms (e.g. fs-extra pre v11)...BREAKING CHANGE: this is a substantial change, and may introduce issues with plugins. It is unlikely, by it seems prudent to mark this as a major change.
Required Items
fix:
|test:
|chore:
|doc:
, to indicate the nature of the fix (see Conventional Commits)Optional Items