Skip to content

Commit fbc1429

Browse files
build: derive schematic entry points from a single list
compileSchematics and loadCompiledSchematics each carried their own hardcoded copy of the seven entry points. An entry point added to the esbuild list alone would compile but never be load-checked, which is the exact failure the load check exists to catch. Both now map one schematicEntryPoints array, to .ts for esbuild and to .js for the require check. Emitted paths and failure strings are unchanged: a build with a deliberate top-level throw added to deploy/actions.ts still fails, and still names deploy/actions.js and deploy/builder.js in the same format.
1 parent 5c7aba4 commit fbc1429

1 file changed

Lines changed: 16 additions & 22 deletions

File tree

tools/build.ts

Lines changed: 16 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -313,17 +313,21 @@ function spawnPromise(command: string, args: string[]) {
313313
.on('error', reject));
314314
}
315315

316+
// Path segments of each schematic entry point, relative to `schematics/` and without the file
317+
// extension: esbuild compiles the `.ts` and loadCompiledSchematics requires the emitted `.js`.
318+
const schematicEntryPoints = [
319+
['update', 'index'],
320+
['deploy', 'actions'],
321+
['deploy', 'builder'],
322+
['add', 'index'],
323+
['setup', 'index'],
324+
['update', 'v7', 'index'],
325+
['update', 'v21', 'index'],
326+
];
327+
316328
async function compileSchematics() {
317329
await esbuild.build({
318-
entryPoints: [
319-
src('schematics', "update", "index.ts"),
320-
src('schematics', "deploy", "actions.ts"),
321-
src('schematics', "deploy", "builder.ts"),
322-
src('schematics', "add", "index.ts"),
323-
src('schematics', "setup", "index.ts"),
324-
src('schematics', "update", "v7", "index.ts"),
325-
src('schematics', "update", "v21", "index.ts"),
326-
],
330+
entryPoints: schematicEntryPoints.map(segments => `${src('schematics', ...segments)}.ts`),
327331
format: "cjs",
328332
// turns out schematics don't support ESM, need to use webpack or shim these
329333
// format: "esm",
@@ -365,22 +369,12 @@ async function compileSchematics() {
365369
* build instead of shipping.
366370
*/
367371
async function loadCompiledSchematics() {
368-
const entryPoints = [
369-
join('update', 'index.js'),
370-
join('deploy', 'actions.js'),
371-
join('deploy', 'builder.js'),
372-
join('add', 'index.js'),
373-
join('setup', 'index.js'),
374-
join('update', 'v7', 'index.js'),
375-
join('update', 'v21', 'index.js'),
376-
];
377372
const failures: string[] = [];
378-
for (const entryPoint of entryPoints) {
379-
const path = dest('schematics', entryPoint);
373+
for (const segments of schematicEntryPoints) {
380374
try {
381-
require(path);
375+
require(`${dest('schematics', ...segments)}.js`);
382376
} catch (error) {
383-
failures.push(` ${entryPoint}: ${error}`);
377+
failures.push(` ${join(...segments)}.js: ${error}`);
384378
}
385379
}
386380
if (failures.length) {

0 commit comments

Comments
 (0)