Skip to content

Commit

Permalink
chore: replace version inject plugin with macro plugin
Browse files Browse the repository at this point in the history
  • Loading branch information
twlite committed Dec 25, 2024
1 parent a2cf4cc commit 157078e
Show file tree
Hide file tree
Showing 4 changed files with 194 additions and 143 deletions.
4 changes: 2 additions & 2 deletions packages/commandkit/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -53,10 +53,10 @@
"@types/node": "^22.10.2",
"@types/yargs": "^17.0.32",
"discord.js": "^14.16.3",
"esbuild-plugin-version-injector": "^1.2.1",
"tsconfig": "workspace:*",
"tsx": "^4.7.0",
"typescript": "^5.7.2",
"use-macro": "^1.0.1",
"vitest": "^1.2.1"
},
"peerDependencies": {
Expand All @@ -65,4 +65,4 @@
"engines": {
"node": ">=22"
}
}
}
9 changes: 6 additions & 3 deletions packages/commandkit/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,12 @@ export * from './components';
export * from './config';
export type * from './types';

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

/**
* The current version of CommandKit.
*/
// Note to developers: This needs to explicitly be `string` so it is not typed as a "const string" that gets injected by esbuild
// eslint-disable-next-line @typescript-eslint/no-inferrable-types
export const version: string = '[VI]{{inject}}[/VI]';
export const version = getCommandKitVersion();
4 changes: 2 additions & 2 deletions packages/commandkit/tsup.config.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { defineConfig } from 'tsup';
import { esbuildPluginVersionInjector } from 'esbuild-plugin-version-injector';
import { esbuildPluginUseMacro } from 'use-macro';

export default defineConfig({
format: ['cjs', 'esm'],
Expand All @@ -13,5 +13,5 @@ export default defineConfig({
shims: true,
skipNodeModulesBundle: true,
clean: true,
esbuildPlugins: [esbuildPluginVersionInjector()],
esbuildPlugins: [esbuildPluginUseMacro()],
});
Loading

0 comments on commit 157078e

Please sign in to comment.