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

template-tag-codemod: only reuse ember prebuild if you explicitly pass the option to do so #2319

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

mansona
Copy link
Member

@mansona mansona commented Feb 27, 2025

This was discussed during the office hours and weekly meeting

essentially while developing the template-tag-codemod it was inconvenient to have to wait for the Ember prebuild every time the script was run. But when people are using this in real apps it is usually better that they don't re-use the prebuild, especially if they are likely to be making changes that would change the contents of the prebuild

This PR removes the reuse of the prebuild entirely 👍

@mansona mansona requested a review from ef4 February 27, 2025 14:05
@mansona mansona added the enhancement New feature or request label Feb 27, 2025
@ef4
Copy link
Contributor

ef4 commented Feb 27, 2025

This is part of what we discussed but it's missing a key step: we need to never use the same working dir as the regular embroider build. Otherwise people will get trolled if they have a build running in some other shell, and it starts messing with the working dir again.

I think it's sufficient to set process.env.EMBROIDER_WORKING_DIRECTORY to something like node_modules/.template-tag-codemod.

Also, please leave some way to explicitly ask to skip the prebuild, for when we're working on the codemod itself. A flag or env var.

@mansona mansona changed the title template-tag-codemod: always do the ember prebuild template-tag-codemod: only reuse ember prebuild if you explicitly pass the option to do so Feb 27, 2025
@mansona
Copy link
Member Author

mansona commented Feb 27, 2025

@ef4 done 👍

@@ -682,9 +693,11 @@ function applyEdits(source: string, edits: { start: number; end: number; replace
}

export async function run(partialOpts: Options) {
// this makes sure that we don't fight with other versions of embroider currently running on the system
process.env.EMBROIDER_WORKING_DIRECTORY = 'node_modules/.template-tag-codemod';
Copy link
Contributor

Choose a reason for hiding this comment

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

This is too late. Run the code and you'll see that it's not taking effect.

Copy link
Member Author

Choose a reason for hiding this comment

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

yikes you're right, I was driving myself mad trying to figure out why it wasn't working and then I realised it's being ready in module scope so there is no way to get it to the "start of execution" 🙈

I've updated it now and set it just before it is read and confirmed locally that it's working 👍

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

Successfully merging this pull request may close these issues.

2 participants