diff --git a/scripts/packaging-test/index.ts b/scripts/packaging-test/index.ts new file mode 100644 index 000000000..c474ec632 --- /dev/null +++ b/scripts/packaging-test/index.ts @@ -0,0 +1,3 @@ +import { onCall } from "firebase-functions/v2/https"; + +onCall({ cors: true }, () => null); diff --git a/scripts/packaging-test/tsconfig.json b/scripts/packaging-test/tsconfig.json new file mode 100644 index 000000000..a191f7a61 --- /dev/null +++ b/scripts/packaging-test/tsconfig.json @@ -0,0 +1,10 @@ +{ + "compilerOptions": { + "module": "commonjs", + "moduleResolution": "node", + "noEmit": true, + "strict": true, + "target": "es2022" + }, + "files": ["index.ts"] +} diff --git a/scripts/test-packaging.sh b/scripts/test-packaging.sh index 82a2b1671..8c7d30c07 100755 --- a/scripts/test-packaging.sh +++ b/scripts/test-packaging.sh @@ -38,10 +38,16 @@ fi echo "Setting up test project in $WORK_DIR..." pushd "$WORK_DIR" > /dev/null npm init -y > /dev/null -npm install "$TARBALL_PATH" +TYPESCRIPT_VERSION=$(node -p "require(process.argv[1]).devDependencies.typescript" "$SCRIPT_DIR/../package.json") +npm install "$TARBALL_PATH" "typescript@$TYPESCRIPT_VERSION" echo "Running verification script..." cp "$SCRIPT_DIR/verify-exports.mjs" . node verify-exports.mjs +echo "Verifying TypeScript declarations without esModuleInterop..." +cp "$SCRIPT_DIR/packaging-test/index.ts" . +cp "$SCRIPT_DIR/packaging-test/tsconfig.json" . +./node_modules/.bin/tsc --project tsconfig.json + popd > /dev/null diff --git a/src/common/providers/https.ts b/src/common/providers/https.ts index c636067a7..60e40a85c 100644 --- a/src/common/providers/https.ts +++ b/src/common/providers/https.ts @@ -20,7 +20,7 @@ // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE // SOFTWARE. -import cors from "cors"; +import * as cors from "cors"; import * as express from "express"; import { DecodedAppCheckToken } from "firebase-admin/app-check"; @@ -796,7 +796,7 @@ export function onCallHandler( ...options.cors, origin, }; - cors(corsOptions as cors.CorsOptions)(req, res, () => { + cors.default(corsOptions)(req, res, () => { resolve(wrapped(req, res)); }); });