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
Allow to pass .ts
files as config with Bun when ts-node
is disabled
#4701
Comments
Makes sense, PR welcome. Maybe the name should be a bit better, as its not really about bypassing the TS files? Ideally we should have a guide about bun in the docs. |
Yes, this flag should enable ts files without ts-node, so maybe something like Actually, I have another thought: Maybe allow ts files by default, but then if we fail to import config with Something like (just a pseudo code)
Something like this.
I think we need to have mikro-orm tests to pass with bun first. I haven't tested this yet. |
This also should work with entities, subscribers, migrations and other stuff that might be loaded by MikroORM itself. |
I would love to get rid of the |
…e` (#4702) ### Details This PR introduces two new options to allow `.ts` files as configs when `ts-node` is not enabled: - `alwaysAllowTs` flag in `mikro-orm` section of `package.json` - `MIKRO_ORM_CLI_ALWAYS_ALLOW_TS` environment variable ### Changes - [x] Add optional `alwaysAllowTs` field on `Settings` interface in `ConfigurationLoader`; - [x] Return `.ts` configs files from `ConfigurationLoader.getConfigPaths()` when `alwaysAllowTs` option is enabled; - [x] Add tests; - [x] Add documentation for these new options Fixes #4701
It's ok, but I would rather report errors to tell a user they're doing something wrong than silently ignoring |
Well, but it's completely fine to not use TS in your project, and that needs to be the baseline, TS should be opt in, not opt out. |
Makes sense, then I think default |
So, the algorithm would be: custom paths -> default |
That would be heavily breaking, as it would mean a compiled js file has precedence over the ts source file. We would need to have a way for users to say the project is TS, I really think the defaults need to stay working as they do now. |
Sorry, is this really already fixed? I tried to run the CLI on my Bun MikroORM API, had setup the config |
Could you provide minimal reproduction repo, please? |
I hope this has enough: |
You need to run command with See documentation: https://bun.sh/docs/cli/bunx#shebangs |
Thanks it worked! I think it would be interesting to have this usage example available on |
Is your feature request related to a problem? Please describe.
Hi, I'm experimenting with MikroORM and Bun, and I find out that MikroORM's configuration loader ignores
.ts
files whents-node
is not enabled. And while this constraint is suitable for node, it is not necessary for Bun since it support TS files out of the box.Describe the solution you'd like
I think it would be nice to add at least an option for configurator loader to pass
.ts
files when this option enabled. Something likebypassTsFiles
flag inmikro-orm
section ofpackage.json
. When enabled, this filter will be ignored same was as ifts-node
was enabled.Describe alternatives you've considered
Enabling
ts-node
works with Bun 1.0.1, but this running code fromts-node
with Bun is not necessary.Additional context
No additional context. But I think I can send a PR upon agreement on implementation details.
The text was updated successfully, but these errors were encountered: