-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
create and use esbuild-plugin-metadata-injector
- Loading branch information
Showing
10 changed files
with
89 additions
and
35 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
export const PACKAGE_VERSION: string; | ||
export const GIT_DESCRIBE: string; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
// @ts-check | ||
|
||
import gitDescribe from "git-describe"; | ||
import packageJSON from "../package.json" with { type: "json" }; | ||
|
||
export const PACKAGE_VERSION = packageJSON.version; | ||
export const GIT_DESCRIBE = gitDescribe.gitDescribeSync().raw; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
// @ts-check | ||
|
||
import { fileURLToPath } from "node:url"; | ||
import * as placeholder from "./placeholder.js"; | ||
|
||
/** | ||
* @param {string} path | ||
* @returns {RegExp} | ||
*/ | ||
function exact(path) { | ||
return new RegExp(`^${path.replace(/[/.]/g, "\\$&")}$`); | ||
} | ||
|
||
const target = fileURLToPath(import.meta.resolve("./placeholder.js")); | ||
|
||
/** | ||
* @returns {import("esbuild").Plugin} | ||
*/ | ||
export default function esbuildPluginMetadataInjector() { | ||
return { | ||
name: "esbuild-plugin-metadata-injector", | ||
setup(build) { | ||
build.onLoad({ filter: exact(target) }, () => ({ | ||
loader: "json", | ||
contents: JSON.stringify(placeholder), | ||
})); | ||
}, | ||
}; | ||
} |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters