mirror of
https://github.com/github/codeql-action
synced 2026-05-25 15:00:36 +03:00
Bundle Actions using esbuild
This commit is contained in:
@@ -0,0 +1,38 @@
|
||||
import { rm } from "node:fs/promises";
|
||||
import { dirname, join } from "node:path";
|
||||
import { fileURLToPath } from "node:url";
|
||||
|
||||
import * as esbuild from "esbuild";
|
||||
import { globSync } from "glob";
|
||||
import { typecheckPlugin } from "@jgoz/esbuild-plugin-typecheck";
|
||||
|
||||
const __filename = fileURLToPath(import.meta.url);
|
||||
const __dirname = dirname(__filename);
|
||||
|
||||
const OUT_DIR = "lib";
|
||||
|
||||
await rm(join(__dirname, OUT_DIR), { recursive: true, force: true });
|
||||
|
||||
// This will just log when a build ends
|
||||
/** @type {esbuild.Plugin} */
|
||||
const onEndPlugin = {
|
||||
name: "on-end",
|
||||
setup(build) {
|
||||
build.onEnd((result) => {
|
||||
// eslint-disable-next-line no-console
|
||||
console.log(`Build ended with ${result.errors.length} errors`);
|
||||
});
|
||||
},
|
||||
};
|
||||
|
||||
const context = await esbuild.context({
|
||||
entryPoints: globSync(["src/*-action.ts", "src/*-action-post.ts"]),
|
||||
bundle: true,
|
||||
format: "cjs",
|
||||
outdir: OUT_DIR,
|
||||
platform: "node",
|
||||
plugins: [typecheckPlugin(), onEndPlugin],
|
||||
});
|
||||
|
||||
await context.rebuild();
|
||||
await context.dispose();
|
||||
@@ -29,6 +29,7 @@ export default [
|
||||
"lib/**/*",
|
||||
"src/testdata/**/*",
|
||||
"tests/**/*",
|
||||
"build.mjs",
|
||||
"eslint.config.mjs",
|
||||
".github/**/*",
|
||||
],
|
||||
|
||||
+4
-1
@@ -4,7 +4,7 @@
|
||||
"private": true,
|
||||
"description": "CodeQL action",
|
||||
"scripts": {
|
||||
"build": "tsc --build",
|
||||
"build": "node build.mjs",
|
||||
"test": "ava src/**.test.ts --serial --verbose",
|
||||
"test-debug": "ava src/**.test.ts --serial --verbose --timeout=20m",
|
||||
"lint": "eslint --report-unused-disable-directives --max-warnings=0 .",
|
||||
@@ -61,6 +61,7 @@
|
||||
"@eslint/compat": "^1.3.2",
|
||||
"@eslint/eslintrc": "^3.3.1",
|
||||
"@eslint/js": "^9.33.0",
|
||||
"@jgoz/esbuild-plugin-typecheck": "^4.0.3",
|
||||
"@microsoft/eslint-formatter-sarif": "^3.1.0",
|
||||
"@types/archiver": "^6.0.3",
|
||||
"@types/console-log-level": "^1.4.5",
|
||||
@@ -73,12 +74,14 @@
|
||||
"@typescript-eslint/eslint-plugin": "^8.40.0",
|
||||
"@typescript-eslint/parser": "^8.40.0",
|
||||
"ava": "^6.4.1",
|
||||
"esbuild": "^0.25.9",
|
||||
"eslint": "^8.57.1",
|
||||
"eslint-import-resolver-typescript": "^3.8.7",
|
||||
"eslint-plugin-filenames": "^1.3.2",
|
||||
"eslint-plugin-github": "^5.1.8",
|
||||
"eslint-plugin-import": "2.29.1",
|
||||
"eslint-plugin-no-async-foreach": "^0.1.1",
|
||||
"glob": "^11.0.3",
|
||||
"nock": "^14.0.10",
|
||||
"removeNPMAbsolutePaths": "3.0.1",
|
||||
"sinon": "^21.0.0",
|
||||
|
||||
Reference in New Issue
Block a user