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

Could not resolve "croner" - Error while bundling for production #163

Open
rdzidziguri opened this issue Jan 16, 2023 · 10 comments
Open

Could not resolve "croner" - Error while bundling for production #163

rdzidziguri opened this issue Jan 16, 2023 · 10 comments

Comments

@rdzidziguri
Copy link

rdzidziguri commented Jan 16, 2023

While trying to build production, the following error is being thrown that prevents from building the application. This has never been an issue and has always worked with the 2.0.0 version. Worth to mention that I am not using any Cron expression-based jobs, so this thing is a regression, most probably because the file where the error is being thrown is added 2 weeks ago only.

tsc --noEmit && node ./build/esbuild.js --metafile=meta.json
X [ERROR] Could not resolve "croner"
    ../../node_modules/toad-scheduler/dist/lib/engines/cron/CronJob.js:24:31:
      24 │         const croner = require('croner');
@kibertoad
Copy link
Owner

Thank you for reporting this. Need to think how to approach this, I was hoping that lazy-loading it would help keep the dependency optional, but looks like bundlers are resolving it eagerly anyway.

@rdzidziguri
Copy link
Author

Meanwhile, are you rolling out another version that reverts this, or do you recommend we downgrade to 2.0.0?

@kibertoad
Copy link
Owner

downgrading to 2.1.1 should suffice, but I'll work on this tomorrow

@Hexagon
Copy link

Hexagon commented Jan 19, 2023

@kibertoad Just depend it 😄

I won't add any third party dependencies - ever. It's small. And bundlers will tree-shake if needed 👍

@rdzidziguri
Copy link
Author

@kibertoad, Any update regarding this one? Actually @Hexagon had a really good point ;)

@kibertoad
Copy link
Owner

yeah, had few ideas, will try them out soon, but worst case scenario just make croner a direct dependency

@kibertoad
Copy link
Owner

@rdzidziguri you can already include croner in your package.json and make error go away

@rdzidziguri
Copy link
Author

Sure, that is the way, but we have strict rules regarding dependencies, mainly not including this way bundlers will. The good thing is that Croner has zero dependencies and is very tiny, so we are evaluating its effect on projects, especially in bundle sizing.

@kibertoad
Copy link
Owner

my concern exactly. will try finding the way to avoid including it

@kibertoad
Copy link
Owner

@rdzidziguri Sorry it took so long, but - going forward solution will be extracting cron-related logic into a separate optional package, as I don't think there is a nicer solution available.

How bad was the impact on the bundle size after including Croner? would you recommend just making it a runtime dependency?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants