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

feature: Add MikroORM CLI wrapper to bypass hardcoded module system #9426

Merged
merged 7 commits into from
Oct 3, 2024

Conversation

thetutlage
Copy link
Contributor

@thetutlage thetutlage commented Oct 2, 2024

FIXES: FRMW-2727

MikroORM (with version 5.9) has hardcoded the TypeScript module system to commonjs, which makes it incompatible with the module system we are using, ie Node16.

So, in order to continue using the Mikro ORM CLI within our modules, we will have to monkey-patch the block of code responsible for configuring ts-node. However, the monkey-patching must be done before their CLI gets booted.

As a result of this, we have to create a wrapper CLI on top of Mikro ORM CLI that performs the following steps.

  • Monkey-patch the relevant code
  • Register Mikro ORM CLI as the second step.

Due do this, we will have to use this new wrapper CLI within the modules, which is exposed as medusa-db. Maybe, medusa-db is not a great name, so please send your suggestions.

Copy link

changeset-bot bot commented Oct 2, 2024

⚠️ No Changeset found

Latest commit: c01fcfb

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

Copy link

vercel bot commented Oct 2, 2024

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
medusa-dashboard ✅ Ready (Inspect) Visit Preview 💬 Add feedback Oct 3, 2024 4:36am
6 Skipped Deployments
Name Status Preview Comments Updated (UTC)
api-reference ⬜️ Ignored (Inspect) Oct 3, 2024 4:36am
api-reference-v2 ⬜️ Ignored (Inspect) Visit Preview Oct 3, 2024 4:36am
docs-ui ⬜️ Ignored (Inspect) Visit Preview Oct 3, 2024 4:36am
docs-v2 ⬜️ Ignored (Inspect) Visit Preview Oct 3, 2024 4:36am
medusa-docs ⬜️ Ignored (Inspect) Visit Preview Oct 3, 2024 4:36am
resources-docs ⬜️ Ignored (Inspect) Visit Preview Oct 3, 2024 4:36am

@thetutlage thetutlage requested review from olivermrbl and removed request for fPolic October 2, 2024 09:24
packages/core/framework/src/mikro-orm-cli/bin.ts Outdated Show resolved Hide resolved
packages/modules/order/bin.js Outdated Show resolved Hide resolved
Copy link
Contributor

@olivermrbl olivermrbl left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

Copy link
Contributor

@riqwan riqwan left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just tested this, thanks man! 💪🏻

packages/modules/order/tsconfig.json Outdated Show resolved Hide resolved
@kodiakhq kodiakhq bot merged commit 2d1cf12 into develop Oct 3, 2024
23 checks passed
@kodiakhq kodiakhq bot deleted the refactor/mikro-orm-cli-wrapper branch October 3, 2024 04:51
panalgin pushed a commit to vennyx-org/medusa that referenced this pull request Oct 7, 2024
…edusajs#9426)

FIXES: FRMW-2727

MikroORM (with version 5.9) has [hardcoded the TypeScript module](https:/mikro-orm/mikro-orm/blob/5.x/packages/core/src/utils/ConfigurationLoader.ts#L138-L139) system to `commonjs`, which makes it incompatible with the module system we are using, ie `Node16`.

So, in order to continue using the Mikro ORM CLI within our modules, we will have to monkey-patch the block of code responsible for configuring `ts-node`. However, the monkey-patching must be done before their CLI gets booted.

As a result of this, we have to create a wrapper CLI on top of Mikro ORM CLI that performs the following steps.

- Monkey-patch the relevant code
- Register Mikro ORM CLI as the second step.

Due do this, we will have to use this new wrapper CLI within the modules, which is exposed as `medusa-db`. Maybe, `medusa-db` is not a great name, so please send your suggestions.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants