mirror of
https://github.com/hanzoai/firebase-js-sdk.git
synced 2026-09-24 16:59:10 +00:00
* Add node engines fields specifying a minimum of 18 (#8457) * Make memory lru gc the default (#8110) * Make memory lru gc the default * undo yarn.lock * Make memory lru gc the default * Fix tests * V11 release removal of node-fetch and undici dependencies (#8492) Our v11 release will require node 18+. Since fetch has been introduced in these node versions, we can remove our dependency on third party fetch implementations. This change removes our usage of fetch variants undici and node-fetch for our node target builds and our CI tools. * V11 - Remove functions node bundle (#8507) With the removal of fetch we no long need to create a node bundle for functions. Instead the sourcebase may become isomorphic, so long as we remove the older node sources. And that's what the PR does! * Initial changes for Vertex GA packaging (#8498) * [Vertex GA] Rewrite Schema (#8479) * [Vertex GA] Add new endpoint and error message. (#8497) * [Vertex GA] Miscellaneous breaking changes for Vertex GA (#8514) * Remove ES5 Support (#8509) * Emit a module package file for functions ESM builds (#8517) * Update API_NOT_ENABLED error for Vertex (#8549) * Upgrade cjs bundles for storage and performance (#8557) These should have been part of the bigger PR, but I missed these. * Rollup JS files with rollup-typescript-plugin (#8503) The rollup-typescript-plugin does not transpile JS files using the TS compiler by default. This means that external dependencies that provide JS bundles will not be transpiled to the target ES version specified in the TypeScript config used by the plugin. This resulted in one of our dependencies (https://github.com/jakearchibald/idb) being included in the CDN bundles without being transpiled to ES5 (the target ES version). Since this dependencies bundle uses ES2018 syntax (object spread operator `{ ...x }`), this upgraded our CDN bundles' minimum ES version requirement to ES2018 which isn't compatible with older browser versions. To see the ES2018 syntax in one of the CDN bundles, see https://www.gstatic.com/firebasejs/10.13.1/firebase-app.js and search for `...oldTraps`. * Fix tsc errors in vertex tests (#8562) * Make SafetySettings.method optional (#8567) * Make SafetySettings.method optional * Update API reports --------- Co-authored-by: hsubox76 <[email protected]> * [Vertex GA] Regenerate docs after Vertex GA changes (#8505) * Close emulator file after download is complete (#8572) * close file * Add test:ci to end of test command in CI * revert workflow file changes * format * rename vertexai package reference in a changeset (#8573) * Missed one doc change from a PR (#8575) * Overwrite undefined candidate index (#8577) * Overwrite undefined candidate index * Fix index overwrite condition to only be true when index is not a property * Upgrade Vertex Mock Responses to V5 (#8579) * Upgrade to mock responses v4 * Upgrade from v4 to v5 mock responses --------- Co-authored-by: wu-hui <[email protected]> Co-authored-by: DellaBitta <[email protected]> Co-authored-by: Daniel La Rocque <[email protected]> Co-authored-by: hsubox76 <[email protected]>
157 lines
3.6 KiB
TypeScript
157 lines
3.6 KiB
TypeScript
/**
|
|
* @license
|
|
* Copyright 2022 Google LLC
|
|
*
|
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
* you may not use this file except in compliance with the License.
|
|
* You may obtain a copy of the License at
|
|
*
|
|
* http://www.apache.org/licenses/LICENSE-2.0
|
|
*
|
|
* Unless required by applicable law or agreed to in writing, software
|
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
* See the License for the specific language governing permissions and
|
|
* limitations under the License.
|
|
*/
|
|
|
|
import glob from 'glob';
|
|
import { existsSync } from 'fs';
|
|
import { resolve, parse } from 'path';
|
|
import { projectRoot as root } from '../utils';
|
|
|
|
/**
|
|
* Top level fields in package.json that may point to entry point and
|
|
* typings files.
|
|
*/
|
|
const TOP_LEVEL_FIELDS = [
|
|
'main',
|
|
'browser',
|
|
'module',
|
|
'typings',
|
|
'react-native',
|
|
'cordova',
|
|
'webworker',
|
|
'main-esm'
|
|
];
|
|
|
|
interface Result {
|
|
packageName: string;
|
|
found: boolean;
|
|
filePath: string;
|
|
fieldPath: string;
|
|
}
|
|
const results: Result[] = [];
|
|
|
|
/**
|
|
* Get paths to packages. Only check the ones we actually
|
|
* publish (packages/*).
|
|
*/
|
|
function getPkgJsonPaths(): Promise<string[]> {
|
|
return new Promise((resolve, reject) => {
|
|
glob('packages/**/package.json', (err, paths) => {
|
|
if (err) reject(err);
|
|
resolve(paths);
|
|
});
|
|
});
|
|
}
|
|
|
|
/**
|
|
* Recursively check `exports` field in package.json.
|
|
*/
|
|
function checkExports(
|
|
pkgName: string,
|
|
pkgRoot: string,
|
|
path: string = '',
|
|
exports: Record<string, any>
|
|
) {
|
|
for (const key in exports) {
|
|
if (typeof exports[key] === 'string') {
|
|
const filePath = resolve(pkgRoot, exports[key]);
|
|
const result = {
|
|
packageName: pkgName,
|
|
found: false,
|
|
filePath,
|
|
fieldPath: `exports${path}[${key}]`
|
|
};
|
|
if (existsSync(filePath)) {
|
|
result.found = true;
|
|
}
|
|
results.push(result);
|
|
} else {
|
|
checkExports(
|
|
pkgName,
|
|
pkgRoot,
|
|
path ? `${path}[${key}]` : `[${key}]`,
|
|
exports[key]
|
|
);
|
|
}
|
|
}
|
|
}
|
|
|
|
async function main() {
|
|
const paths = await getPkgJsonPaths();
|
|
|
|
for (const path of paths) {
|
|
const { dir } = parse(path);
|
|
if (dir.includes('node_modules') || dir.includes('/demo')) {
|
|
continue;
|
|
}
|
|
const pkgRoot = resolve(root, dir);
|
|
if (existsSync(`${pkgRoot}/package.json`)) {
|
|
const pkg = require(`${pkgRoot}/package.json`);
|
|
if (!pkg.name) {
|
|
// Probably dummy package.json with 'type: module'
|
|
continue;
|
|
}
|
|
console.log(`Checking ${dir}/package.json`);
|
|
|
|
/**
|
|
* Check top level fields.
|
|
*/
|
|
for (const field of TOP_LEVEL_FIELDS) {
|
|
if (pkg[field]) {
|
|
const filePath = resolve(pkgRoot, pkg[field]);
|
|
const result = {
|
|
packageName: pkg.name,
|
|
found: false,
|
|
filePath,
|
|
fieldPath: field
|
|
};
|
|
if (existsSync(filePath)) {
|
|
result.found = true;
|
|
}
|
|
results.push(result);
|
|
}
|
|
}
|
|
/**
|
|
* Check all levels of exports field.
|
|
*/
|
|
if (pkg.exports) {
|
|
checkExports(pkg.name, pkgRoot, '', pkg.exports);
|
|
}
|
|
}
|
|
}
|
|
|
|
let missingPaths: boolean = false;
|
|
|
|
for (const result of results) {
|
|
if (!result.found) {
|
|
missingPaths = true;
|
|
console.log(
|
|
`${result.packageName}: Field "${result.fieldPath}" ` +
|
|
`points to ${result.filePath} which is not found.`
|
|
);
|
|
}
|
|
}
|
|
|
|
/**
|
|
* Fail CI if any missing paths found.
|
|
*/
|
|
if (missingPaths) {
|
|
process.exit(1);
|
|
}
|
|
}
|
|
|
|
main();
|