From 75ab8809d1ee8a2ebb333a86175a3b3330a70692 Mon Sep 17 00:00:00 2001 From: Feiyang Date: Wed, 30 Jun 2021 23:15:33 -0700 Subject: [PATCH] Fix auth compat import (#5090) * fix auth compat import * do not use g flag in regex * revert changes for testing * update --- packages-exp/auth-compat-exp/index.ts | 13 ++++++------- packages/database/rollup.config.compat.js | 4 ++-- packages/firestore/rollup.config.browser.compat.js | 2 +- packages/firestore/rollup.config.node.compat.js | 2 +- packages/firestore/rollup.config.rn.compat.js | 2 +- packages/storage/rollup.config.compat.js | 4 ++-- scripts/exp/ts-transform-import-path.js | 5 ++--- 7 files changed, 15 insertions(+), 17 deletions(-) diff --git a/packages-exp/auth-compat-exp/index.ts b/packages-exp/auth-compat-exp/index.ts index 685ddaec20f..082b6ae38f0 100644 --- a/packages-exp/auth-compat-exp/index.ts +++ b/packages-exp/auth-compat-exp/index.ts @@ -19,7 +19,6 @@ import firebase, { _FirebaseNamespace } from '@firebase/app-compat'; import * as impl from '@firebase/auth-exp/internal'; -import * as externs from '@firebase/auth-exp'; import { Component, ComponentType, @@ -87,14 +86,14 @@ function registerAuthCompat(instance: _FirebaseNamespace): void { .setServiceProps({ ActionCodeInfo: { Operation: { - EMAIL_SIGNIN: externs.ActionCodeOperation.EMAIL_SIGNIN, - PASSWORD_RESET: externs.ActionCodeOperation.PASSWORD_RESET, - RECOVER_EMAIL: externs.ActionCodeOperation.RECOVER_EMAIL, + EMAIL_SIGNIN: impl.ActionCodeOperation.EMAIL_SIGNIN, + PASSWORD_RESET: impl.ActionCodeOperation.PASSWORD_RESET, + RECOVER_EMAIL: impl.ActionCodeOperation.RECOVER_EMAIL, REVERT_SECOND_FACTOR_ADDITION: - externs.ActionCodeOperation.REVERT_SECOND_FACTOR_ADDITION, + impl.ActionCodeOperation.REVERT_SECOND_FACTOR_ADDITION, VERIFY_AND_CHANGE_EMAIL: - externs.ActionCodeOperation.VERIFY_AND_CHANGE_EMAIL, - VERIFY_EMAIL: externs.ActionCodeOperation.VERIFY_EMAIL + impl.ActionCodeOperation.VERIFY_AND_CHANGE_EMAIL, + VERIFY_EMAIL: impl.ActionCodeOperation.VERIFY_EMAIL } }, EmailAuthProvider: impl.EmailAuthProvider, diff --git a/packages/database/rollup.config.compat.js b/packages/database/rollup.config.compat.js index b67a16ef6fd..4892413e42d 100644 --- a/packages/database/rollup.config.compat.js +++ b/packages/database/rollup.config.compat.js @@ -47,7 +47,7 @@ const es5BuildPlugins = [ transformers: [ getImportPathTransformer({ // ../../exp/index - pattern: /^.*exp\/index$/g, + pattern: /^.*exp\/index$/, template: ['@firebase/database'] }) ] @@ -111,7 +111,7 @@ const es2017BuildPlugins = [ transformers: [ getImportPathTransformer({ // ../../exp/index - pattern: /^.*exp\/index$/g, + pattern: /^.*exp\/index$/, template: ['@firebase/database'] }) ] diff --git a/packages/firestore/rollup.config.browser.compat.js b/packages/firestore/rollup.config.browser.compat.js index 069e47278c4..94384ddf8a6 100644 --- a/packages/firestore/rollup.config.browser.compat.js +++ b/packages/firestore/rollup.config.browser.compat.js @@ -37,7 +37,7 @@ export default [ 'browser', getImportPathTransformer({ // ../../exp/index - pattern: /^.*exp\/index$/g, + pattern: /^.*exp\/index$/, template: ['@firebase/firestore'] }), /* mangled= */ false diff --git a/packages/firestore/rollup.config.node.compat.js b/packages/firestore/rollup.config.node.compat.js index abc6320684d..b7d8d0ff791 100644 --- a/packages/firestore/rollup.config.node.compat.js +++ b/packages/firestore/rollup.config.node.compat.js @@ -38,7 +38,7 @@ export default [ 'node', getImportPathTransformer({ // ../../exp/index - pattern: /^.*exp\/index$/g, + pattern: /^.*exp\/index$/, template: ['@firebase/firestore'] }) ), diff --git a/packages/firestore/rollup.config.rn.compat.js b/packages/firestore/rollup.config.rn.compat.js index 523722c820e..3aab7b7fb37 100644 --- a/packages/firestore/rollup.config.rn.compat.js +++ b/packages/firestore/rollup.config.rn.compat.js @@ -34,7 +34,7 @@ export default [ 'rn', getImportPathTransformer({ // ../../exp/index - pattern: /^.*exp\/index$/g, + pattern: /^.*exp\/index$/, template: ['@firebase/firestore'] }), /* mangled= */ false diff --git a/packages/storage/rollup.config.compat.js b/packages/storage/rollup.config.compat.js index ec81fdbff89..a1b6321157d 100644 --- a/packages/storage/rollup.config.compat.js +++ b/packages/storage/rollup.config.compat.js @@ -39,7 +39,7 @@ const es5BuildPlugins = [ transformers: [ getImportPathTransformer({ // ../exp/index - pattern: /^.*exp\/api$/g, + pattern: /^.*exp\/api$/, template: ['@firebase/storage'] }) ] @@ -80,7 +80,7 @@ const es2017BuildPlugins = [ transformers: [ getImportPathTransformer({ // ../exp/index - pattern: /^.*exp\/api$/g, + pattern: /^.*exp\/api$/, template: ['@firebase/storage'] }) ], diff --git a/scripts/exp/ts-transform-import-path.js b/scripts/exp/ts-transform-import-path.js index 81294363cf7..46fb7b9217d 100644 --- a/scripts/exp/ts-transform-import-path.js +++ b/scripts/exp/ts-transform-import-path.js @@ -34,14 +34,14 @@ export function getImportPathTransformer({ pattern, template }) { export const importPathTransformer = () => ({ before: [ transformImportPath({ - pattern: /^(@firebase.*)-exp(.*)$/g, + pattern: /^(@firebase.*)-exp(.*)$/, template: [1, 2] }) ], after: [], afterDeclarations: [ transformImportPath({ - pattern: /^(@firebase.*)-exp(.*)$/g, + pattern: /^(@firebase.*)-exp(.*)$/, template: [1, 2] }) ] @@ -75,7 +75,6 @@ function visitNode(node, { pattern, template }) { ); const captures = pattern.exec(importPath); - if (captures) { const newNameFragments = []; for (const fragment of template) {