Skip to content

Conversation

@MatiasArriola
Copy link
Contributor

@MatiasArriola MatiasArriola commented Oct 21, 2025

📌 References

📝 Implementation

start-scheduler and build-scheduler stopped working as part of the changes in #1014

Problem: the project started using ES modules features like import.meta.env, while the scheduler script was using CJS.

  • For start-scheduler: replaced ts-node with tsx. With this change we can run the scheduler without no further changes, its faster and preferred in latest skeleton versions.
  • For build-scheduler:
    • I tried to move to a vite build with ES modules instead of ncc CJS, or adding "type": "module" to package.json to have ncc generate a ES modules build, but couldn't get it working in a reasonable time.
    • Instead, made Config use process.env instead of import.meta.env. Changed vite.config.js to map the process.env values for the web build as well. This allows to use the same Config class for both vite web builds and ncc builds.
  • Extra: fixed a type export missing in d2-api

📹 Screenshots/Screen capture

🔥 Is there anything the reviewer should know to test it?

It was failing because of the usage of import.meta
Replace ts-node with tsx and keep using ES modules
Still need to fix ncc build
ncc builds CJS format, and won't work with the Config class wich uses import.meta.env, a feature from ES modules
@bundlemon
Copy link

bundlemon bot commented Oct 21, 2025

BundleMon

No change in files bundle size

Groups updated (1)
Status Path Size Limits
Build Folder
./**/*
2.78MB (-22B 0%) +20%

Final result: ✅

View report in BundleMon website ➡️


Current branch size history | Target branch size history

This allows to use the same approach everywhere despite web / node script
@MiquelAdell MiquelAdell requested a review from tokland October 22, 2025 11:17
"process.env.VITE_PRESENTATION_VARIANT": JSON.stringify(env.VITE_PRESENTATION_VARIANT),
"process.env.VITE_PRESENTATION_TITLE": JSON.stringify(env.VITE_PRESENTATION_TITLE),
"process.env.VITE_PRESENTATION_TYPE": JSON.stringify(env.VITE_PRESENTATION_TYPE),
"process.env.VITE_CYPRESS": JSON.stringify(env.VITE_CYPRESS),
Copy link
Contributor

Choose a reason for hiding this comment

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

This also caused issues for us in CPR. Just as a note, what we did there was use vite-node to run the scripts so that the import.meta references keep working.

That’s not to say this approach is wrong, moving everything to environment variables is reasonable.

@MiquelAdell MiquelAdell merged commit a02ce1e into development Oct 22, 2025
3 checks passed
@MiquelAdell MiquelAdell deleted the fix/scheduler-vite-imports branch October 22, 2025 11:58
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

Successfully merging this pull request may close these issues.

3 participants