Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: remove need for babel (except for mocha tests) #9337

Merged
merged 1 commit into from
Apr 11, 2023

Conversation

starpit
Copy link
Contributor

@starpit starpit commented Apr 10, 2023

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:

  1. ts-node/esm+ts-node/register fail because of our use of a 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
  2. mocha's native support for ESM assumes either that the generated ESM files are named .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)
  3. port to ... playwright? which would also get us off the spectron hack branch

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

  • Your PR consists of a single commit (i.e. squash your commits)
  • Your commit and PR title starts with one of fix: | test: | chore: | doc:, to indicate the nature of the fix (see Conventional Commits)

Optional Items

  • 💥 This PR involves a breaking change. If so, include "BREAKING CHANGE: ...why..." in the commit and PR message.

@k8s-ci-robot k8s-ci-robot added cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. size/XXL Denotes a PR that changes 1000+ lines, ignoring generated files. labels Apr 10, 2023
@k8s-ci-robot
Copy link

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: starpit

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@k8s-ci-robot k8s-ci-robot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Apr 10, 2023
@starpit starpit force-pushed the no-babel-20230410 branch 9 times, most recently from f3f2f99 to 1990fc2 Compare April 10, 2023 23:08
@starpit starpit changed the title feat: remove need for babel feat: remove need for babel (except for mocha tests) Apr 10, 2023
@starpit starpit force-pushed the no-babel-20230410 branch 7 times, most recently from b9ca385 to 162efc0 Compare April 11, 2023 16:41
This updates the way we prescan the plugins so as to remove any need for CJS modules. We can thus remove the last remaining use of babel.

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.
@starpit starpit merged commit e8627a2 into kubernetes-sigs:master Apr 11, 2023
@starpit starpit deleted the no-babel-20230410 branch April 11, 2023 17:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
approved Indicates a PR has been approved by an approver from all required OWNERS files. cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. size/XXL Denotes a PR that changes 1000+ lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants