Skip to content

Commit 9af13e3

Browse files
committed
Use tsc output in build.mjs rather than compiling twice
1 parent 3db7caf commit 9af13e3

14 files changed

Lines changed: 53166 additions & 50834 deletions

‎build.mjs‎

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ const __filename = fileURLToPath(import.meta.url);
1111
const __dirname = dirname(__filename);
1212

1313
const SRC_DIR = join(__dirname, "src");
14+
const BUILD_DIR = join(__dirname, "build");
1415
const OUT_DIR = join(__dirname, "lib");
1516

1617
/**
@@ -69,7 +70,7 @@ const SHARED_ENTRYPOINT = "entry-points";
6970
const UPLOAD_LIB_EXPORT = "uploadLib";
7071

7172
/** The relative source path of the `upload-lib` module that we re-export from `entry-points`. */
72-
const UPLOAD_LIB_SRC = "./src/upload-lib";
73+
const UPLOAD_LIB_SRC = "./build/upload-lib.js";
7374

7475
/**
7576
* This plugin finds all source files that contain Action entry points. It then generates the
@@ -95,7 +96,7 @@ const entryPointsPlugin = {
9596

9697
// Find the source files containing Action entry points.
9798
build.onStart(() => {
98-
const actionFiles = globSync("src/*-action{,-post}.ts");
99+
const actionFiles = globSync(join(BUILD_DIR, "*-action{,-post}.js"));
99100
for (const actionFile of actionFiles) {
100101
const match = basename(actionFile).match(/(.*)-action(-post)?/);
101102

@@ -137,7 +138,7 @@ const entryPointsPlugin = {
137138
const imports = actionsSorted
138139
.map(
139140
(action) =>
140-
`import * as ${action.pascalCaseName} from "./src/${basename(action.path)}";`,
141+
`import * as ${action.pascalCaseName} from "./build/${basename(action.path)}";`,
141142
)
142143
.join("\n");
143144
const wrappers = actionsSorted
@@ -153,14 +154,14 @@ const entryPointsPlugin = {
153154
return {
154155
contents: `"use strict";\n${imports}\n\n${uploadLibReExport}\n\n${wrappers}\n`,
155156
resolveDir: ".",
156-
loader: "ts",
157+
loader: "js",
157158
};
158159
});
159160

160161
// Emit entry point stubs for each Action using the entry template.
161162
build.onEnd(async () => {
162163
const makeHeader = (templatePath, sourceFile) =>
163-
`// Automatically generated from '${templatePath}' for 'src/${basename(sourceFile)}'.\n\n`;
164+
`// Automatically generated from '${templatePath}' for 'build/${basename(sourceFile)}'.\n\n`;
164165

165166
// Read the entry point template.
166167
const actionTemplatePath = "action-entry.js.tpl";
@@ -191,7 +192,7 @@ const entryPointsPlugin = {
191192
);
192193
await writeFile(
193194
join(OUT_DIR, "upload-lib.js"),
194-
makeHeader(uploadLibStubTemplatePath, `${UPLOAD_LIB_SRC}.ts`) +
195+
makeHeader(uploadLibStubTemplatePath, `${UPLOAD_LIB_SRC}`) +
195196
uploadLibStubTemplate.replaceAll(
196197
"__UPLOAD_LIB_EXPORT__",
197198
UPLOAD_LIB_EXPORT,

‎lib/analyze-entry.js‎

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎lib/analyze-post-entry.js‎

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎lib/autobuild-entry.js‎

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)