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

chore: replace version inject plugin with macro plugin #83

Merged
merged 2 commits into from
Dec 29, 2024

Conversation

twlite
Copy link
Collaborator

@twlite twlite commented Dec 25, 2024

This will allow us to add macros in this codebase. For now, it is only being used to export the version.

Assuming we have a code like this

function getCommandKitVersion(): string {
  'use macro';
  return require('../package.json').version;
}

/**
 * The current version of CommandKit.
 */
export const version = getCommandKitVersion();

It will compile down to export const version = 'x.x.x' (return value is inlined)

Previously we were doing something like

export const version: string = '[VI]{{inject}}[/VI]';

which is not dynamic and looks confusing. The new solution offers more dynamic and straightforward approach.

Copy link

netlify bot commented Dec 25, 2024

Deploy Preview for commandkit ready!

Name Link
🔨 Latest commit dc7beb9
🔍 Latest deploy log https://app.netlify.com/sites/commandkit/deploys/676ba9cc85bff50008437b99
😎 Deploy Preview https://deploy-preview-83--commandkit.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site configuration.

@twlite twlite merged commit ac358bc into main Dec 29, 2024
5 checks passed
@twlite twlite deleted the add-macro-plugin branch December 29, 2024 13:13
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.

1 participant