Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 4 additions & 3 deletions src/schematics/deploy/actions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,9 @@ import * as winston from 'winston';
import { BuildTarget, CloudRunOptions, DeployBuilderSchema, FSHost, FirebaseTools } from '../interfaces';
import { DEFAULT_FUNCTION_NAME, defaultFunction, defaultPackage, dockerfile, functionGen2 } from './functions-templates.js';

// @ts-ignore
const __dirname = dirname(fileURLToPath(import.meta.url));
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
// @ts-ignore `import.meta` is rejected by the --module es2015 pass of `npm run build:jasmine`.
const moduleDirectory = typeof __dirname === 'string' ? __dirname : dirname(fileURLToPath(import.meta.url));

const { copySync, removeSync, readJsonSync } = fsExtra;

Expand Down Expand Up @@ -128,7 +129,7 @@ const findPackageVersion = (packageManager: string, name: string) => {
const getPackageJson = (context: BuilderContext, workspaceRoot: string, options: DeployBuilderOptions, main?: string) => {
const dependencies: Record<string, string> = {};
const devDependencies: Record<string, string> = {};
const { firebaseFunctionsDependencies } = readJsonSync(join(__dirname, '..', 'versions.json'));
const { firebaseFunctionsDependencies } = readJsonSync(join(moduleDirectory, '..', 'versions.json'));
if (options.ssr !== 'cloud-run') {
Object.keys(firebaseFunctionsDependencies).forEach(name => {
const { version, dev } = firebaseFunctionsDependencies[name];
Expand Down
29 changes: 29 additions & 0 deletions tools/build.ts
Original file line number Diff line number Diff line change
Expand Up @@ -357,6 +357,35 @@ async function compileSchematics() {
copy(src('schematics', 'setup', 'schema.json'), dest('schematics', 'setup', 'schema.json')),
]);
await replaceSchematicVersions();
await loadCompiledSchematics();
}

/**
* Loads every compiled schematic entry point, so a bundle that cannot even be required fails the
* build instead of shipping.
*/
async function loadCompiledSchematics() {
const entryPoints = [
join('update', 'index.js'),
join('deploy', 'actions.js'),
join('deploy', 'builder.js'),
join('add', 'index.js'),
join('setup', 'index.js'),
join('update', 'v7', 'index.js'),
join('update', 'v21', 'index.js'),
];
const failures: string[] = [];
for (const entryPoint of entryPoints) {
const path = dest('schematics', entryPoint);
try {
require(path);
} catch (error) {
failures.push(` ${entryPoint}: ${error}`);
}
}
if (failures.length) {
throw new Error(`Compiled schematics failed to load:\n${failures.join('\n')}`);
}
}

async function buildLibrary() {
Expand Down
Loading