Skip to content

Commit dafe740

Browse files
authored
Merge pull request #3573 from github/mbg/esbuild/no-package-json
Avoid bundling `package.json` in JavaScript files
2 parents 1dbebad + ea70366 commit dafe740

18 files changed

+71
-1354
lines changed

ava.config.mjs

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
export default {
2+
typescript: {
3+
rewritePaths: {
4+
"src/": "build/",
5+
},
6+
compile: false,
7+
},
8+
require: ["./ava.setup.mjs"],
9+
};

ava.setup.mjs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
import pkg from "./package.json" with { type: "json" };
2+
3+
globalThis.__CODEQL_ACTION_VERSION__ = pkg.version;

build.mjs

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@ import { fileURLToPath } from "node:url";
55
import * as esbuild from "esbuild";
66
import { globSync } from "glob";
77

8+
import pkg from "./package.json" with { type: "json" };
9+
810
const __filename = fileURLToPath(import.meta.url);
911
const __dirname = dirname(__filename);
1012

@@ -13,7 +15,7 @@ const OUT_DIR = join(__dirname, "lib");
1315

1416
/**
1517
* Clean the output directory before building.
16-
*
18+
*
1719
* @type {esbuild.Plugin}
1820
*/
1921
const cleanPlugin = {
@@ -27,7 +29,7 @@ const cleanPlugin = {
2729

2830
/**
2931
* Copy defaults.json to the output directory since other projects depend on it.
30-
*
32+
*
3133
* @type {esbuild.Plugin}
3234
*/
3335
const copyDefaultsPlugin = {
@@ -69,6 +71,9 @@ const context = await esbuild.context({
6971
platform: "node",
7072
plugins: [cleanPlugin, copyDefaultsPlugin, onEndPlugin],
7173
target: ["node20"],
74+
define: {
75+
__CODEQL_ACTION_VERSION__: JSON.stringify(pkg.version),
76+
},
7277
});
7378

7479
await context.rebuild();

eslint.config.mjs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,8 @@ export default [
1919
"src/testdata/**/*",
2020
"tests/**/*",
2121
"build.mjs",
22+
"ava.config.mjs",
23+
"ava.setup.mjs",
2224
"eslint.config.mjs",
2325
".github/**/*",
2426
"pr-checks/**/*",

lib/analyze-action-post.js

Lines changed: 5 additions & 113 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

lib/analyze-action.js

Lines changed: 3 additions & 111 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)