diff --git a/config/tsconfig.base.json b/config/tsconfig.base.json index d77192bd516..cf88a789aa2 100644 --- a/config/tsconfig.base.json +++ b/config/tsconfig.base.json @@ -19,6 +19,7 @@ "module": "ES2015", "moduleResolution": "node", "resolveJsonModule": true, + "esModuleInterop": true, "sourceMap": true, "target": "es5", "typeRoots": [ diff --git a/packages/analytics-compat/package.json b/packages/analytics-compat/package.json index 6a8942cb562..e176c544cf1 100644 --- a/packages/analytics-compat/package.json +++ b/packages/analytics-compat/package.json @@ -4,8 +4,16 @@ "description": "", "author": "Firebase (https://firebase.google.com/)", "main": "dist/index.cjs.js", - "browser": "dist/index.esm2017.js", - "module": "dist/index.esm2017.js", + "browser": "dist/esm/index.esm2017.js", + "module": "dist/esm/index.esm2017.js", + "esm5": "dist/esm/index.esm.js", + "exports": { + ".": { + "require": "./dist/index.cjs.js", + "default": "./dist/esm/index.esm2017.js" + }, + "./package.json": "./package.json" + }, "files": [ "dist" ], @@ -54,6 +62,5 @@ ".ts" ], "reportDir": "./coverage/node" - }, - "esm5": "dist/index.esm.js" + } } \ No newline at end of file diff --git a/packages/analytics-compat/rollup.config.js b/packages/analytics-compat/rollup.config.js index 5a54bd6baae..0fccfa7a26c 100644 --- a/packages/analytics-compat/rollup.config.js +++ b/packages/analytics-compat/rollup.config.js @@ -18,14 +18,13 @@ import json from '@rollup/plugin-json'; import typescriptPlugin from 'rollup-plugin-typescript2'; import typescript from 'typescript'; +import { emitModulePackageFile } from '../../scripts/build/rollup_emit_module_package_file'; import pkg from './package.json'; const deps = Object.keys( Object.assign({}, pkg.peerDependencies, pkg.dependencies) ); -/** - * ES5 Builds - */ + const es5BuildPlugins = [ typescriptPlugin({ typescript @@ -33,24 +32,6 @@ const es5BuildPlugins = [ json() ]; -const es5Builds = [ - /** - * Browser Builds - */ - { - input: 'src/index.ts', - output: [ - { file: pkg.main, format: 'cjs', sourcemap: true }, - { file: pkg.esm5, format: 'es', sourcemap: true } - ], - external: id => deps.some(dep => id === dep || id.startsWith(`${dep}/`)), - plugins: es5BuildPlugins - } -]; - -/** - * ES2017 Builds - */ const es2017BuildPlugins = [ typescriptPlugin({ typescript, @@ -63,11 +44,8 @@ const es2017BuildPlugins = [ json({ preferConst: true }) ]; -const es2017Builds = [ +const esmBuilds = [ { - /** - * Browser Build - */ input: 'src/index.ts', output: { file: pkg.browser, @@ -75,8 +53,23 @@ const es2017Builds = [ sourcemap: true }, external: id => deps.some(dep => id === dep || id.startsWith(`${dep}/`)), - plugins: es2017BuildPlugins + plugins: [...es2017BuildPlugins, emitModulePackageFile()] + }, + { + input: 'src/index.ts', + output: { file: pkg.esm5, format: 'es', sourcemap: true }, + external: id => deps.some(dep => id === dep || id.startsWith(`${dep}/`)), + plugins: [...es5BuildPlugins, emitModulePackageFile()] + } +]; + +const cjsBuilds = [ + { + input: 'src/index.ts', + output: { file: pkg.main, format: 'cjs', sourcemap: true }, + external: id => deps.some(dep => id === dep || id.startsWith(`${dep}/`)), + plugins: es5BuildPlugins } ]; -export default [...es5Builds, ...es2017Builds]; +export default [...esmBuilds, ...cjsBuilds]; diff --git a/packages/analytics-compat/src/service.test.ts b/packages/analytics-compat/src/service.test.ts index 30598025d61..c0995f9e32c 100644 --- a/packages/analytics-compat/src/service.test.ts +++ b/packages/analytics-compat/src/service.test.ts @@ -19,7 +19,7 @@ import { AnalyticsService } from './service'; import firebase, { FirebaseApp } from '@firebase/app-compat'; import * as analyticsExp from '@firebase/analytics'; import { stub, match, SinonStub } from 'sinon'; -import * as sinonChai from 'sinon-chai'; +import sinonChai from 'sinon-chai'; use(sinonChai); diff --git a/packages/analytics/package.json b/packages/analytics/package.json index d4bc8677126..ab30fcce8f3 100644 --- a/packages/analytics/package.json +++ b/packages/analytics/package.json @@ -4,8 +4,16 @@ "description": "A analytics package for new firebase packages", "author": "Firebase (https://firebase.google.com/)", "main": "dist/index.cjs.js", - "browser": "dist/index.esm2017.js", - "module": "dist/index.esm2017.js", + "browser": "dist/esm/index.esm2017.js", + "module": "dist/esm/index.esm2017.js", + "esm5": "dist/esm/index.esm.js", + "exports": { + ".": { + "require": "./dist/index.cjs.js", + "default": "./dist/esm/index.esm2017.js" + }, + "./package.json": "./package.json" + }, "files": [ "dist" ], @@ -60,6 +68,5 @@ ".ts" ], "reportDir": "./coverage/node" - }, - "esm5": "dist/index.esm.js" + } } \ No newline at end of file diff --git a/packages/analytics/rollup.config.js b/packages/analytics/rollup.config.js index 49ad3bc45c0..509b9690c5e 100644 --- a/packages/analytics/rollup.config.js +++ b/packages/analytics/rollup.config.js @@ -20,15 +20,13 @@ import typescriptPlugin from 'rollup-plugin-typescript2'; import replace from 'rollup-plugin-replace'; import typescript from 'typescript'; import { generateBuildTargetReplaceConfig } from '../../scripts/build/rollup_replace_build_target'; +import { emitModulePackageFile } from '../../scripts/build/rollup_emit_module_package_file'; import pkg from './package.json'; const deps = [ ...Object.keys(Object.assign({}, pkg.peerDependencies, pkg.dependencies)) ]; -/** - * ES5 Builds - */ const es5BuildPlugins = [ typescriptPlugin({ typescript @@ -36,33 +34,6 @@ const es5BuildPlugins = [ json() ]; -const es5Builds = [ - /** - * Browser Builds - */ - { - input: 'src/index.ts', - output: [{ file: pkg.main, format: 'cjs', sourcemap: true }], - external: id => deps.some(dep => id === dep || id.startsWith(`${dep}/`)), - plugins: [ - ...es5BuildPlugins, - replace(generateBuildTargetReplaceConfig('cjs', 5)) - ] - }, - { - input: 'src/index.ts', - output: [{ file: pkg.esm5, format: 'es', sourcemap: true }], - external: id => deps.some(dep => id === dep || id.startsWith(`${dep}/`)), - plugins: [ - ...es5BuildPlugins, - replace(generateBuildTargetReplaceConfig('esm', 5)) - ] - } -]; - -/** - * ES2017 Builds - */ const es2017BuildPlugins = [ typescriptPlugin({ typescript, @@ -75,11 +46,21 @@ const es2017BuildPlugins = [ json({ preferConst: true }) ]; -const es2017Builds = [ +/** + * ESM builds + */ +const esmBuilds = [ + { + input: 'src/index.ts', + output: [{ file: pkg.esm5, format: 'es', sourcemap: true }], + external: id => deps.some(dep => id === dep || id.startsWith(`${dep}/`)), + plugins: [ + ...es5BuildPlugins, + replace(generateBuildTargetReplaceConfig('esm', 5)), + emitModulePackageFile() + ] + }, { - /** - * Browser Build - */ input: 'src/index.ts', output: { file: pkg.browser, @@ -89,9 +70,25 @@ const es2017Builds = [ external: id => deps.some(dep => id === dep || id.startsWith(`${dep}/`)), plugins: [ ...es2017BuildPlugins, - replace(generateBuildTargetReplaceConfig('esm', 2017)) + replace(generateBuildTargetReplaceConfig('esm', 2017)), + emitModulePackageFile() + ] + } +]; + +/** + * CJS builds + */ +const cjsBuilds = [ + { + input: 'src/index.ts', + output: [{ file: pkg.main, format: 'cjs', sourcemap: true }], + external: id => deps.some(dep => id === dep || id.startsWith(`${dep}/`)), + plugins: [ + ...es5BuildPlugins, + replace(generateBuildTargetReplaceConfig('cjs', 5)) ] } ]; -export default [...es5Builds, ...es2017Builds]; +export default [...esmBuilds, ...cjsBuilds]; diff --git a/packages/analytics/testing/setup.ts b/packages/analytics/testing/setup.ts index 3165aab4e7e..de3f31890ab 100644 --- a/packages/analytics/testing/setup.ts +++ b/packages/analytics/testing/setup.ts @@ -16,8 +16,8 @@ */ import { use } from 'chai'; -import * as chaiAsPromised from 'chai-as-promised'; -import * as sinonChai from 'sinon-chai'; +import chaiAsPromised from 'chai-as-promised'; +import sinonChai from 'sinon-chai'; use(chaiAsPromised); use(sinonChai); diff --git a/packages/app-check-compat/package.json b/packages/app-check-compat/package.json index def56afd855..f8acdcaf3f0 100644 --- a/packages/app-check-compat/package.json +++ b/packages/app-check-compat/package.json @@ -4,8 +4,16 @@ "description": "A compat App Check package for new firebase packages", "author": "Firebase (https://firebase.google.com/)", "main": "dist/index.cjs.js", - "browser": "dist/index.esm2017.js", - "module": "dist/index.esm2017.js", + "browser": "dist/esm/index.esm2017.js", + "module": "dist/esm/index.esm2017.js", + "esm5": "dist/esm/index.esm.js", + "exports": { + ".": { + "require": "./dist/index.cjs.js", + "default": "./dist/esm/index.esm2017.js" + }, + "./package.json": "./package.json" + }, "files": [ "dist" ], @@ -55,6 +63,5 @@ ".ts" ], "reportDir": "./coverage/node" - }, - "esm5": "dist/index.esm.js" -} + } +} \ No newline at end of file diff --git a/packages/app-check-compat/rollup.config.js b/packages/app-check-compat/rollup.config.js index 5a54bd6baae..e3cc4ea55de 100644 --- a/packages/app-check-compat/rollup.config.js +++ b/packages/app-check-compat/rollup.config.js @@ -18,14 +18,13 @@ import json from '@rollup/plugin-json'; import typescriptPlugin from 'rollup-plugin-typescript2'; import typescript from 'typescript'; +import { emitModulePackageFile } from '../../scripts/build/rollup_emit_module_package_file'; import pkg from './package.json'; const deps = Object.keys( Object.assign({}, pkg.peerDependencies, pkg.dependencies) ); -/** - * ES5 Builds - */ + const es5BuildPlugins = [ typescriptPlugin({ typescript @@ -33,24 +32,6 @@ const es5BuildPlugins = [ json() ]; -const es5Builds = [ - /** - * Browser Builds - */ - { - input: 'src/index.ts', - output: [ - { file: pkg.main, format: 'cjs', sourcemap: true }, - { file: pkg.esm5, format: 'es', sourcemap: true } - ], - external: id => deps.some(dep => id === dep || id.startsWith(`${dep}/`)), - plugins: es5BuildPlugins - } -]; - -/** - * ES2017 Builds - */ const es2017BuildPlugins = [ typescriptPlugin({ typescript, @@ -63,11 +44,14 @@ const es2017BuildPlugins = [ json({ preferConst: true }) ]; -const es2017Builds = [ +const esmBuilds = [ + { + input: 'src/index.ts', + output: { file: pkg.esm5, format: 'es', sourcemap: true }, + external: id => deps.some(dep => id === dep || id.startsWith(`${dep}/`)), + plugins: [...es5BuildPlugins, emitModulePackageFile()] + }, { - /** - * Browser Build - */ input: 'src/index.ts', output: { file: pkg.browser, @@ -75,8 +59,17 @@ const es2017Builds = [ sourcemap: true }, external: id => deps.some(dep => id === dep || id.startsWith(`${dep}/`)), - plugins: es2017BuildPlugins + plugins: [...es2017BuildPlugins, emitModulePackageFile()] + } +]; + +const cjsBuilds = [ + { + input: 'src/index.ts', + output: { file: pkg.main, format: 'cjs', sourcemap: true }, + external: id => deps.some(dep => id === dep || id.startsWith(`${dep}/`)), + plugins: es5BuildPlugins } ]; -export default [...es5Builds, ...es2017Builds]; +export default [...esmBuilds, ...cjsBuilds]; diff --git a/packages/app-check-compat/rollup.shared.js b/packages/app-check-compat/rollup.shared.js deleted file mode 100644 index 776f45fed8c..00000000000 --- a/packages/app-check-compat/rollup.shared.js +++ /dev/null @@ -1,16 +0,0 @@ -/** - * @license - * Copyright 2021 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. - */ diff --git a/packages/app-check-compat/src/service.test.ts b/packages/app-check-compat/src/service.test.ts index 6679c6b4823..b254feec801 100644 --- a/packages/app-check-compat/src/service.test.ts +++ b/packages/app-check-compat/src/service.test.ts @@ -19,7 +19,7 @@ import { AppCheckService } from './service'; import firebase, { FirebaseApp } from '@firebase/app-compat'; import * as appCheckExp from '@firebase/app-check'; import { stub, match, SinonStub } from 'sinon'; -import * as sinonChai from 'sinon-chai'; +import sinonChai from 'sinon-chai'; import { AppCheck, CustomProvider, diff --git a/packages/app-check/package.json b/packages/app-check/package.json index 2a8d2e59655..162dffbde0c 100644 --- a/packages/app-check/package.json +++ b/packages/app-check/package.json @@ -4,8 +4,16 @@ "description": "The App Check component of the Firebase JS SDK", "author": "Firebase (https://firebase.google.com/)", "main": "dist/index.cjs.js", - "browser": "dist/index.esm2017.js", - "module": "dist/index.esm2017.js", + "browser": "dist/esm/index.esm2017.js", + "module": "dist/esm/index.esm2017.js", + "esm5": "dist/esm/index.esm.js", + "exports": { + ".": { + "require": "./dist/index.cjs.js", + "default": "./dist/esm/index.esm2017.js" + }, + "./package.json": "./package.json" + }, "files": [ "dist" ], @@ -57,6 +65,5 @@ ".ts" ], "reportDir": "./coverage/node" - }, - "esm5": "dist/index.esm.js" + } } \ No newline at end of file diff --git a/packages/app-check/rollup.config.js b/packages/app-check/rollup.config.js index 5a54bd6baae..e3cc4ea55de 100644 --- a/packages/app-check/rollup.config.js +++ b/packages/app-check/rollup.config.js @@ -18,14 +18,13 @@ import json from '@rollup/plugin-json'; import typescriptPlugin from 'rollup-plugin-typescript2'; import typescript from 'typescript'; +import { emitModulePackageFile } from '../../scripts/build/rollup_emit_module_package_file'; import pkg from './package.json'; const deps = Object.keys( Object.assign({}, pkg.peerDependencies, pkg.dependencies) ); -/** - * ES5 Builds - */ + const es5BuildPlugins = [ typescriptPlugin({ typescript @@ -33,24 +32,6 @@ const es5BuildPlugins = [ json() ]; -const es5Builds = [ - /** - * Browser Builds - */ - { - input: 'src/index.ts', - output: [ - { file: pkg.main, format: 'cjs', sourcemap: true }, - { file: pkg.esm5, format: 'es', sourcemap: true } - ], - external: id => deps.some(dep => id === dep || id.startsWith(`${dep}/`)), - plugins: es5BuildPlugins - } -]; - -/** - * ES2017 Builds - */ const es2017BuildPlugins = [ typescriptPlugin({ typescript, @@ -63,11 +44,14 @@ const es2017BuildPlugins = [ json({ preferConst: true }) ]; -const es2017Builds = [ +const esmBuilds = [ + { + input: 'src/index.ts', + output: { file: pkg.esm5, format: 'es', sourcemap: true }, + external: id => deps.some(dep => id === dep || id.startsWith(`${dep}/`)), + plugins: [...es5BuildPlugins, emitModulePackageFile()] + }, { - /** - * Browser Build - */ input: 'src/index.ts', output: { file: pkg.browser, @@ -75,8 +59,17 @@ const es2017Builds = [ sourcemap: true }, external: id => deps.some(dep => id === dep || id.startsWith(`${dep}/`)), - plugins: es2017BuildPlugins + plugins: [...es2017BuildPlugins, emitModulePackageFile()] + } +]; + +const cjsBuilds = [ + { + input: 'src/index.ts', + output: { file: pkg.main, format: 'cjs', sourcemap: true }, + external: id => deps.some(dep => id === dep || id.startsWith(`${dep}/`)), + plugins: es5BuildPlugins } ]; -export default [...es5Builds, ...es2017Builds]; +export default [...esmBuilds, ...cjsBuilds]; diff --git a/packages/app-check/test/setup.ts b/packages/app-check/test/setup.ts index 4426a0a8bf4..cf6ea9095b6 100644 --- a/packages/app-check/test/setup.ts +++ b/packages/app-check/test/setup.ts @@ -16,9 +16,9 @@ */ import { use } from 'chai'; -import * as chaiAsPromised from 'chai-as-promised'; +import chaiAsPromised from 'chai-as-promised'; import { restore } from 'sinon'; -import * as sinonChai from 'sinon-chai'; +import sinonChai from 'sinon-chai'; use(chaiAsPromised); use(sinonChai); diff --git a/packages/app-compat/package.json b/packages/app-compat/package.json index e8c6d8ced8c..472164bd9e9 100644 --- a/packages/app-compat/package.json +++ b/packages/app-compat/package.json @@ -4,10 +4,18 @@ "description": "The primary entrypoint to the Firebase JS SDK", "author": "Firebase (https://firebase.google.com/)", "main": "dist/index.cjs.js", - "browser": "dist/index.esm2017.js", - "module": "dist/index.esm2017.js", + "browser": "dist/esm/index.esm2017.js", + "module": "dist/esm/index.esm2017.js", + "esm5": "dist/esm/index.esm5.js", "lite": "dist/index.lite.js", "lite-esm5": "dist/index.lite.esm5.js", + "exports": { + ".": { + "require": "./dist/index.cjs.js", + "default": "./dist/esm/index.esm2017.js" + }, + "./package.json": "./package.json" + }, "files": [ "dist" ], @@ -55,6 +63,5 @@ ".ts" ], "reportDir": "./coverage/node" - }, - "esm5": "dist/index.esm5.js" -} + } +} \ No newline at end of file diff --git a/packages/app-compat/rollup.config.js b/packages/app-compat/rollup.config.js index 6f4a9067e81..85781edb5cb 100644 --- a/packages/app-compat/rollup.config.js +++ b/packages/app-compat/rollup.config.js @@ -18,15 +18,13 @@ import typescriptPlugin from 'rollup-plugin-typescript2'; import json from '@rollup/plugin-json'; import typescript from 'typescript'; +import { emitModulePackageFile } from '../../scripts/build/rollup_emit_module_package_file'; import pkg from './package.json'; const deps = Object.keys( Object.assign({}, pkg.peerDependencies, pkg.dependencies) ); -/** - * ES5 Builds - */ const es5BuildPlugins = [ typescriptPlugin({ typescript, @@ -35,31 +33,6 @@ const es5BuildPlugins = [ json() ]; -const es5Builds = [ - { - input: 'src/index.ts', - output: [ - { file: pkg.main, format: 'cjs', sourcemap: true }, - { file: pkg.esm5, format: 'es', sourcemap: true } - ], - plugins: es5BuildPlugins, - external: id => deps.some(dep => id === dep || id.startsWith(`${dep}/`)) - }, - { - input: 'src/index.lite.ts', - output: { - file: pkg['lite-esm5'], - format: 'es', - sourcemap: true - }, - plugins: es5BuildPlugins, - external: id => deps.some(dep => id === dep || id.startsWith(`${dep}/`)) - } -]; - -/** - * ES2017 Builds - */ const es2017BuildPlugins = [ typescriptPlugin({ typescript, @@ -75,10 +48,23 @@ const es2017BuildPlugins = [ }) ]; -const es2017Builds = [ - /** - * Browser Builds - */ +const esmBuilds = [ + { + input: 'src/index.ts', + output: { file: pkg.esm5, format: 'es', sourcemap: true }, + plugins: [...es5BuildPlugins, emitModulePackageFile()], + external: id => deps.some(dep => id === dep || id.startsWith(`${dep}/`)) + }, + { + input: 'src/index.lite.ts', + output: { + file: pkg['lite-esm5'], + format: 'es', + sourcemap: true + }, + plugins: es5BuildPlugins, + external: id => deps.some(dep => id === dep || id.startsWith(`${dep}/`)) + }, { input: 'src/index.ts', output: { @@ -86,7 +72,7 @@ const es2017Builds = [ format: 'es', sourcemap: true }, - plugins: es2017BuildPlugins, + plugins: [...es2017BuildPlugins, emitModulePackageFile()], external: id => deps.some(dep => id === dep || id.startsWith(`${dep}/`)) }, { @@ -101,4 +87,13 @@ const es2017Builds = [ } ]; -export default [...es5Builds, ...es2017Builds]; +const cjsBuilds = [ + { + input: 'src/index.ts', + output: { file: pkg.main, format: 'cjs', sourcemap: true }, + plugins: es5BuildPlugins, + external: id => deps.some(dep => id === dep || id.startsWith(`${dep}/`)) + } +]; + +export default [...esmBuilds, ...cjsBuilds]; diff --git a/packages/app-compat/test/setup.ts b/packages/app-compat/test/setup.ts index b1e3136529f..899b4867c1a 100644 --- a/packages/app-compat/test/setup.ts +++ b/packages/app-compat/test/setup.ts @@ -17,7 +17,7 @@ import { use } from 'chai'; import { restore } from 'sinon'; -import * as sinonChai from 'sinon-chai'; +import sinonChai from 'sinon-chai'; use(sinonChai); diff --git a/packages/app/package.json b/packages/app/package.json index 5b2d7bf8b24..e05d666c03d 100644 --- a/packages/app/package.json +++ b/packages/app/package.json @@ -4,8 +4,16 @@ "description": "The primary entrypoint to the Firebase JS SDK", "author": "Firebase (https://firebase.google.com/)", "main": "dist/index.cjs.js", - "browser": "dist/index.esm2017.js", - "module": "dist/index.esm2017.js", + "browser": "dist/esm/index.esm2017.js", + "module": "dist/esm/index.esm2017.js", + "esm5": "dist/esm/index.esm5.js", + "exports": { + ".": { + "require": "./dist/index.cjs.js", + "default": "./dist/esm/index.esm2017.js" + }, + "./package.json": "./package.json" + }, "files": [ "dist" ], @@ -55,6 +63,5 @@ ".ts" ], "reportDir": "./coverage/node" - }, - "esm5": "dist/index.esm5.js" + } } \ No newline at end of file diff --git a/packages/app/rollup.config.js b/packages/app/rollup.config.js index cac494df977..c126cde4387 100644 --- a/packages/app/rollup.config.js +++ b/packages/app/rollup.config.js @@ -20,15 +20,13 @@ import replace from 'rollup-plugin-replace'; import typescript from 'typescript'; import json from '@rollup/plugin-json'; import { generateBuildTargetReplaceConfig } from '../../scripts/build/rollup_replace_build_target'; +import { emitModulePackageFile } from '../../scripts/build/rollup_emit_module_package_file'; import pkg from './package.json'; const deps = Object.keys( Object.assign({}, pkg.peerDependencies, pkg.dependencies) ); -/** - * ES5 Builds - */ const es5BuildPlugins = [ typescriptPlugin({ typescript @@ -36,42 +34,6 @@ const es5BuildPlugins = [ json() ]; -const es5Builds = [ - /** - * Browser Builds - */ - { - input: 'src/index.ts', - output: [{ file: pkg.esm5, format: 'es', sourcemap: true }], - external: id => deps.some(dep => id === dep || id.startsWith(`${dep}/`)), - plugins: [ - ...es5BuildPlugins, - replace({ - ...generateBuildTargetReplaceConfig('esm', 5), - '__RUNTIME_ENV__': '' - }) - ] - }, - /** - * Node.js Build - */ - { - input: 'src/index.ts', - output: [{ file: pkg.main, format: 'cjs', sourcemap: true }], - external: id => deps.some(dep => id === dep || id.startsWith(`${dep}/`)), - plugins: [ - ...es5BuildPlugins, - replace({ - ...generateBuildTargetReplaceConfig('cjs', 5), - '__RUNTIME_ENV__': 'node' - }) - ] - } -]; - -/** - * ES2017 Builds - */ const es2017BuildPlugins = [ typescriptPlugin({ typescript, @@ -86,10 +48,23 @@ const es2017BuildPlugins = [ }) ]; -const es2017Builds = [ +const esmBuilds = [ /** - * Browser Builds + * Browser Builds */ + { + input: 'src/index.ts', + output: [{ file: pkg.esm5, format: 'es', sourcemap: true }], + external: id => deps.some(dep => id === dep || id.startsWith(`${dep}/`)), + plugins: [ + ...es5BuildPlugins, + replace({ + ...generateBuildTargetReplaceConfig('esm', 5), + '__RUNTIME_ENV__': '' + }), + emitModulePackageFile() + ] + }, { input: 'src/index.ts', output: { @@ -103,9 +78,25 @@ const es2017Builds = [ replace({ ...generateBuildTargetReplaceConfig('esm', 2017), '__RUNTIME_ENV__': '' + }), + emitModulePackageFile() + ] + } +]; + +const cjsBuilds = [ + { + input: 'src/index.ts', + output: [{ file: pkg.main, format: 'cjs', sourcemap: true }], + external: id => deps.some(dep => id === dep || id.startsWith(`${dep}/`)), + plugins: [ + ...es5BuildPlugins, + replace({ + ...generateBuildTargetReplaceConfig('cjs', 5), + '__RUNTIME_ENV__': 'node' }) ] } ]; -export default [...es5Builds, ...es2017Builds]; +export default [...esmBuilds, ...cjsBuilds]; diff --git a/packages/app/test/setup.ts b/packages/app/test/setup.ts index b1e3136529f..899b4867c1a 100644 --- a/packages/app/test/setup.ts +++ b/packages/app/test/setup.ts @@ -17,7 +17,7 @@ import { use } from 'chai'; import { restore } from 'sinon'; -import * as sinonChai from 'sinon-chai'; +import sinonChai from 'sinon-chai'; use(sinonChai); diff --git a/packages/auth-compat/package.json b/packages/auth-compat/package.json index 337ca7c6a94..4bdccfd74a0 100644 --- a/packages/auth-compat/package.json +++ b/packages/auth-compat/package.json @@ -6,6 +6,17 @@ "main": "dist/index.node.cjs.js", "browser": "dist/index.esm2017.js", "module": "dist/index.esm2017.js", + "esm5": "dist/index.esm.js", + "exports": { + ".": { + "node": { + "import": "./dist/esm/index.node.esm.js", + "require": "./dist/index.node.cjs.js" + }, + "default": "./dist/index.esm2017.js" + }, + "./package.json": "./package.json" + }, "files": [ "dist" ], @@ -62,6 +73,5 @@ ".ts" ], "reportDir": "./coverage/node" - }, - "esm5": "dist/index.esm.js" -} + } +} \ No newline at end of file diff --git a/packages/auth-compat/rollup.config.js b/packages/auth-compat/rollup.config.js index 2211770f6f6..5b767355657 100644 --- a/packages/auth-compat/rollup.config.js +++ b/packages/auth-compat/rollup.config.js @@ -20,6 +20,7 @@ import resolve from '@rollup/plugin-node-resolve'; import { uglify } from 'rollup-plugin-uglify'; import typescriptPlugin from 'rollup-plugin-typescript2'; import typescript from 'typescript'; +import { emitModulePackageFile } from '../../scripts/build/rollup_emit_module_package_file'; import pkg from './package.json'; const deps = Object.keys( @@ -31,9 +32,6 @@ const deps = Object.keys( */ const commonPlugins = [json(), resolve()]; -/** - * ES5 Builds - */ const es5BuildPlugins = [ ...commonPlugins, typescriptPlugin({ @@ -41,74 +39,6 @@ const es5BuildPlugins = [ }) ]; -const es5Builds = [ - /** - * Browser Builds - */ - { - input: 'index.ts', - output: [{ file: pkg.esm5, format: 'esm', sourcemap: true }], - plugins: es5BuildPlugins, - external: id => deps.some(dep => id === dep || id.startsWith(`${dep}/`)), - treeshake: { - moduleSideEffects: false - } - }, - /** - * Node.js Build - */ - { - input: 'index.node.ts', - output: [{ file: pkg.main, format: 'cjs', sourcemap: true }], - plugins: es5BuildPlugins, - external: id => deps.some(dep => id === dep || id.startsWith(`${dep}/`)), - treeshake: { - moduleSideEffects: true - } - }, - /** - * UMD build - */ - { - input: `./index.ts`, - output: { - compact: true, - file: `dist/firebase-auth.js`, - format: 'umd', - sourcemap: true, - extend: true, - name: 'firebase', - globals: { - '@firebase/app-compat': 'firebase', - '@firebase/app': 'firebase.INTERNAL.modularAPIs' - }, - /** - * use iife to avoid below error in the old Safari browser - * SyntaxError: Functions cannot be declared in a nested block in strict mode - * https://github.com/firebase/firebase-js-sdk/issues/1228 - * - */ - intro: ` - try { - (function() {`, - outro: ` - }).apply(this, arguments); - } catch(err) { - console.error(err); - throw new Error( - 'Cannot instantiate firebase-auth.js - ' + - 'be sure to load firebase-app.js first.' - ); - }` - }, - plugins: [...es5BuildPlugins, uglify()], - external: ['@firebase/app-compat', '@firebase/app'] - } -]; - -/** - * ES2017 Builds - */ const es2017BuildPlugins = [ ...commonPlugins, typescriptPlugin({ @@ -120,10 +50,17 @@ const es2017BuildPlugins = [ } }) ]; -const es2017Builds = [ - /** - * Browser Builds - */ + +const browserBuilds = [ + { + input: 'index.ts', + output: [{ file: pkg.esm5, format: 'es', sourcemap: true }], + plugins: es5BuildPlugins, + external: id => deps.some(dep => id === dep || id.startsWith(`${dep}/`)), + treeshake: { + moduleSideEffects: false + } + }, { input: 'index.ts', output: { @@ -139,4 +76,63 @@ const es2017Builds = [ } ]; -export default [...es5Builds, ...es2017Builds]; +const nodeBuilds = [ + { + input: 'index.node.ts', + output: [{ file: pkg.main, format: 'cjs', sourcemap: true }], + plugins: es5BuildPlugins, + external: id => deps.some(dep => id === dep || id.startsWith(`${dep}/`)), + treeshake: { + moduleSideEffects: true + } + }, + { + input: 'index.node.ts', + output: [ + { file: pkg.exports['.'].node.import, format: 'es', sourcemap: true } + ], + plugins: [...es2017BuildPlugins, emitModulePackageFile()], + external: id => deps.some(dep => id === dep || id.startsWith(`${dep}/`)), + treeshake: { + moduleSideEffects: true + } + } +]; + +const umdBuild = { + input: `./index.ts`, + output: { + compact: true, + file: `dist/firebase-auth.js`, + format: 'umd', + sourcemap: true, + extend: true, + name: 'firebase', + globals: { + '@firebase/app-compat': 'firebase', + '@firebase/app': 'firebase.INTERNAL.modularAPIs' + }, + /** + * use iife to avoid below error in the old Safari browser + * SyntaxError: Functions cannot be declared in a nested block in strict mode + * https://github.com/firebase/firebase-js-sdk/issues/1228 + * + */ + intro: ` + try { + (function() {`, + outro: ` + }).apply(this, arguments); + } catch(err) { + console.error(err); + throw new Error( + 'Cannot instantiate firebase-auth.js - ' + + 'be sure to load firebase-app.js first.' + ); + }` + }, + plugins: [...es5BuildPlugins, uglify()], + external: ['@firebase/app-compat', '@firebase/app'] +}; + +export default [...browserBuilds, ...nodeBuilds, umdBuild]; diff --git a/packages/auth-compat/src/auth.test.ts b/packages/auth-compat/src/auth.test.ts index 0de0bc42e44..4ccae935d78 100644 --- a/packages/auth-compat/src/auth.test.ts +++ b/packages/auth-compat/src/auth.test.ts @@ -20,7 +20,7 @@ import * as exp from '@firebase/auth/internal'; import { Provider } from '@firebase/component'; import { expect, use } from 'chai'; import * as sinon from 'sinon'; -import * as sinonChai from 'sinon-chai'; +import sinonChai from 'sinon-chai'; import { Auth } from './auth'; import { CompatPopupRedirectResolver } from './popup_redirect'; diff --git a/packages/auth-compat/src/popup_redirect.test.ts b/packages/auth-compat/src/popup_redirect.test.ts index 3399bf8d5af..be01b8f622e 100644 --- a/packages/auth-compat/src/popup_redirect.test.ts +++ b/packages/auth-compat/src/popup_redirect.test.ts @@ -16,7 +16,7 @@ */ import { expect, use } from 'chai'; -import * as sinonChai from 'sinon-chai'; +import sinonChai from 'sinon-chai'; import * as sinon from 'sinon'; import * as exp from '@firebase/auth/internal'; import * as platform from './platform'; diff --git a/packages/auth-compat/test/integration/flows/anonymous.test.ts b/packages/auth-compat/test/integration/flows/anonymous.test.ts index 85c82465e9c..45f0fb7f733 100644 --- a/packages/auth-compat/test/integration/flows/anonymous.test.ts +++ b/packages/auth-compat/test/integration/flows/anonymous.test.ts @@ -16,7 +16,7 @@ */ import { expect, use } from 'chai'; -import * as chaiAsPromised from 'chai-as-promised'; +import chaiAsPromised from 'chai-as-promised'; import firebase from '@firebase/app-compat'; import { FirebaseError } from '@firebase/util'; diff --git a/packages/auth-compat/test/integration/flows/custom.test.ts b/packages/auth-compat/test/integration/flows/custom.test.ts index 6333bf7b7f1..7fe45521c97 100644 --- a/packages/auth-compat/test/integration/flows/custom.test.ts +++ b/packages/auth-compat/test/integration/flows/custom.test.ts @@ -21,7 +21,7 @@ import firebase from '@firebase/app-compat'; // eslint-disable-next-line import/no-extraneous-dependencies import '@firebase/auth-compat'; -import * as chaiAsPromised from 'chai-as-promised'; +import chaiAsPromised from 'chai-as-promised'; import { cleanUpTestInstance, initializeTestInstance, diff --git a/packages/auth-compat/test/integration/flows/email.test.ts b/packages/auth-compat/test/integration/flows/email.test.ts index eef2adad2d4..24829276c23 100644 --- a/packages/auth-compat/test/integration/flows/email.test.ts +++ b/packages/auth-compat/test/integration/flows/email.test.ts @@ -16,7 +16,7 @@ */ import { expect, use } from 'chai'; -import * as chaiAsPromised from 'chai-as-promised'; +import chaiAsPromised from 'chai-as-promised'; import { FirebaseError } from '@firebase/util'; import firebase from '@firebase/app-compat'; diff --git a/packages/auth-compat/test/integration/flows/idp.test.ts b/packages/auth-compat/test/integration/flows/idp.test.ts index d0ff10e235e..010e7240430 100644 --- a/packages/auth-compat/test/integration/flows/idp.test.ts +++ b/packages/auth-compat/test/integration/flows/idp.test.ts @@ -18,7 +18,7 @@ import firebase from '@firebase/app-compat'; import { FirebaseError } from '@firebase/util'; import { expect, use } from 'chai'; -import * as chaiAsPromised from 'chai-as-promised'; +import chaiAsPromised from 'chai-as-promised'; import { cleanUpTestInstance, initializeTestInstance, diff --git a/packages/auth-compat/test/integration/flows/oob.test.ts b/packages/auth-compat/test/integration/flows/oob.test.ts index ba36a4d5dba..da7d07cea38 100644 --- a/packages/auth-compat/test/integration/flows/oob.test.ts +++ b/packages/auth-compat/test/integration/flows/oob.test.ts @@ -17,7 +17,7 @@ import { FirebaseError } from '@firebase/util'; import { expect, use } from 'chai'; -import * as chaiAsPromised from 'chai-as-promised'; +import chaiAsPromised from 'chai-as-promised'; import firebase from '@firebase/app-compat'; import { getOobCodes, diff --git a/packages/auth-compat/test/integration/flows/phone.test.ts b/packages/auth-compat/test/integration/flows/phone.test.ts index fe50494d633..fc623c4177d 100644 --- a/packages/auth-compat/test/integration/flows/phone.test.ts +++ b/packages/auth-compat/test/integration/flows/phone.test.ts @@ -16,7 +16,7 @@ */ import { expect, use } from 'chai'; -import * as chaiAsPromised from 'chai-as-promised'; +import chaiAsPromised from 'chai-as-promised'; import { FirebaseError } from '@firebase/util'; import firebase from '@firebase/app-compat'; import { diff --git a/packages/auth/package.json b/packages/auth/package.json index 54ef9c8d5fb..736ebd424f6 100644 --- a/packages/auth/package.json +++ b/packages/auth/package.json @@ -6,9 +6,32 @@ "main": "dist/node/index.js", "react-native": "dist/rn/index.js", "browser": "dist/esm2017/index.js", - "cordova": "dist/cordova/index.esm5.js", "module": "dist/esm2017/index.js", + "cordova": "dist/cordova/index.esm5.js", "webworker": "dist/index.webworker.esm5.js", + "esm5": "dist/esm5/index.js", + "exports": { + ".": { + "node": { + "import": "./dist/node-esm/index.js", + "require": "./dist/node/index.js" + }, + "react-native": "./dist/rn/index.js", + "cordova": "./dist/cordova/index.esm5.js", + "webworker": "./dist/index.webworker.esm5.js", + "default": "./dist/esm2017/index.js" + }, + "./internal": { + "node": { + "import": "./dist/node-esm/internal.js", + "require": "./dist/node/internal.js" + }, + "react-native": "./dist/rn/internal.js", + "cordova": "./dist/cordova/internal.js", + "default": "./dist/esm2017/internal.js" + }, + "./package.json": "./package.json" + }, "files": [ "dist", "cordova/package.json", @@ -81,6 +104,5 @@ ".ts" ], "reportDir": "./coverage/node" - }, - "esm5": "dist/esm5/index.js" + } } \ No newline at end of file diff --git a/packages/auth/rollup.config.js b/packages/auth/rollup.config.js index c32a1e18e92..9dd90fc6415 100644 --- a/packages/auth/rollup.config.js +++ b/packages/auth/rollup.config.js @@ -22,6 +22,7 @@ import replace from 'rollup-plugin-replace'; import typescript from 'typescript'; import alias from '@rollup/plugin-alias'; import { generateBuildTargetReplaceConfig } from '../../scripts/build/rollup_replace_build_target'; +import { emitModulePackageFile } from '../../scripts/build/rollup_emit_module_package_file'; import pkg from './package.json'; const deps = Object.keys(Object.assign({}, pkg.peerDependencies, pkg.dependencies)); @@ -40,9 +41,7 @@ const nodeAliasPlugin = alias({ } ] }); -/** - * ES5 Builds - */ + const es5BuildPlugins = [ json(), strip({ @@ -53,10 +52,22 @@ const es5BuildPlugins = [ }) ]; -const es5Builds = [ - /** - * Browser Builds - */ +const es2017BuildPlugins = [ + json(), + strip({ + functions: ['debugAssert.*'] + }), + typescriptPlugin({ + typescript, + tsconfigOverride: { + compilerOptions: { + target: 'es2017' + } + } + }) +]; + +const browserBuilds = [ { input: { index: 'index.ts', @@ -66,36 +77,25 @@ const es5Builds = [ plugins: [...es5BuildPlugins, replace(generateBuildTargetReplaceConfig('esm', 5))], external: id => deps.some(dep => id === dep || id.startsWith(`${dep}/`)) }, - /** - * Web Worker Build (compiled without DOM) - */ { - input: 'index.webworker.ts', - output: [{ file: pkg.webworker, format: 'es', sourcemap: true }], + input: { + index: 'index.ts', + internal: 'internal/index.ts' + }, + output: { + dir: 'dist/esm2017', + format: 'es', + sourcemap: true + }, plugins: [ - json(), - strip({ - functions: ['debugAssert.*'] - }), - typescriptPlugin({ - typescript, - compilerOptions: { - lib: [ - // Remove dom after we figure out why navigator stuff doesn't exist - 'dom', - 'es2015', - 'webworker' - ] - } - - }), - replace(generateBuildTargetReplaceConfig('esm', 5)) + ...es2017BuildPlugins, + replace(generateBuildTargetReplaceConfig('esm', 2017)) ], external: id => deps.some(dep => id === dep || id.startsWith(`${dep}/`)) - }, - /** - * Node.js Build - */ + } +]; + +const nodeBuilds = [ { input: { index: 'index.node.ts', @@ -109,80 +109,75 @@ const es5Builds = [ ], external: id => deps.some(dep => id === dep || id.startsWith(`${dep}/`)) }, - /** - * Cordova Builds - */ - { - input: { - index: 'index.cordova.ts', - internal: 'internal/index.ts' - }, - output: [{ dir: 'dist/cordova', format: 'es', sourcemap: true }], - plugins: [ - ...es5BuildPlugins, - replace(generateBuildTargetReplaceConfig('esm', 5)) - ], - external: id => - [...deps, 'cordova'].some(dep => id === dep || id.startsWith(`${dep}/`)) - }, - /** - * React Native Builds - */ { input: { - index: 'index.rn.ts', + index: 'index.node.ts', internal: 'internal/index.ts' }, - output: [{ dir: 'dist/rn', format: 'cjs', sourcemap: true }], + output: [{ dir: 'dist/node-esm', format: 'es', sourcemap: true }], plugins: [ - ...es5BuildPlugins, - replace(generateBuildTargetReplaceConfig('cjs', 5)) + nodeAliasPlugin, + ...es2017BuildPlugins, + replace(generateBuildTargetReplaceConfig('esm', 2017)), + emitModulePackageFile() ], - external: id => - [...deps, 'react-native'].some( - dep => id === dep || id.startsWith(`${dep}/`) - ) + external: id => deps.some(dep => id === dep || id.startsWith(`${dep}/`)) } ]; -/** - * ES2017 Builds - */ -const es2017BuildPlugins = [ - json(), - strip({ - functions: ['debugAssert.*'] - }), - typescriptPlugin({ - typescript, - tsconfigOverride: { +const cordovaBuild = { + input: { + index: 'index.cordova.ts', + internal: 'internal/index.ts' + }, + output: [{ dir: 'dist/cordova', format: 'es', sourcemap: true }], + plugins: [ + ...es5BuildPlugins, + replace(generateBuildTargetReplaceConfig('esm', 5)) + ], + external: id => + [...deps, 'cordova'].some(dep => id === dep || id.startsWith(`${dep}/`)) +}; + +const rnBuild = { + input: { + index: 'index.rn.ts', + internal: 'internal/index.ts' + }, + output: [{ dir: 'dist/rn', format: 'cjs', sourcemap: true }], + plugins: [ + ...es5BuildPlugins, + replace(generateBuildTargetReplaceConfig('cjs', 5)) + ], + external: id => + [...deps, 'react-native'].some( + dep => id === dep || id.startsWith(`${dep}/`) + ) +}; + +const webWorkerBuild = { + input: 'index.webworker.ts', + output: [{ file: pkg.webworker, format: 'es', sourcemap: true }], + plugins: [ + json(), + strip({ + functions: ['debugAssert.*'] + }), + typescriptPlugin({ + typescript, compilerOptions: { - target: 'es2017' + lib: [ + // Remove dom after we figure out why navigator stuff doesn't exist + 'dom', + 'es2015', + 'webworker' + ] } - } - }) -]; -const es2017Builds = [ - /** - * Browser Builds - */ - { - input: { - index: 'index.ts', - internal: 'internal/index.ts' - }, - output: { - dir: 'dist/esm2017', - format: 'es', - sourcemap: true - }, - plugins: [ - ...es2017BuildPlugins, - replace(generateBuildTargetReplaceConfig('esm', 2017)) - ], - external: id => deps.some(dep => id === dep || id.startsWith(`${dep}/`)) - } -]; + }), + replace(generateBuildTargetReplaceConfig('esm', 5)) + ], + external: id => deps.some(dep => id === dep || id.startsWith(`${dep}/`)) +}; -export default [...es5Builds, ...es2017Builds]; +export default [...browserBuilds, ...nodeBuilds, cordovaBuild, rnBuild, webWorkerBuild]; diff --git a/packages/auth/src/api/account_management/account.test.ts b/packages/auth/src/api/account_management/account.test.ts index 896786baccb..36293e64e2c 100644 --- a/packages/auth/src/api/account_management/account.test.ts +++ b/packages/auth/src/api/account_management/account.test.ts @@ -16,7 +16,7 @@ */ import { expect, use } from 'chai'; -import * as chaiAsPromised from 'chai-as-promised'; +import chaiAsPromised from 'chai-as-promised'; import { ProviderId } from '../../model/enums'; import { FirebaseError } from '@firebase/util'; diff --git a/packages/auth/src/api/account_management/email_and_password.test.ts b/packages/auth/src/api/account_management/email_and_password.test.ts index a77fdc5905a..e5268860b47 100644 --- a/packages/auth/src/api/account_management/email_and_password.test.ts +++ b/packages/auth/src/api/account_management/email_and_password.test.ts @@ -16,7 +16,7 @@ */ import { expect, use } from 'chai'; -import * as chaiAsPromised from 'chai-as-promised'; +import chaiAsPromised from 'chai-as-promised'; import { FirebaseError } from '@firebase/util'; diff --git a/packages/auth/src/api/account_management/mfa.test.ts b/packages/auth/src/api/account_management/mfa.test.ts index a2974eceb72..ec9da17cb6f 100644 --- a/packages/auth/src/api/account_management/mfa.test.ts +++ b/packages/auth/src/api/account_management/mfa.test.ts @@ -16,7 +16,7 @@ */ import { expect, use } from 'chai'; -import * as chaiAsPromised from 'chai-as-promised'; +import chaiAsPromised from 'chai-as-promised'; import { FirebaseError } from '@firebase/util'; diff --git a/packages/auth/src/api/account_management/profile.test.ts b/packages/auth/src/api/account_management/profile.test.ts index 085b5ac4d8a..d39965d69c5 100644 --- a/packages/auth/src/api/account_management/profile.test.ts +++ b/packages/auth/src/api/account_management/profile.test.ts @@ -16,7 +16,7 @@ */ import { expect, use } from 'chai'; -import * as chaiAsPromised from 'chai-as-promised'; +import chaiAsPromised from 'chai-as-promised'; import { FirebaseError } from '@firebase/util'; diff --git a/packages/auth/src/api/authentication/create_auth_uri.test.ts b/packages/auth/src/api/authentication/create_auth_uri.test.ts index b4cc9bc416f..3cb0bd29842 100644 --- a/packages/auth/src/api/authentication/create_auth_uri.test.ts +++ b/packages/auth/src/api/authentication/create_auth_uri.test.ts @@ -16,7 +16,7 @@ */ import { expect, use } from 'chai'; -import * as chaiAsPromised from 'chai-as-promised'; +import chaiAsPromised from 'chai-as-promised'; import { FirebaseError } from '@firebase/util'; diff --git a/packages/auth/src/api/authentication/custom_token.test.ts b/packages/auth/src/api/authentication/custom_token.test.ts index 7b0b21075cb..8716f0eaff2 100644 --- a/packages/auth/src/api/authentication/custom_token.test.ts +++ b/packages/auth/src/api/authentication/custom_token.test.ts @@ -16,7 +16,7 @@ */ import { expect, use } from 'chai'; -import * as chaiAsPromised from 'chai-as-promised'; +import chaiAsPromised from 'chai-as-promised'; import { ProviderId } from '../../model/enums'; import { FirebaseError } from '@firebase/util'; diff --git a/packages/auth/src/api/authentication/email_and_password.test.ts b/packages/auth/src/api/authentication/email_and_password.test.ts index 5506c89c5cd..f67982c1246 100644 --- a/packages/auth/src/api/authentication/email_and_password.test.ts +++ b/packages/auth/src/api/authentication/email_and_password.test.ts @@ -16,7 +16,7 @@ */ import { expect, use } from 'chai'; -import * as chaiAsPromised from 'chai-as-promised'; +import chaiAsPromised from 'chai-as-promised'; import { ActionCodeOperation } from '../../model/public_types'; import { FirebaseError } from '@firebase/util'; diff --git a/packages/auth/src/api/authentication/email_link.test.ts b/packages/auth/src/api/authentication/email_link.test.ts index da518187631..9d7b992e785 100644 --- a/packages/auth/src/api/authentication/email_link.test.ts +++ b/packages/auth/src/api/authentication/email_link.test.ts @@ -16,7 +16,7 @@ */ import { expect, use } from 'chai'; -import * as chaiAsPromised from 'chai-as-promised'; +import chaiAsPromised from 'chai-as-promised'; import { FirebaseError } from '@firebase/util'; diff --git a/packages/auth/src/api/authentication/idp.test.ts b/packages/auth/src/api/authentication/idp.test.ts index 02a05167ad3..59ddd13fb4f 100644 --- a/packages/auth/src/api/authentication/idp.test.ts +++ b/packages/auth/src/api/authentication/idp.test.ts @@ -16,7 +16,7 @@ */ import { expect, use } from 'chai'; -import * as chaiAsPromised from 'chai-as-promised'; +import chaiAsPromised from 'chai-as-promised'; import { FirebaseError } from '@firebase/util'; diff --git a/packages/auth/src/api/authentication/mfa.test.ts b/packages/auth/src/api/authentication/mfa.test.ts index d3ba40cc394..40c0d7e8821 100644 --- a/packages/auth/src/api/authentication/mfa.test.ts +++ b/packages/auth/src/api/authentication/mfa.test.ts @@ -16,7 +16,7 @@ */ import { expect, use } from 'chai'; -import * as chaiAsPromised from 'chai-as-promised'; +import chaiAsPromised from 'chai-as-promised'; import { FirebaseError } from '@firebase/util'; diff --git a/packages/auth/src/api/authentication/recaptcha.test.ts b/packages/auth/src/api/authentication/recaptcha.test.ts index 5e400701ccd..2f69d8ea821 100644 --- a/packages/auth/src/api/authentication/recaptcha.test.ts +++ b/packages/auth/src/api/authentication/recaptcha.test.ts @@ -16,7 +16,7 @@ */ import { expect, use } from 'chai'; -import * as chaiAsPromised from 'chai-as-promised'; +import chaiAsPromised from 'chai-as-promised'; import { FirebaseError } from '@firebase/util'; diff --git a/packages/auth/src/api/authentication/sign_up.test.ts b/packages/auth/src/api/authentication/sign_up.test.ts index dfd15127896..50a952de6ed 100644 --- a/packages/auth/src/api/authentication/sign_up.test.ts +++ b/packages/auth/src/api/authentication/sign_up.test.ts @@ -16,7 +16,7 @@ */ import { expect, use } from 'chai'; -import * as chaiAsPromised from 'chai-as-promised'; +import chaiAsPromised from 'chai-as-promised'; import { FirebaseError } from '@firebase/util'; diff --git a/packages/auth/src/api/authentication/sms.test.ts b/packages/auth/src/api/authentication/sms.test.ts index 4744520ff90..420797b1c97 100644 --- a/packages/auth/src/api/authentication/sms.test.ts +++ b/packages/auth/src/api/authentication/sms.test.ts @@ -16,7 +16,7 @@ */ import { expect, use } from 'chai'; -import * as chaiAsPromised from 'chai-as-promised'; +import chaiAsPromised from 'chai-as-promised'; import { ProviderId } from '../../model/enums'; import { FirebaseError } from '@firebase/util'; diff --git a/packages/auth/src/api/authentication/token.test.ts b/packages/auth/src/api/authentication/token.test.ts index af0ef19d762..529bfe3bd7c 100644 --- a/packages/auth/src/api/authentication/token.test.ts +++ b/packages/auth/src/api/authentication/token.test.ts @@ -16,7 +16,7 @@ */ import { expect, use } from 'chai'; -import * as chaiAsPromised from 'chai-as-promised'; +import chaiAsPromised from 'chai-as-promised'; import { FirebaseError, getUA, querystringDecode } from '@firebase/util'; diff --git a/packages/auth/src/api/index.test.ts b/packages/auth/src/api/index.test.ts index b1e89419403..fb864c87400 100644 --- a/packages/auth/src/api/index.test.ts +++ b/packages/auth/src/api/index.test.ts @@ -16,10 +16,10 @@ */ import { assert, expect, use } from 'chai'; -import * as chaiAsPromised from 'chai-as-promised'; +import chaiAsPromised from 'chai-as-promised'; import * as sinon from 'sinon'; import { useFakeTimers } from 'sinon'; -import * as sinonChai from 'sinon-chai'; +import sinonChai from 'sinon-chai'; import { FirebaseError, getUA } from '@firebase/util'; diff --git a/packages/auth/src/api/project_config/get_project_config.test.ts b/packages/auth/src/api/project_config/get_project_config.test.ts index 07210b875b4..a257d22dc1a 100644 --- a/packages/auth/src/api/project_config/get_project_config.test.ts +++ b/packages/auth/src/api/project_config/get_project_config.test.ts @@ -16,7 +16,7 @@ */ import { expect, use } from 'chai'; -import * as chaiAsPromised from 'chai-as-promised'; +import chaiAsPromised from 'chai-as-promised'; import { FirebaseError } from '@firebase/util'; diff --git a/packages/auth/src/core/auth/auth_event_manager.test.ts b/packages/auth/src/core/auth/auth_event_manager.test.ts index 6e6bfc0128a..f934f9b2c94 100644 --- a/packages/auth/src/core/auth/auth_event_manager.test.ts +++ b/packages/auth/src/core/auth/auth_event_manager.test.ts @@ -17,7 +17,7 @@ import { expect, use } from 'chai'; import * as sinon from 'sinon'; -import * as sinonChai from 'sinon-chai'; +import sinonChai from 'sinon-chai'; import { testAuth } from '../../../test/helpers/mock_auth'; import { diff --git a/packages/auth/src/core/auth/auth_impl.test.ts b/packages/auth/src/core/auth/auth_impl.test.ts index d8b8e088381..72a11b04944 100644 --- a/packages/auth/src/core/auth/auth_impl.test.ts +++ b/packages/auth/src/core/auth/auth_impl.test.ts @@ -16,9 +16,9 @@ */ import { expect, use } from 'chai'; -import * as chaiAsPromised from 'chai-as-promised'; +import chaiAsPromised from 'chai-as-promised'; import * as sinon from 'sinon'; -import * as sinonChai from 'sinon-chai'; +import sinonChai from 'sinon-chai'; import { FirebaseApp } from '@firebase/app'; import { FirebaseError } from '@firebase/util'; diff --git a/packages/auth/src/core/auth/emulator.test.ts b/packages/auth/src/core/auth/emulator.test.ts index 2d613fd8aef..8015aecee18 100644 --- a/packages/auth/src/core/auth/emulator.test.ts +++ b/packages/auth/src/core/auth/emulator.test.ts @@ -16,9 +16,9 @@ */ import { expect, use } from 'chai'; -import * as chaiAsPromised from 'chai-as-promised'; +import chaiAsPromised from 'chai-as-promised'; import * as sinon from 'sinon'; -import * as sinonChai from 'sinon-chai'; +import sinonChai from 'sinon-chai'; import { FirebaseError } from '@firebase/util'; diff --git a/packages/auth/src/core/auth/firebase_internal.test.ts b/packages/auth/src/core/auth/firebase_internal.test.ts index edf2e7fee3f..a2bb2e4c8af 100644 --- a/packages/auth/src/core/auth/firebase_internal.test.ts +++ b/packages/auth/src/core/auth/firebase_internal.test.ts @@ -18,7 +18,7 @@ import { FirebaseError } from '@firebase/util'; import { expect, use } from 'chai'; import * as sinon from 'sinon'; -import * as chaiAsPromised from 'chai-as-promised'; +import chaiAsPromised from 'chai-as-promised'; import { testAuth, testUser } from '../../../test/helpers/mock_auth'; import { AuthInternal } from '../../model/auth'; diff --git a/packages/auth/src/core/credentials/email.test.ts b/packages/auth/src/core/credentials/email.test.ts index ca4334b98e3..e70a49a2423 100644 --- a/packages/auth/src/core/credentials/email.test.ts +++ b/packages/auth/src/core/credentials/email.test.ts @@ -16,7 +16,7 @@ */ import { expect, use } from 'chai'; -import * as chaiAsPromised from 'chai-as-promised'; +import chaiAsPromised from 'chai-as-promised'; import { ProviderId, SignInMethod } from '../../model/enums'; diff --git a/packages/auth/src/core/persistence/persistence_user_manager.test.ts b/packages/auth/src/core/persistence/persistence_user_manager.test.ts index bff2ae7214c..4022ae493c0 100644 --- a/packages/auth/src/core/persistence/persistence_user_manager.test.ts +++ b/packages/auth/src/core/persistence/persistence_user_manager.test.ts @@ -18,7 +18,7 @@ import * as chai from 'chai'; import { expect } from 'chai'; import * as sinon from 'sinon'; -import * as sinonChai from 'sinon-chai'; +import sinonChai from 'sinon-chai'; import { testAuth, testUser, TestAuth } from '../../../test/helpers/mock_auth'; import { UserImpl } from '../user/user_impl'; diff --git a/packages/auth/src/core/providers/email.test.ts b/packages/auth/src/core/providers/email.test.ts index 5eea4529d46..378b1e93477 100644 --- a/packages/auth/src/core/providers/email.test.ts +++ b/packages/auth/src/core/providers/email.test.ts @@ -16,7 +16,7 @@ */ import { expect, use } from 'chai'; -import * as chaiAsPromised from 'chai-as-promised'; +import chaiAsPromised from 'chai-as-promised'; import { ProviderId, SignInMethod } from '../../model/enums'; // eslint-disable-next-line import/no-extraneous-dependencies diff --git a/packages/auth/src/core/strategies/abstract_popup_redirect_operation.test.ts b/packages/auth/src/core/strategies/abstract_popup_redirect_operation.test.ts index ba818c0b9dd..2e499c0d9e1 100644 --- a/packages/auth/src/core/strategies/abstract_popup_redirect_operation.test.ts +++ b/packages/auth/src/core/strategies/abstract_popup_redirect_operation.test.ts @@ -16,9 +16,9 @@ */ import { expect, use } from 'chai'; -import * as chaiAsPromised from 'chai-as-promised'; +import chaiAsPromised from 'chai-as-promised'; import * as sinon from 'sinon'; -import * as sinonChai from 'sinon-chai'; +import sinonChai from 'sinon-chai'; import { OperationType, ProviderId } from '../../model/enums'; import { FirebaseError } from '@firebase/util'; diff --git a/packages/auth/src/core/strategies/credential.test.ts b/packages/auth/src/core/strategies/credential.test.ts index 79dcbdcd234..3d2d31d5760 100644 --- a/packages/auth/src/core/strategies/credential.test.ts +++ b/packages/auth/src/core/strategies/credential.test.ts @@ -16,7 +16,7 @@ */ import { expect, use } from 'chai'; -import * as chaiAsPromised from 'chai-as-promised'; +import chaiAsPromised from 'chai-as-promised'; import { stub } from 'sinon'; import { diff --git a/packages/auth/src/core/strategies/custom_token.test.ts b/packages/auth/src/core/strategies/custom_token.test.ts index 5c046ec4d5c..e6f7aa4bca9 100644 --- a/packages/auth/src/core/strategies/custom_token.test.ts +++ b/packages/auth/src/core/strategies/custom_token.test.ts @@ -16,7 +16,7 @@ */ import { expect, use } from 'chai'; -import * as chaiAsPromised from 'chai-as-promised'; +import chaiAsPromised from 'chai-as-promised'; import { OperationType } from '../../model/enums'; diff --git a/packages/auth/src/core/strategies/email.test.ts b/packages/auth/src/core/strategies/email.test.ts index 2b44816303a..85493a89aef 100644 --- a/packages/auth/src/core/strategies/email.test.ts +++ b/packages/auth/src/core/strategies/email.test.ts @@ -16,9 +16,9 @@ */ import { expect, use } from 'chai'; -import * as chaiAsPromised from 'chai-as-promised'; +import chaiAsPromised from 'chai-as-promised'; import { restore, SinonStub, stub } from 'sinon'; -import * as sinonChai from 'sinon-chai'; +import sinonChai from 'sinon-chai'; import { ActionCodeOperation } from '../../model/public_types'; import { ProviderId } from '../../model/enums'; diff --git a/packages/auth/src/core/strategies/email_and_password.test.ts b/packages/auth/src/core/strategies/email_and_password.test.ts index ea46e545ffe..48756f1f487 100644 --- a/packages/auth/src/core/strategies/email_and_password.test.ts +++ b/packages/auth/src/core/strategies/email_and_password.test.ts @@ -16,8 +16,8 @@ */ import { expect, use } from 'chai'; -import * as chaiAsPromised from 'chai-as-promised'; -import * as sinonChai from 'sinon-chai'; +import chaiAsPromised from 'chai-as-promised'; +import sinonChai from 'sinon-chai'; import { ActionCodeOperation } from '../../model/public_types'; import { OperationType } from '../../model/enums'; diff --git a/packages/auth/src/core/strategies/email_link.test.ts b/packages/auth/src/core/strategies/email_link.test.ts index b2a282cc7da..afbbd833b1f 100644 --- a/packages/auth/src/core/strategies/email_link.test.ts +++ b/packages/auth/src/core/strategies/email_link.test.ts @@ -16,8 +16,8 @@ */ import { expect, use } from 'chai'; -import * as chaiAsPromised from 'chai-as-promised'; -import * as sinonChai from 'sinon-chai'; +import chaiAsPromised from 'chai-as-promised'; +import sinonChai from 'sinon-chai'; import { ActionCodeOperation } from '../../model/public_types'; import { OperationType } from '../../model/enums'; diff --git a/packages/auth/src/core/strategies/idp.test.ts b/packages/auth/src/core/strategies/idp.test.ts index 0fcef68c246..ab2fdddec8b 100644 --- a/packages/auth/src/core/strategies/idp.test.ts +++ b/packages/auth/src/core/strategies/idp.test.ts @@ -16,9 +16,9 @@ */ import * as sinon from 'sinon'; -import * as sinonChai from 'sinon-chai'; +import sinonChai from 'sinon-chai'; import { expect, use } from 'chai'; -import * as chaiAsPromised from 'chai-as-promised'; +import chaiAsPromised from 'chai-as-promised'; import { OperationType } from '../../model/enums'; diff --git a/packages/auth/src/core/strategies/redirect.test.ts b/packages/auth/src/core/strategies/redirect.test.ts index a579cfb5f19..d5a44074525 100644 --- a/packages/auth/src/core/strategies/redirect.test.ts +++ b/packages/auth/src/core/strategies/redirect.test.ts @@ -22,7 +22,7 @@ import { } from '../../model/public_types'; import { OperationType, ProviderId } from '../../model/enums'; import * as sinon from 'sinon'; -import * as sinonChai from 'sinon-chai'; +import sinonChai from 'sinon-chai'; import { _clearInstanceMap, _getInstance } from '../util/instantiator'; import { MockPersistenceLayer, diff --git a/packages/auth/src/core/user/account_info.test.ts b/packages/auth/src/core/user/account_info.test.ts index 05ac0856d1a..35e7d9bb623 100644 --- a/packages/auth/src/core/user/account_info.test.ts +++ b/packages/auth/src/core/user/account_info.test.ts @@ -16,9 +16,9 @@ */ import { expect, use } from 'chai'; -import * as chaiAsPromised from 'chai-as-promised'; +import chaiAsPromised from 'chai-as-promised'; import * as sinon from 'sinon'; -import * as sinonChai from 'sinon-chai'; +import sinonChai from 'sinon-chai'; import { UserInfo } from '../../model/public_types'; import { ProviderId } from '../../model/enums'; diff --git a/packages/auth/src/core/user/id_token_result.test.ts b/packages/auth/src/core/user/id_token_result.test.ts index 72bf829e04a..ee635e8053a 100644 --- a/packages/auth/src/core/user/id_token_result.test.ts +++ b/packages/auth/src/core/user/id_token_result.test.ts @@ -16,7 +16,7 @@ */ import { expect, use } from 'chai'; -import * as chaiAsPromised from 'chai-as-promised'; +import chaiAsPromised from 'chai-as-promised'; import * as sinon from 'sinon'; import { ProviderId } from '../../model/enums'; diff --git a/packages/auth/src/core/user/invalidation.test.ts b/packages/auth/src/core/user/invalidation.test.ts index 9d596bed448..5faa058c3a6 100644 --- a/packages/auth/src/core/user/invalidation.test.ts +++ b/packages/auth/src/core/user/invalidation.test.ts @@ -16,7 +16,7 @@ */ import { expect, use } from 'chai'; -import * as chaiAsPromised from 'chai-as-promised'; +import chaiAsPromised from 'chai-as-promised'; import { FirebaseError } from '@firebase/util'; diff --git a/packages/auth/src/core/user/link_unlink.test.ts b/packages/auth/src/core/user/link_unlink.test.ts index 59d66ae9ad4..1fc55a430cc 100644 --- a/packages/auth/src/core/user/link_unlink.test.ts +++ b/packages/auth/src/core/user/link_unlink.test.ts @@ -16,7 +16,7 @@ */ import { expect, use } from 'chai'; -import * as chaiAsPromised from 'chai-as-promised'; +import chaiAsPromised from 'chai-as-promised'; import { ProviderId } from '../../model/enums'; import { FirebaseError } from '@firebase/util'; diff --git a/packages/auth/src/core/user/proactive_refresh.test.ts b/packages/auth/src/core/user/proactive_refresh.test.ts index abdb0f9ca8c..7c0fee0194b 100644 --- a/packages/auth/src/core/user/proactive_refresh.test.ts +++ b/packages/auth/src/core/user/proactive_refresh.test.ts @@ -16,9 +16,9 @@ */ import { expect, use } from 'chai'; -import * as chaiAsPromised from 'chai-as-promised'; +import chaiAsPromised from 'chai-as-promised'; import * as sinon from 'sinon'; -import * as sinonChai from 'sinon-chai'; +import sinonChai from 'sinon-chai'; import { testAuth, testUser } from '../../../test/helpers/mock_auth'; import { UserInternal } from '../../model/user'; diff --git a/packages/auth/src/core/user/reauthenticate.test.ts b/packages/auth/src/core/user/reauthenticate.test.ts index 65782597324..190f2177bab 100644 --- a/packages/auth/src/core/user/reauthenticate.test.ts +++ b/packages/auth/src/core/user/reauthenticate.test.ts @@ -16,7 +16,7 @@ */ import { expect, use } from 'chai'; -import * as chaiAsPromised from 'chai-as-promised'; +import chaiAsPromised from 'chai-as-promised'; import { stub } from 'sinon'; import { diff --git a/packages/auth/src/core/user/reload.test.ts b/packages/auth/src/core/user/reload.test.ts index 29c9cd1ce8a..95a3bf61e42 100644 --- a/packages/auth/src/core/user/reload.test.ts +++ b/packages/auth/src/core/user/reload.test.ts @@ -16,9 +16,9 @@ */ import { expect, use } from 'chai'; -import * as chaiAsPromised from 'chai-as-promised'; +import chaiAsPromised from 'chai-as-promised'; import * as sinon from 'sinon'; -import * as sinonChai from 'sinon-chai'; +import sinonChai from 'sinon-chai'; import { UserInfo } from '../../model/public_types'; import { ProviderId } from '../../model/enums'; diff --git a/packages/auth/src/core/user/token_manager.test.ts b/packages/auth/src/core/user/token_manager.test.ts index 8a20c2a30b6..2baf992d0a7 100644 --- a/packages/auth/src/core/user/token_manager.test.ts +++ b/packages/auth/src/core/user/token_manager.test.ts @@ -16,7 +16,7 @@ */ import { expect, use } from 'chai'; -import * as chaiAsPromised from 'chai-as-promised'; +import chaiAsPromised from 'chai-as-promised'; import * as sinon from 'sinon'; import { FirebaseError } from '@firebase/util'; diff --git a/packages/auth/src/core/user/user_credential_impl.test.ts b/packages/auth/src/core/user/user_credential_impl.test.ts index bc609a39d28..02f97bf8b3f 100644 --- a/packages/auth/src/core/user/user_credential_impl.test.ts +++ b/packages/auth/src/core/user/user_credential_impl.test.ts @@ -16,9 +16,9 @@ */ import { expect, use } from 'chai'; -import * as chaiAsPromised from 'chai-as-promised'; +import chaiAsPromised from 'chai-as-promised'; import * as sinon from 'sinon'; -import * as sinonChai from 'sinon-chai'; +import sinonChai from 'sinon-chai'; import { OperationType, ProviderId } from '../../model/enums'; diff --git a/packages/auth/src/core/user/user_impl.test.ts b/packages/auth/src/core/user/user_impl.test.ts index 375f83d17d5..c39bd85210f 100644 --- a/packages/auth/src/core/user/user_impl.test.ts +++ b/packages/auth/src/core/user/user_impl.test.ts @@ -16,9 +16,9 @@ */ import { expect, use } from 'chai'; -import * as chaiAsPromised from 'chai-as-promised'; +import chaiAsPromised from 'chai-as-promised'; import * as sinon from 'sinon'; -import * as sinonChai from 'sinon-chai'; +import sinonChai from 'sinon-chai'; import { FirebaseError } from '@firebase/util'; diff --git a/packages/auth/src/core/util/validate_origin.test.ts b/packages/auth/src/core/util/validate_origin.test.ts index efc3795e1a6..8610ac0a56e 100644 --- a/packages/auth/src/core/util/validate_origin.test.ts +++ b/packages/auth/src/core/util/validate_origin.test.ts @@ -16,7 +16,7 @@ */ import { expect, use } from 'chai'; -import * as chaiAsPromised from 'chai-as-promised'; +import chaiAsPromised from 'chai-as-promised'; import * as sinon from 'sinon'; import { FirebaseError } from '@firebase/util'; diff --git a/packages/auth/src/mfa/mfa_info.test.ts b/packages/auth/src/mfa/mfa_info.test.ts index ba97f85cb05..91f0c6175e0 100644 --- a/packages/auth/src/mfa/mfa_info.test.ts +++ b/packages/auth/src/mfa/mfa_info.test.ts @@ -16,7 +16,7 @@ */ import { expect, use } from 'chai'; -import * as chaiAsPromised from 'chai-as-promised'; +import chaiAsPromised from 'chai-as-promised'; import { ProviderId } from '../model/enums'; import { FirebaseError } from '@firebase/util'; diff --git a/packages/auth/src/mfa/mfa_resolver.test.ts b/packages/auth/src/mfa/mfa_resolver.test.ts index 4479d1621d1..4c6e7139c78 100644 --- a/packages/auth/src/mfa/mfa_resolver.test.ts +++ b/packages/auth/src/mfa/mfa_resolver.test.ts @@ -16,7 +16,7 @@ */ import { expect, use } from 'chai'; -import * as chaiAsPromised from 'chai-as-promised'; +import chaiAsPromised from 'chai-as-promised'; import * as sinon from 'sinon'; import { FactorId } from '../model/public_types'; diff --git a/packages/auth/src/mfa/mfa_session.test.ts b/packages/auth/src/mfa/mfa_session.test.ts index ec603fd5f83..c0400a8a2b2 100644 --- a/packages/auth/src/mfa/mfa_session.test.ts +++ b/packages/auth/src/mfa/mfa_session.test.ts @@ -16,7 +16,7 @@ */ import { expect, use } from 'chai'; -import * as chaiAsPromised from 'chai-as-promised'; +import chaiAsPromised from 'chai-as-promised'; import { MultiFactorSessionImpl, MultiFactorSessionType } from './mfa_session'; use(chaiAsPromised); diff --git a/packages/auth/src/mfa/mfa_user.test.ts b/packages/auth/src/mfa/mfa_user.test.ts index f5fc504dc44..5bce1fa66c6 100644 --- a/packages/auth/src/mfa/mfa_user.test.ts +++ b/packages/auth/src/mfa/mfa_user.test.ts @@ -16,7 +16,7 @@ */ import { expect, use } from 'chai'; -import * as chaiAsPromised from 'chai-as-promised'; +import chaiAsPromised from 'chai-as-promised'; import * as sinon from 'sinon'; import { FactorId } from '../model/public_types'; diff --git a/packages/auth/src/platform_browser/auth.test.ts b/packages/auth/src/platform_browser/auth.test.ts index 3b33f357db2..129c00855f0 100644 --- a/packages/auth/src/platform_browser/auth.test.ts +++ b/packages/auth/src/platform_browser/auth.test.ts @@ -16,9 +16,9 @@ */ import { expect, use } from 'chai'; -import * as chaiAsPromised from 'chai-as-promised'; +import chaiAsPromised from 'chai-as-promised'; import * as sinon from 'sinon'; -import * as sinonChai from 'sinon-chai'; +import sinonChai from 'sinon-chai'; import { FirebaseApp } from '@firebase/app'; import { diff --git a/packages/auth/src/platform_browser/iframe/gapi.test.ts b/packages/auth/src/platform_browser/iframe/gapi.test.ts index af7dc30210d..f0cfefba7e2 100644 --- a/packages/auth/src/platform_browser/iframe/gapi.test.ts +++ b/packages/auth/src/platform_browser/iframe/gapi.test.ts @@ -16,9 +16,9 @@ */ import { expect, use } from 'chai'; -import * as chaiAsPromised from 'chai-as-promised'; +import chaiAsPromised from 'chai-as-promised'; import * as sinon from 'sinon'; -import * as sinonChai from 'sinon-chai'; +import sinonChai from 'sinon-chai'; import { FirebaseError } from '@firebase/util'; diff --git a/packages/auth/src/platform_browser/iframe/iframe.test.ts b/packages/auth/src/platform_browser/iframe/iframe.test.ts index de0207ab3e8..f1bf2cc54ed 100644 --- a/packages/auth/src/platform_browser/iframe/iframe.test.ts +++ b/packages/auth/src/platform_browser/iframe/iframe.test.ts @@ -16,9 +16,9 @@ */ import { expect, use } from 'chai'; -import * as chaiAsPromised from 'chai-as-promised'; +import chaiAsPromised from 'chai-as-promised'; import * as sinon from 'sinon'; -import * as sinonChai from 'sinon-chai'; +import sinonChai from 'sinon-chai'; import { SDK_VERSION } from '@firebase/app'; import { FirebaseError } from '@firebase/util'; diff --git a/packages/auth/src/platform_browser/load_js.test.ts b/packages/auth/src/platform_browser/load_js.test.ts index 9d0d0028169..df6e994f614 100644 --- a/packages/auth/src/platform_browser/load_js.test.ts +++ b/packages/auth/src/platform_browser/load_js.test.ts @@ -17,7 +17,7 @@ import { expect, use } from 'chai'; import * as sinon from 'sinon'; -import * as sinonChai from 'sinon-chai'; +import sinonChai from 'sinon-chai'; import { _generateCallbackName, _loadJS } from './load_js'; diff --git a/packages/auth/src/platform_browser/messagechannel/receiver.test.ts b/packages/auth/src/platform_browser/messagechannel/receiver.test.ts index 820b9223e26..2eb89c6bbe1 100644 --- a/packages/auth/src/platform_browser/messagechannel/receiver.test.ts +++ b/packages/auth/src/platform_browser/messagechannel/receiver.test.ts @@ -17,7 +17,7 @@ import { expect, use } from 'chai'; import * as sinon from 'sinon'; -import * as sinonChai from 'sinon-chai'; +import sinonChai from 'sinon-chai'; import { _EventType, PingRequest, diff --git a/packages/auth/src/platform_browser/messagechannel/sender.test.ts b/packages/auth/src/platform_browser/messagechannel/sender.test.ts index a2883265dba..23bbc71e0e1 100644 --- a/packages/auth/src/platform_browser/messagechannel/sender.test.ts +++ b/packages/auth/src/platform_browser/messagechannel/sender.test.ts @@ -16,9 +16,9 @@ */ import { expect, use } from 'chai'; -import * as chaiAsPromised from 'chai-as-promised'; +import chaiAsPromised from 'chai-as-promised'; import * as sinon from 'sinon'; -import * as sinonChai from 'sinon-chai'; +import sinonChai from 'sinon-chai'; import { _EventType, _MessageError, diff --git a/packages/auth/src/platform_browser/mfa/assertions/phone.test.ts b/packages/auth/src/platform_browser/mfa/assertions/phone.test.ts index 29724e5d2d7..116b9d2d9d5 100644 --- a/packages/auth/src/platform_browser/mfa/assertions/phone.test.ts +++ b/packages/auth/src/platform_browser/mfa/assertions/phone.test.ts @@ -17,7 +17,7 @@ import { ProviderId } from '../../../model/enums'; import { expect, use } from 'chai'; -import * as chaiAsPromised from 'chai-as-promised'; +import chaiAsPromised from 'chai-as-promised'; import { mockEndpoint } from '../../../../test/helpers/api/helper'; import { testAuth, TestAuth } from '../../../../test/helpers/mock_auth'; diff --git a/packages/auth/src/platform_browser/persistence/indexed_db.test.ts b/packages/auth/src/platform_browser/persistence/indexed_db.test.ts index 7bdc7f8cf68..bfc9fbb12f0 100644 --- a/packages/auth/src/platform_browser/persistence/indexed_db.test.ts +++ b/packages/auth/src/platform_browser/persistence/indexed_db.test.ts @@ -17,7 +17,7 @@ import { expect, use } from 'chai'; import * as sinon from 'sinon'; -import * as sinonChai from 'sinon-chai'; +import sinonChai from 'sinon-chai'; import { FakeServiceWorker } from '../../../test/helpers/fake_service_worker'; import { testAuth, testUser } from '../../../test/helpers/mock_auth'; import { PersistenceInternal, PersistenceType } from '../../core/persistence'; diff --git a/packages/auth/src/platform_browser/persistence/local_storage.test.ts b/packages/auth/src/platform_browser/persistence/local_storage.test.ts index dd5b713eded..1ccc1da9a6d 100644 --- a/packages/auth/src/platform_browser/persistence/local_storage.test.ts +++ b/packages/auth/src/platform_browser/persistence/local_storage.test.ts @@ -17,7 +17,7 @@ import { expect, use } from 'chai'; import * as sinon from 'sinon'; -import * as sinonChai from 'sinon-chai'; +import sinonChai from 'sinon-chai'; import { testAuth, testUser } from '../../../test/helpers/mock_auth'; import { PersistedBlob, diff --git a/packages/auth/src/platform_browser/popup_redirect.test.ts b/packages/auth/src/platform_browser/popup_redirect.test.ts index 6159bf24052..05c3b871a95 100644 --- a/packages/auth/src/platform_browser/popup_redirect.test.ts +++ b/packages/auth/src/platform_browser/popup_redirect.test.ts @@ -16,9 +16,9 @@ */ import { expect, use } from 'chai'; -import * as chaiAsPromised from 'chai-as-promised'; +import chaiAsPromised from 'chai-as-promised'; import * as sinon from 'sinon'; -import * as sinonChai from 'sinon-chai'; +import sinonChai from 'sinon-chai'; import { SDK_VERSION } from '@firebase/app'; import { Config } from '../model/public_types'; diff --git a/packages/auth/src/platform_browser/recaptcha/recaptcha_loader.test.ts b/packages/auth/src/platform_browser/recaptcha/recaptcha_loader.test.ts index b1323c55e63..5b56ff89b5a 100644 --- a/packages/auth/src/platform_browser/recaptcha/recaptcha_loader.test.ts +++ b/packages/auth/src/platform_browser/recaptcha/recaptcha_loader.test.ts @@ -16,9 +16,9 @@ */ import { expect, use } from 'chai'; -import * as chaiAsPromised from 'chai-as-promised'; +import chaiAsPromised from 'chai-as-promised'; import * as sinon from 'sinon'; -import * as sinonChai from 'sinon-chai'; +import sinonChai from 'sinon-chai'; import { FirebaseError } from '@firebase/util'; diff --git a/packages/auth/src/platform_browser/recaptcha/recaptcha_mock.test.ts b/packages/auth/src/platform_browser/recaptcha/recaptcha_mock.test.ts index 0dff03cac04..547bd9fd81f 100644 --- a/packages/auth/src/platform_browser/recaptcha/recaptcha_mock.test.ts +++ b/packages/auth/src/platform_browser/recaptcha/recaptcha_mock.test.ts @@ -16,9 +16,9 @@ */ import { expect, use } from 'chai'; -import * as chaiAsPromised from 'chai-as-promised'; +import chaiAsPromised from 'chai-as-promised'; import * as sinon from 'sinon'; -import * as sinonChai from 'sinon-chai'; +import sinonChai from 'sinon-chai'; import { FirebaseError } from '@firebase/util'; diff --git a/packages/auth/src/platform_browser/recaptcha/recaptcha_verifier.test.ts b/packages/auth/src/platform_browser/recaptcha/recaptcha_verifier.test.ts index 59e299b627d..9459cd2dfd4 100644 --- a/packages/auth/src/platform_browser/recaptcha/recaptcha_verifier.test.ts +++ b/packages/auth/src/platform_browser/recaptcha/recaptcha_verifier.test.ts @@ -16,9 +16,9 @@ */ import { expect, use } from 'chai'; -import * as chaiAsPromised from 'chai-as-promised'; +import chaiAsPromised from 'chai-as-promised'; import * as sinon from 'sinon'; -import * as sinonChai from 'sinon-chai'; +import sinonChai from 'sinon-chai'; import { FirebaseError } from '@firebase/util'; diff --git a/packages/auth/src/platform_browser/strategies/phone.test.ts b/packages/auth/src/platform_browser/strategies/phone.test.ts index 6281ff812b1..168c6398d21 100644 --- a/packages/auth/src/platform_browser/strategies/phone.test.ts +++ b/packages/auth/src/platform_browser/strategies/phone.test.ts @@ -16,9 +16,9 @@ */ import { expect, use } from 'chai'; -import * as chaiAsPromised from 'chai-as-promised'; +import chaiAsPromised from 'chai-as-promised'; import * as sinon from 'sinon'; -import * as sinonChai from 'sinon-chai'; +import sinonChai from 'sinon-chai'; import { OperationType, ProviderId } from '../../model/enums'; import { FirebaseError } from '@firebase/util'; diff --git a/packages/auth/src/platform_browser/strategies/popup.test.ts b/packages/auth/src/platform_browser/strategies/popup.test.ts index 23e67bf2dfa..76fee540842 100644 --- a/packages/auth/src/platform_browser/strategies/popup.test.ts +++ b/packages/auth/src/platform_browser/strategies/popup.test.ts @@ -16,9 +16,9 @@ */ import { expect, use } from 'chai'; -import * as chaiAsPromised from 'chai-as-promised'; +import chaiAsPromised from 'chai-as-promised'; import * as sinon from 'sinon'; -import * as sinonChai from 'sinon-chai'; +import sinonChai from 'sinon-chai'; import { PopupRedirectResolver } from '../../model/public_types'; import { OperationType, ProviderId } from '../../model/enums'; diff --git a/packages/auth/src/platform_browser/strategies/redirect.test.ts b/packages/auth/src/platform_browser/strategies/redirect.test.ts index aa02d6d982a..b87c93e9a98 100644 --- a/packages/auth/src/platform_browser/strategies/redirect.test.ts +++ b/packages/auth/src/platform_browser/strategies/redirect.test.ts @@ -16,9 +16,9 @@ */ import { expect, use } from 'chai'; -import * as chaiAsPromised from 'chai-as-promised'; +import chaiAsPromised from 'chai-as-promised'; import * as sinon from 'sinon'; -import * as sinonChai from 'sinon-chai'; +import sinonChai from 'sinon-chai'; import { AuthError, diff --git a/packages/auth/src/platform_browser/util/popup.test.ts b/packages/auth/src/platform_browser/util/popup.test.ts index 07a06de0b67..541d03b1dce 100644 --- a/packages/auth/src/platform_browser/util/popup.test.ts +++ b/packages/auth/src/platform_browser/util/popup.test.ts @@ -17,7 +17,7 @@ import { expect, use } from 'chai'; import * as sinon from 'sinon'; -import * as sinonChai from 'sinon-chai'; +import sinonChai from 'sinon-chai'; import { FirebaseError } from '@firebase/util'; import * as utils from '@firebase/util'; diff --git a/packages/auth/src/platform_cordova/popup_redirect/events.test.ts b/packages/auth/src/platform_cordova/popup_redirect/events.test.ts index f259d6d98ec..aca545eed3a 100644 --- a/packages/auth/src/platform_cordova/popup_redirect/events.test.ts +++ b/packages/auth/src/platform_cordova/popup_redirect/events.test.ts @@ -15,7 +15,7 @@ * limitations under the License. */ -import * as sinonChai from 'sinon-chai'; +import sinonChai from 'sinon-chai'; import * as sinon from 'sinon'; import { FirebaseError, querystring } from '@firebase/util'; import { expect, use } from 'chai'; diff --git a/packages/auth/src/platform_cordova/popup_redirect/popup_redirect.test.ts b/packages/auth/src/platform_cordova/popup_redirect/popup_redirect.test.ts index 9a867a07b9d..c09ae4c254c 100644 --- a/packages/auth/src/platform_cordova/popup_redirect/popup_redirect.test.ts +++ b/packages/auth/src/platform_cordova/popup_redirect/popup_redirect.test.ts @@ -17,8 +17,8 @@ import { AuthProvider } from '../../model/public_types'; import * as sinon from 'sinon'; -import * as chaiAsPromised from 'chai-as-promised'; -import * as sinonChai from 'sinon-chai'; +import chaiAsPromised from 'chai-as-promised'; +import sinonChai from 'sinon-chai'; import { expect, use } from 'chai'; import { testAuth, TestAuth } from '../../../test/helpers/mock_auth'; import { SingletonInstantiator } from '../../core/util/instantiator'; diff --git a/packages/auth/src/platform_cordova/popup_redirect/utils.test.ts b/packages/auth/src/platform_cordova/popup_redirect/utils.test.ts index 53430477960..f17c2a0d066 100644 --- a/packages/auth/src/platform_cordova/popup_redirect/utils.test.ts +++ b/packages/auth/src/platform_cordova/popup_redirect/utils.test.ts @@ -15,8 +15,8 @@ * limitations under the License. */ -import * as chaiAsPromised from 'chai-as-promised'; -import * as sinonChai from 'sinon-chai'; +import chaiAsPromised from 'chai-as-promised'; +import sinonChai from 'sinon-chai'; import * as sinon from 'sinon'; import { expect, use } from 'chai'; import { testAuth, TestAuth } from '../../../test/helpers/mock_auth'; diff --git a/packages/auth/test/integration/flows/anonymous.test.ts b/packages/auth/test/integration/flows/anonymous.test.ts index 1c744b251fc..3e085dbcd37 100644 --- a/packages/auth/test/integration/flows/anonymous.test.ts +++ b/packages/auth/test/integration/flows/anonymous.test.ts @@ -16,7 +16,7 @@ */ import { expect, use } from 'chai'; -import * as chaiAsPromised from 'chai-as-promised'; +import chaiAsPromised from 'chai-as-promised'; // eslint-disable-next-line import/no-extraneous-dependencies import { diff --git a/packages/auth/test/integration/flows/custom.local.test.ts b/packages/auth/test/integration/flows/custom.local.test.ts index 6ffbb18afc7..c9b1f0d1d42 100644 --- a/packages/auth/test/integration/flows/custom.local.test.ts +++ b/packages/auth/test/integration/flows/custom.local.test.ts @@ -33,7 +33,7 @@ import { } from '@firebase/auth'; import { FirebaseError } from '@firebase/util'; import { expect, use } from 'chai'; -import * as chaiAsPromised from 'chai-as-promised'; +import chaiAsPromised from 'chai-as-promised'; import { cleanUpTestInstance, getTestInstance, diff --git a/packages/auth/test/integration/flows/email.test.ts b/packages/auth/test/integration/flows/email.test.ts index bb73d95c383..12a27e84358 100644 --- a/packages/auth/test/integration/flows/email.test.ts +++ b/packages/auth/test/integration/flows/email.test.ts @@ -16,7 +16,7 @@ */ import { expect, use } from 'chai'; -import * as chaiAsPromised from 'chai-as-promised'; +import chaiAsPromised from 'chai-as-promised'; // eslint-disable-next-line import/no-extraneous-dependencies import { diff --git a/packages/auth/test/integration/flows/idp.local.test.ts b/packages/auth/test/integration/flows/idp.local.test.ts index 9262c84c17c..4e42ac9d405 100644 --- a/packages/auth/test/integration/flows/idp.local.test.ts +++ b/packages/auth/test/integration/flows/idp.local.test.ts @@ -35,7 +35,7 @@ import { } from '@firebase/auth'; import { FirebaseError } from '@firebase/util'; import { expect, use } from 'chai'; -import * as chaiAsPromised from 'chai-as-promised'; +import chaiAsPromised from 'chai-as-promised'; import { cleanUpTestInstance, getTestInstance, diff --git a/packages/auth/test/integration/flows/oob.local.test.ts b/packages/auth/test/integration/flows/oob.local.test.ts index e7fd54a0e8b..059313a4ce7 100644 --- a/packages/auth/test/integration/flows/oob.local.test.ts +++ b/packages/auth/test/integration/flows/oob.local.test.ts @@ -43,7 +43,7 @@ import { } from '@firebase/auth'; import { FirebaseError } from '@firebase/util'; import { expect, use } from 'chai'; -import * as chaiAsPromised from 'chai-as-promised'; +import chaiAsPromised from 'chai-as-promised'; import { getOobCodes, OobCodeSession diff --git a/packages/auth/test/integration/flows/phone.test.ts b/packages/auth/test/integration/flows/phone.test.ts index c938964f241..54ed016c81a 100644 --- a/packages/auth/test/integration/flows/phone.test.ts +++ b/packages/auth/test/integration/flows/phone.test.ts @@ -16,7 +16,7 @@ */ import { expect, use } from 'chai'; -import * as chaiAsPromised from 'chai-as-promised'; +import chaiAsPromised from 'chai-as-promised'; // eslint-disable-next-line import/no-extraneous-dependencies import { diff --git a/packages/auth/test/integration/webdriver/popup.test.ts b/packages/auth/test/integration/webdriver/popup.test.ts index 0ef1f0cb49d..e90823cb512 100644 --- a/packages/auth/test/integration/webdriver/popup.test.ts +++ b/packages/auth/test/integration/webdriver/popup.test.ts @@ -24,7 +24,7 @@ import { } from '@firebase/auth'; import { expect, use } from 'chai'; import { IdPPage } from './util/idp_page'; -import * as chaiAsPromised from 'chai-as-promised'; +import chaiAsPromised from 'chai-as-promised'; import { browserDescribe } from './util/test_runner'; import { AnonFunction, diff --git a/packages/auth/test/integration/webdriver/redirect.test.ts b/packages/auth/test/integration/webdriver/redirect.test.ts index bdbc965a06a..2bc17411637 100644 --- a/packages/auth/test/integration/webdriver/redirect.test.ts +++ b/packages/auth/test/integration/webdriver/redirect.test.ts @@ -24,7 +24,7 @@ import { } from '@firebase/auth'; import { expect, use } from 'chai'; import { IdPPage } from './util/idp_page'; -import * as chaiAsPromised from 'chai-as-promised'; +import chaiAsPromised from 'chai-as-promised'; import { browserDescribe } from './util/test_runner'; import { AnonFunction, diff --git a/packages/auth/test/integration/webdriver/util/test_server.ts b/packages/auth/test/integration/webdriver/util/test_server.ts index 77a66e0d961..c50dac81f6d 100644 --- a/packages/auth/test/integration/webdriver/util/test_server.ts +++ b/packages/auth/test/integration/webdriver/util/test_server.ts @@ -16,7 +16,7 @@ */ import * as path from 'path'; -import * as express from 'express'; +import express from 'express'; import { Server } from 'http'; const PORT_NUMBER = '4100'; diff --git a/packages/component/package.json b/packages/component/package.json index fca8587477f..7c274d17b84 100644 --- a/packages/component/package.json +++ b/packages/component/package.json @@ -4,9 +4,16 @@ "description": "Firebase Component Platform", "author": "Firebase (https://firebase.google.com/)", "main": "dist/index.cjs.js", - "browser": "dist/index.esm.js", - "module": "dist/index.esm.js", - "esm2017": "dist/index.esm2017.js", + "browser": "dist/esm/index.esm2017.js", + "module": "dist/esm/index.esm2017.js", + "esm5": "dist/esm/index.esm5.js", + "exports": { + ".": { + "require": "./dist/index.cjs.js", + "default": "./dist/esm/index.esm2017.js" + }, + "./package.json": "./package.json" + }, "files": [ "dist" ], @@ -47,4 +54,4 @@ ], "reportDir": "./coverage/node" } -} +} \ No newline at end of file diff --git a/packages/component/rollup.config.js b/packages/component/rollup.config.js index b97d6542ad8..f0cc1a84e98 100644 --- a/packages/component/rollup.config.js +++ b/packages/component/rollup.config.js @@ -17,39 +17,19 @@ import typescriptPlugin from 'rollup-plugin-typescript2'; import typescript from 'typescript'; +import { emitModulePackageFile } from '../../scripts/build/rollup_emit_module_package_file'; import pkg from './package.json'; const deps = Object.keys( Object.assign({}, pkg.peerDependencies, pkg.dependencies) ); -/** - * ES5 Builds - */ const es5BuildPlugins = [ typescriptPlugin({ typescript }) ]; -const es5Builds = [ - /** - * Browser Builds - */ - { - input: 'index.ts', - output: [ - { file: pkg.main, format: 'cjs', sourcemap: true }, - { file: pkg.module, format: 'es', sourcemap: true } - ], - plugins: es5BuildPlugins, - external: id => deps.some(dep => id === dep || id.startsWith(`${dep}/`)) - } -]; - -/** - * ES2017 Builds - */ const es2017BuildPlugins = [ typescriptPlugin({ typescript, @@ -61,20 +41,32 @@ const es2017BuildPlugins = [ }) ]; -const es2017Builds = [ - /** - * Browser Builds - */ +const esmBuilds = [ + { + input: 'index.ts', + output: { file: pkg.module, format: 'es', sourcemap: true }, + plugins: [...es2017BuildPlugins, emitModulePackageFile()], + external: id => deps.some(dep => id === dep || id.startsWith(`${dep}/`)) + }, { input: 'index.ts', output: { - file: pkg.esm2017, + file: pkg.esm5, format: 'es', sourcemap: true }, - plugins: es2017BuildPlugins, + plugins: [...es5BuildPlugins, emitModulePackageFile()], + external: id => deps.some(dep => id === dep || id.startsWith(`${dep}/`)) + } +]; + +const cjsBuilds = [ + { + input: 'index.ts', + output: { file: pkg.main, format: 'cjs', sourcemap: true }, + plugins: es5BuildPlugins, external: id => deps.some(dep => id === dep || id.startsWith(`${dep}/`)) } ]; -export default [...es5Builds, ...es2017Builds]; +export default [...esmBuilds, ...cjsBuilds]; diff --git a/packages/component/test/setup.ts b/packages/component/test/setup.ts index 6e2b3d195bb..76cac9a552c 100644 --- a/packages/component/test/setup.ts +++ b/packages/component/test/setup.ts @@ -16,9 +16,9 @@ */ import { use } from 'chai'; -import * as chaiAsPromised from 'chai-as-promised'; +import chaiAsPromised from 'chai-as-promised'; import { restore } from 'sinon'; -import * as sinonChai from 'sinon-chai'; +import sinonChai from 'sinon-chai'; use(chaiAsPromised); use(sinonChai); diff --git a/packages/database-compat/package.json b/packages/database-compat/package.json index 594f7507e14..f08c5ce6bd0 100644 --- a/packages/database-compat/package.json +++ b/packages/database-compat/package.json @@ -15,12 +15,16 @@ ], "exports": { ".": { - "node": "./dist/index.js", + "node": { + "import": "./dist/node-esm/index.js", + "require": "./dist/index.js" + }, "default": "./dist/index.esm2017.js" }, "./standalone": { "node": "./dist/index.standalone.js" - } + }, + "./package.json": "./package.json" }, "scripts": { "lint": "eslint -c .eslintrc.js '**/*.ts' --ignore-path '../../.gitignore'", diff --git a/packages/database-compat/rollup.config.js b/packages/database-compat/rollup.config.js index ac99b792e82..23abc254918 100644 --- a/packages/database-compat/rollup.config.js +++ b/packages/database-compat/rollup.config.js @@ -23,6 +23,7 @@ import resolveModule from '@rollup/plugin-node-resolve'; import pkg from './package.json'; import standalonePkg from './standalone/package.json'; +import { emitModulePackageFile } from '../../scripts/build/rollup_emit_module_package_file'; const deps = Object.keys({ ...pkg.peerDependencies, ...pkg.dependencies }); @@ -33,9 +34,6 @@ function onWarn(warning, defaultWarn) { defaultWarn(warning); } -/** - * ES5 Builds - */ const es5BuildPlugins = [ typescriptPlugin({ typescript, @@ -44,7 +42,20 @@ const es5BuildPlugins = [ json() ]; -const es5Builds = [ +const es2017BuildPlugins = [ + typescriptPlugin({ + typescript, + tsconfigOverride: { + compilerOptions: { + target: 'es2017' + } + }, + abortOnError: false + }), + json({ preferConst: true }) +]; + +const esmBuilds = [ /** * Node.js Build */ @@ -52,12 +63,12 @@ const es5Builds = [ input: 'src/index.node.ts', output: [ { - file: pkg.main, - format: 'cjs', + file: pkg.exports['.'].node.import, + format: 'es', sourcemap: true } ], - plugins: es5BuildPlugins, + plugins: [...es2017BuildPlugins, emitModulePackageFile()], treeshake: { moduleSideEffects: false }, @@ -83,6 +94,44 @@ const es5Builds = [ external: id => deps.some(dep => id === dep || id.startsWith(`${dep}/`)), onwarn: onWarn }, + { + input: 'src/index.ts', + output: [ + { + file: pkg.browser, + format: 'es', + sourcemap: true + } + ], + plugins: es2017BuildPlugins, + treeshake: { + moduleSideEffects: false + }, + external: id => deps.some(dep => id === dep || id.startsWith(`${dep}/`)), + onwarn: onWarn + } +]; + +const cjsBuilds = [ + /** + * Node.js Build + */ + { + input: 'src/index.node.ts', + output: [ + { + file: pkg.main, + format: 'cjs', + sourcemap: true + } + ], + plugins: es5BuildPlugins, + treeshake: { + moduleSideEffects: false + }, + external: id => deps.some(dep => id === dep || id.startsWith(`${dep}/`)), + onwarn: onWarn + }, /** * Standalone Build (used by Admin SDK). * @firebase/database and only @firebase/database is bundled in this build. @@ -115,42 +164,4 @@ const es5Builds = [ } ]; -/** - * ES2017 Builds - */ -const es2017BuildPlugins = [ - typescriptPlugin({ - typescript, - tsconfigOverride: { - compilerOptions: { - target: 'es2017' - } - }, - abortOnError: false - }), - json({ preferConst: true }) -]; - -const es2017Builds = [ - /** - * Browser Build - */ - { - input: 'src/index.ts', - output: [ - { - file: pkg.browser, - format: 'es', - sourcemap: true - } - ], - plugins: es2017BuildPlugins, - treeshake: { - moduleSideEffects: false - }, - external: id => deps.some(dep => id === dep || id.startsWith(`${dep}/`)), - onwarn: onWarn - } -]; - -export default [...es5Builds, ...es2017Builds]; +export default [...esmBuilds, ...cjsBuilds]; diff --git a/packages/database-compat/test/query.test.ts b/packages/database-compat/test/query.test.ts index 4a82c295b56..97faa37a427 100644 --- a/packages/database-compat/test/query.test.ts +++ b/packages/database-compat/test/query.test.ts @@ -16,7 +16,7 @@ */ import { expect, use } from 'chai'; -import * as chaiAsPromised from 'chai-as-promised'; +import chaiAsPromised from 'chai-as-promised'; import * as _ from 'lodash'; import { diff --git a/packages/database/package.json b/packages/database/package.json index 83fcfcb52d7..92b339ebe9c 100644 --- a/packages/database/package.json +++ b/packages/database/package.json @@ -8,6 +8,16 @@ "module": "dist/index.esm2017.js", "esm5": "dist/index.esm5.js", "standalone": "dist/index.standalone.js", + "exports": { + ".": { + "node": { + "import": "./dist/node-esm/index.node.esm.js", + "require": "./dist/index.node.cjs.js" + }, + "default": "./dist/index.esm2017.js" + }, + "./package.json": "./package.json" + }, "files": [ "dist" ], @@ -60,4 +70,4 @@ ], "reportDir": "./coverage/node" } -} +} \ No newline at end of file diff --git a/packages/database/rollup.config.js b/packages/database/rollup.config.js index 50dd9cc798d..d1ba71f14da 100644 --- a/packages/database/rollup.config.js +++ b/packages/database/rollup.config.js @@ -20,6 +20,7 @@ import typescriptPlugin from 'rollup-plugin-typescript2'; import replace from 'rollup-plugin-replace'; import typescript from 'typescript'; import { generateBuildTargetReplaceConfig } from '../../scripts/build/rollup_replace_build_target'; +import { emitModulePackageFile } from '../../scripts/build/rollup_emit_module_package_file'; import pkg from './package.json'; const deps = [ @@ -34,9 +35,6 @@ function onWarn(warning, defaultWarn) { defaultWarn(warning); } -/** - * ES5 Builds - */ const es5BuildPlugins = [ typescriptPlugin({ typescript, @@ -45,16 +43,32 @@ const es5BuildPlugins = [ json() ]; -const es5Builds = [ - /** - * Node.js Build - */ +const es2017BuildPlugins = [ + typescriptPlugin({ + typescript, + tsconfigOverride: { + compilerOptions: { + target: 'es2017' + } + }, + abortOnError: false + }), + json({ preferConst: true }) +]; + +const browserBuilds = [ { - input: 'src/index.node.ts', - output: [{ file: pkg.main, format: 'cjs', sourcemap: true }], + input: 'src/index.ts', + output: [ + { + file: pkg.esm5, + format: 'es', + sourcemap: true + } + ], plugins: [ ...es5BuildPlugins, - replace(generateBuildTargetReplaceConfig('cjs', 5)) + replace(generateBuildTargetReplaceConfig('esm', 5)) ], treeshake: { moduleSideEffects: false @@ -62,21 +76,34 @@ const es5Builds = [ external: id => deps.some(dep => id === dep || id.startsWith(`${dep}/`)), onwarn: onWarn }, - /** - * Browser Builds - */ { input: 'src/index.ts', output: [ { - file: pkg.esm5, + file: pkg.module, format: 'es', sourcemap: true } ], + plugins: [ + ...es2017BuildPlugins, + replace(generateBuildTargetReplaceConfig('esm', 2017)) + ], + treeshake: { + moduleSideEffects: false + }, + external: id => deps.some(dep => id === dep || id.startsWith(`${dep}/`)), + onwarn: onWarn + } +]; + +const nodeBuilds = [ + { + input: 'src/index.node.ts', + output: { file: pkg.main, format: 'cjs', sourcemap: true }, plugins: [ ...es5BuildPlugins, - replace(generateBuildTargetReplaceConfig('esm', 5)) + replace(generateBuildTargetReplaceConfig('cjs', 5)) ], treeshake: { moduleSideEffects: false @@ -84,54 +111,31 @@ const es5Builds = [ external: id => deps.some(dep => id === dep || id.startsWith(`${dep}/`)), onwarn: onWarn }, - /** - * Standalone Build - */ { - input: 'src/index.standalone.ts', - output: [{ file: pkg.standalone, format: 'cjs', sourcemap: true }], - plugins: es5BuildPlugins, + input: 'src/index.node.ts', + output: { + file: pkg.exports['.'].node.import, + format: 'es', + sourcemap: true + }, + plugins: [ + ...es2017BuildPlugins, + replace(generateBuildTargetReplaceConfig('esm', 2017)), + emitModulePackageFile() + ], treeshake: { moduleSideEffects: false }, external: id => deps.some(dep => id === dep || id.startsWith(`${dep}/`)), onwarn: onWarn - } -]; - -/** - * ES2017 Builds - */ -const es2017BuildPlugins = [ - typescriptPlugin({ - typescript, - tsconfigOverride: { - compilerOptions: { - target: 'es2017' - } - }, - abortOnError: false - }), - json({ preferConst: true }) -]; - -const es2017Builds = [ + }, /** - * Browser Build + * Standalone Build for Admin SDK */ { - input: 'src/index.ts', - output: [ - { - file: pkg.browser, - format: 'es', - sourcemap: true - } - ], - plugins: [ - ...es2017BuildPlugins, - replace(generateBuildTargetReplaceConfig('esm', 2017)) - ], + input: 'src/index.standalone.ts', + output: [{ file: pkg.standalone, format: 'cjs', sourcemap: true }], + plugins: es5BuildPlugins, treeshake: { moduleSideEffects: false }, @@ -140,4 +144,4 @@ const es2017Builds = [ } ]; -export default [...es5Builds, ...es2017Builds]; +export default [...browserBuilds, ...nodeBuilds]; diff --git a/packages/database/src/index.node.ts b/packages/database/src/index.node.ts index dee46010eaa..2f64ddd63dc 100644 --- a/packages/database/src/index.node.ts +++ b/packages/database/src/index.node.ts @@ -15,13 +15,18 @@ * limitations under the License. */ -import { Client } from 'faye-websocket'; +// Use default import to import a cjs library, so we can provide a esm entrypoint for Nodejs. +// We can't use named import here because otherwise you will get the following error: +// "SyntaxError: Named export 'Client' not found. The requested module 'faye-websocket' is a CommonJS module". +// We can change back to using named imports once the lib provides an esm build, however they are not planning to. +// see https://github.com/faye/faye-websocket-node/issues/82 +import Websocket from 'faye-websocket'; import { setWebSocketImpl } from '../src/realtime/WebSocketConnection'; import { registerDatabase } from './register'; -setWebSocketImpl(Client); +setWebSocketImpl(Websocket.Client); export * from './api'; diff --git a/packages/database/src/index.standalone.ts b/packages/database/src/index.standalone.ts index c056613c7d0..4b560df8c66 100644 --- a/packages/database/src/index.standalone.ts +++ b/packages/database/src/index.standalone.ts @@ -15,11 +15,11 @@ * limitations under the License. */ -import { Client } from 'faye-websocket'; +import Websocket from 'faye-websocket'; import { setWebSocketImpl } from './realtime/WebSocketConnection'; -setWebSocketImpl(Client); +setWebSocketImpl(Websocket.Client); // This entry point should only be consumed by Admin SDK export * from './api.standalone'; diff --git a/packages/firebase/package.json b/packages/firebase/package.json index 8f4dd7414a7..fef445f5c17 100644 --- a/packages/firebase/package.json +++ b/packages/firebase/package.json @@ -204,7 +204,8 @@ "import": "./compat/storage/dist/index.mjs" }, "default": "./compat/storage/dist/index.esm.js" - } + }, + "./package.json": "./package.json" }, "repository": { "type": "git", diff --git a/packages/firestore-compat/package.json b/packages/firestore-compat/package.json index cb8b00aa7d2..0091a6c99db 100644 --- a/packages/firestore-compat/package.json +++ b/packages/firestore-compat/package.json @@ -8,6 +8,17 @@ "browser": "dist/index.esm2017.js", "module": "dist/index.esm2017.js", "esm5": "dist/index.esm5.js", + "exports": { + ".": { + "node": { + "import": "./dist/node-esm/index.node.esm.js", + "require": "./dist/index.node.cjs.js" + }, + "react-native": "./dist/index.rn.js", + "default": "./dist/index.esm2017.js" + }, + "./package.json": "./package.json" + }, "files": [ "dist" ], diff --git a/packages/firestore-compat/rollup.config.js b/packages/firestore-compat/rollup.config.js index 8bc2442d8a3..ebf87c79e15 100644 --- a/packages/firestore-compat/rollup.config.js +++ b/packages/firestore-compat/rollup.config.js @@ -19,6 +19,7 @@ import pkg from './package.json'; import typescriptPlugin from 'rollup-plugin-typescript2'; import typescript from 'typescript'; import json from '@rollup/plugin-json'; +import { emitModulePackageFile } from '../../scripts/build/rollup_emit_module_package_file'; const util = require('../firestore/rollup.shared'); @@ -37,7 +38,7 @@ const es2017Plugins = [ json({ preferConst: true }) ]; -const es5Plugings = [ +const es5Plugins = [ typescriptPlugin({ typescript, transformers: [util.removeAssertTransformer] @@ -65,7 +66,7 @@ const browserBuilds = [ sourcemap: true } ], - plugins: es5Plugings, + plugins: es5Plugins, external: id => deps.some(dep => id === dep || id.startsWith(`${dep}/`)) } ]; @@ -80,6 +81,16 @@ const nodeBuilds = [ }, plugins: es2017Plugins, external: deps + }, + { + input: './src/index.node.ts', + output: { + file: pkg.exports['.'].node.import, + format: 'es', + sourcemap: true + }, + plugins: [...es2017Plugins, emitModulePackageFile()], + external: deps } ]; diff --git a/packages/firestore/package.json b/packages/firestore/package.json index d08a4ea9599..4159c9e19c4 100644 --- a/packages/firestore/package.json +++ b/packages/firestore/package.json @@ -53,6 +53,7 @@ "require": "./dist/index.node.cjs.js", "import": "./dist/index.node.mjs" }, + "react-native": "./dist/index.rn.js", "default": "./dist/index.esm2017.js" }, "./lite": { @@ -60,8 +61,10 @@ "require": "./dist/lite/index.node.cjs.js", "import": "./dist/lite/index.node.mjs" }, + "react-native": "./dist/lite/index.rn.esm2017.js", "default": "./dist/lite/index.browser.esm2017.js" - } + }, + "./package.json": "./package.json" }, "main": "dist/index.node.cjs.js", "main-esm": "dist/index.node.mjs", diff --git a/packages/firestore/rollup.shared.js b/packages/firestore/rollup.shared.js index 3f31e3061ed..e6044a9f22a 100644 --- a/packages/firestore/rollup.shared.js +++ b/packages/firestore/rollup.shared.js @@ -79,7 +79,7 @@ const browserDeps = [ '@firebase/app' ]; -const nodeDeps = [...browserDeps, 'util', 'path']; +const nodeDeps = [...browserDeps, 'util', 'path', 'url']; /** Resolves the external dependencies for the browser build. */ exports.resolveBrowserExterns = function (id) { diff --git a/packages/firestore/src/platform/node/load_protos.ts b/packages/firestore/src/platform/node/load_protos.ts index ef93dce8dd8..28b4fb393fc 100644 --- a/packages/firestore/src/platform/node/load_protos.ts +++ b/packages/firestore/src/platform/node/load_protos.ts @@ -15,7 +15,13 @@ * limitations under the License. */ -import { join, resolve, isAbsolute } from 'path'; +import { join, resolve, isAbsolute, dirname } from 'path'; +import { fileURLToPath } from 'url'; + +// __filename and __dirname globals are unavailable in ES modules +// @ts-ignore To avoid using `--module es2020` flag. +const __filename = fileURLToPath(import.meta.url); +const __dirname = dirname(__filename); import { loadPackageDefinition, GrpcObject } from '@grpc/grpc-js'; import { loadSync } from '@grpc/proto-loader'; diff --git a/packages/firestore/test/integration/api/database.test.ts b/packages/firestore/test/integration/api/database.test.ts index be5e529c70a..89a6a0883e7 100644 --- a/packages/firestore/test/integration/api/database.test.ts +++ b/packages/firestore/test/integration/api/database.test.ts @@ -18,7 +18,7 @@ import * as firestore from '@firebase/firestore-types'; import { Deferred } from '@firebase/util'; import { expect, use } from 'chai'; -import * as chaiAsPromised from 'chai-as-promised'; +import chaiAsPromised from 'chai-as-promised'; import { EventsAccumulator } from '../util/events_accumulator'; import * as firebaseExport from '../util/firebase_export'; diff --git a/packages/firestore/test/integration/api_internal/database.test.ts b/packages/firestore/test/integration/api_internal/database.test.ts index f719a1fd91b..457764845c6 100644 --- a/packages/firestore/test/integration/api_internal/database.test.ts +++ b/packages/firestore/test/integration/api_internal/database.test.ts @@ -16,7 +16,7 @@ */ import { expect, use } from 'chai'; -import * as chaiAsPromised from 'chai-as-promised'; +import chaiAsPromised from 'chai-as-promised'; import { User } from '../../../src/auth/user'; import { SimpleDb } from '../../../src/local/simple_db'; diff --git a/packages/firestore/test/lite/integration.test.ts b/packages/firestore/test/lite/integration.test.ts index 04dd47c99d6..0de8ede6f76 100644 --- a/packages/firestore/test/lite/integration.test.ts +++ b/packages/firestore/test/lite/integration.test.ts @@ -18,7 +18,7 @@ // eslint-disable-next-line import/no-extraneous-dependencies import { initializeApp } from '@firebase/app'; import { expect, use } from 'chai'; -import * as chaiAsPromised from 'chai-as-promised'; +import chaiAsPromised from 'chai-as-promised'; import { Bytes } from '../../src/lite-api/bytes'; import { diff --git a/packages/firestore/test/unit/local/indexeddb_persistence.test.ts b/packages/firestore/test/unit/local/indexeddb_persistence.test.ts index d0a69287819..69e3c8190ff 100644 --- a/packages/firestore/test/unit/local/indexeddb_persistence.test.ts +++ b/packages/firestore/test/unit/local/indexeddb_persistence.test.ts @@ -16,7 +16,7 @@ */ import { expect, use } from 'chai'; -import * as chaiAsPromised from 'chai-as-promised'; +import chaiAsPromised from 'chai-as-promised'; import { Context } from 'mocha'; import { queryToTarget } from '../../../src/core/query'; diff --git a/packages/firestore/test/unit/local/persistence_promise.test.ts b/packages/firestore/test/unit/local/persistence_promise.test.ts index 6eaf8e15398..fbec9b45291 100644 --- a/packages/firestore/test/unit/local/persistence_promise.test.ts +++ b/packages/firestore/test/unit/local/persistence_promise.test.ts @@ -16,7 +16,7 @@ */ import { expect, use } from 'chai'; -import * as chaiAsPromised from 'chai-as-promised'; +import chaiAsPromised from 'chai-as-promised'; import { PersistencePromise } from '../../../src/local/persistence_promise'; diff --git a/packages/firestore/test/unit/local/simple_db.test.ts b/packages/firestore/test/unit/local/simple_db.test.ts index 644281ea815..8a9f6076c68 100644 --- a/packages/firestore/test/unit/local/simple_db.test.ts +++ b/packages/firestore/test/unit/local/simple_db.test.ts @@ -16,7 +16,7 @@ */ import { expect, use } from 'chai'; -import * as chaiAsPromised from 'chai-as-promised'; +import chaiAsPromised from 'chai-as-promised'; import { Context } from 'mocha'; import { PersistencePromise } from '../../../src/local/persistence_promise'; diff --git a/packages/firestore/test/unit/remote/datastore.test.ts b/packages/firestore/test/unit/remote/datastore.test.ts index 45e0dbf8843..84f9df34086 100644 --- a/packages/firestore/test/unit/remote/datastore.test.ts +++ b/packages/firestore/test/unit/remote/datastore.test.ts @@ -16,7 +16,7 @@ */ import { expect, use } from 'chai'; -import * as chaiAsPromised from 'chai-as-promised'; +import chaiAsPromised from 'chai-as-promised'; import { EmptyCredentialsProvider, Token } from '../../../src/api/credentials'; import { DatabaseId } from '../../../src/core/database_info'; diff --git a/packages/firestore/test/unit/util/async_queue.test.ts b/packages/firestore/test/unit/util/async_queue.test.ts index b041f76a688..cbedb079fab 100644 --- a/packages/firestore/test/unit/util/async_queue.test.ts +++ b/packages/firestore/test/unit/util/async_queue.test.ts @@ -17,7 +17,7 @@ import { isSafari } from '@firebase/util'; import { expect, use } from 'chai'; -import * as chaiAsPromised from 'chai-as-promised'; +import chaiAsPromised from 'chai-as-promised'; import { IndexedDbTransactionError } from '../../../src/local/simple_db'; import { fail } from '../../../src/util/assert'; diff --git a/packages/firestore/test/unit/util/bundle.test.ts b/packages/firestore/test/unit/util/bundle.test.ts index 317088c8405..942d45f41f8 100644 --- a/packages/firestore/test/unit/util/bundle.test.ts +++ b/packages/firestore/test/unit/util/bundle.test.ts @@ -15,7 +15,7 @@ * limitations under the License. */ import { expect, use } from 'chai'; -import * as chaiAsPromised from 'chai-as-promised'; +import chaiAsPromised from 'chai-as-promised'; import { toByteStreamReader } from '../../../src/platform/byte_stream_reader'; import { newTextEncoder } from '../../../src/platform/serializer'; diff --git a/packages/functions-compat/package.json b/packages/functions-compat/package.json index 62971ed57d0..f507c35decc 100644 --- a/packages/functions-compat/package.json +++ b/packages/functions-compat/package.json @@ -6,6 +6,17 @@ "main": "dist/index.node.cjs.js", "browser": "dist/index.esm2017.js", "module": "dist/index.esm2017.js", + "esm5": "dist/index.esm5.js", + "exports": { + ".": { + "node": { + "import": "./dist/node-esm/index.node.esm.js", + "require": "./dist/index.node.cjs.js" + }, + "default": "./dist/index.esm2017.js" + }, + "./package.json": "./package.json" + }, "files": [ "dist" ], @@ -57,6 +68,5 @@ ".ts" ], "reportDir": "./coverage/node" - }, - "esm5": "dist/index.esm5.js" + } } \ No newline at end of file diff --git a/packages/functions-compat/rollup.config.js b/packages/functions-compat/rollup.config.js index cc01a87b357..74a738a1c92 100644 --- a/packages/functions-compat/rollup.config.js +++ b/packages/functions-compat/rollup.config.js @@ -19,44 +19,19 @@ import json from '@rollup/plugin-json'; import typescriptPlugin from 'rollup-plugin-typescript2'; import typescript from 'typescript'; import pkg from './package.json'; +import { emitModulePackageFile } from '../../scripts/build/rollup_emit_module_package_file'; const deps = Object.keys( Object.assign({}, pkg.peerDependencies, pkg.dependencies) ); -/** - * ES5 Builds - */ const es5BuildPlugins = [ typescriptPlugin({ typescript }), json() ]; -const es5Builds = [ - /** - * Browser Builds - */ - { - input: 'src/index.ts', - output: [{ file: pkg.esm5, format: 'es', sourcemap: true }], - plugins: es5BuildPlugins, - external: id => deps.some(dep => id === dep || id.startsWith(`${dep}/`)) - }, - /** - * Node.js Build - */ - { - input: 'src/index.node.ts', - output: [{ file: pkg.main, format: 'cjs', sourcemap: true }], - plugins: es5BuildPlugins, - external: id => deps.some(dep => id === dep || id.startsWith(`${dep}/`)) - } -]; -/** - * ES2017 Builds - */ const es2017BuildPlugins = [ typescriptPlugin({ typescript, @@ -68,11 +43,15 @@ const es2017BuildPlugins = [ }), json({ preferConst: true }) ]; -const es2017Builds = [ + +const browserBuilds = [ + { + input: 'src/index.ts', + output: { file: pkg.esm5, format: 'es', sourcemap: true }, + plugins: es5BuildPlugins, + external: id => deps.some(dep => id === dep || id.startsWith(`${dep}/`)) + }, { - /** - * Browser Build - */ input: 'src/index.ts', output: { file: pkg.browser, @@ -84,4 +63,21 @@ const es2017Builds = [ } ]; -export default [...es5Builds, ...es2017Builds]; +const nodeBuilds = [ + { + input: 'src/index.node.ts', + output: [{ file: pkg.main, format: 'cjs', sourcemap: true }], + plugins: es5BuildPlugins, + external: id => deps.some(dep => id === dep || id.startsWith(`${dep}/`)) + }, + { + input: 'src/index.node.ts', + output: [ + { file: pkg.exports['.'].node.import, format: 'es', sourcemap: true } + ], + plugins: [...es2017BuildPlugins, emitModulePackageFile()], + external: id => deps.some(dep => id === dep || id.startsWith(`${dep}/`)) + } +]; + +export default [...browserBuilds, ...nodeBuilds]; diff --git a/packages/functions-compat/src/service.test.ts b/packages/functions-compat/src/service.test.ts index 5a77e16b8e2..ad702f4fa39 100644 --- a/packages/functions-compat/src/service.test.ts +++ b/packages/functions-compat/src/service.test.ts @@ -20,7 +20,7 @@ import { FunctionsService } from './service'; import firebase, { FirebaseApp } from '@firebase/app-compat'; import * as functionsExp from '@firebase/functions'; import { stub, match, SinonStub } from 'sinon'; -import * as sinonChai from 'sinon-chai'; +import sinonChai from 'sinon-chai'; use(sinonChai); diff --git a/packages/functions/package.json b/packages/functions/package.json index eb0e3820cb4..b7dfce07060 100644 --- a/packages/functions/package.json +++ b/packages/functions/package.json @@ -6,6 +6,17 @@ "main": "dist/index.node.cjs.js", "browser": "dist/index.esm2017.js", "module": "dist/index.esm2017.js", + "esm5": "dist/index.esm.js", + "exports": { + ".": { + "node": { + "import": "./dist/esm-node/index.node.esm.js", + "require": "./dist/index.node.cjs.js" + }, + "default": "./dist/index.esm2017.js" + }, + "./package.json": "./package.json" + }, "files": [ "dist" ], @@ -62,6 +73,5 @@ ".ts" ], "reportDir": "./coverage/node" - }, - "esm5": "dist/index.esm.js" + } } \ No newline at end of file diff --git a/packages/functions/rollup.config.js b/packages/functions/rollup.config.js index 812fdee54c4..f535171ee9e 100644 --- a/packages/functions/rollup.config.js +++ b/packages/functions/rollup.config.js @@ -21,13 +21,12 @@ import replace from 'rollup-plugin-replace'; import typescript from 'typescript'; import pkg from './package.json'; import { generateBuildTargetReplaceConfig } from '../../scripts/build/rollup_replace_build_target'; +import { emitModulePackageFile } from '../../scripts/build/rollup_emit_module_package_file'; const deps = Object.keys( Object.assign({}, pkg.peerDependencies, pkg.dependencies) ); -/** - * ES5 Builds - */ + const es5BuildPlugins = [ typescriptPlugin({ typescript @@ -35,36 +34,6 @@ const es5BuildPlugins = [ json() ]; -const es5Builds = [ - /** - * Browser Builds - */ - { - input: 'src/index.ts', - output: [{ file: pkg.esm5, format: 'es', sourcemap: true }], - external: id => deps.some(dep => id === dep || id.startsWith(`${dep}/`)), - plugins: [ - ...es5BuildPlugins, - replace(generateBuildTargetReplaceConfig('esm', 5)) - ] - }, - /** - * Node.js Build - */ - { - input: 'src/index.node.ts', - output: [{ file: pkg.main, format: 'cjs', sourcemap: true }], - external: id => deps.some(dep => id === dep || id.startsWith(`${dep}/`)), - plugins: [ - ...es5BuildPlugins, - replace(generateBuildTargetReplaceConfig('cjs', 5)) - ] - } -]; - -/** - * ES2017 Builds - */ const es2017BuildPlugins = [ typescriptPlugin({ typescript, @@ -77,11 +46,17 @@ const es2017BuildPlugins = [ json({ preferConst: true }) ]; -const es2017Builds = [ +const browserBuilds = [ + { + input: 'src/index.ts', + output: [{ file: pkg.esm5, format: 'es', sourcemap: true }], + external: id => deps.some(dep => id === dep || id.startsWith(`${dep}/`)), + plugins: [ + ...es5BuildPlugins, + replace(generateBuildTargetReplaceConfig('esm', 5)) + ] + }, { - /** - * Browser Build - */ input: 'src/index.ts', output: { file: pkg.browser, @@ -96,4 +71,28 @@ const es2017Builds = [ } ]; -export default [...es5Builds, ...es2017Builds]; +const nodeBuilds = [ + { + input: 'src/index.node.ts', + output: [{ file: pkg.main, format: 'cjs', sourcemap: true }], + external: id => deps.some(dep => id === dep || id.startsWith(`${dep}/`)), + plugins: [ + ...es5BuildPlugins, + replace(generateBuildTargetReplaceConfig('cjs', 5)) + ] + }, + { + input: 'src/index.node.ts', + output: [ + { file: pkg.exports['.'].node.import, format: 'es', sourcemap: true } + ], + external: id => deps.some(dep => id === dep || id.startsWith(`${dep}/`)), + plugins: [ + ...es2017BuildPlugins, + replace(generateBuildTargetReplaceConfig('esm', 2017)), + emitModulePackageFile() + ] + } +]; + +export default [...browserBuilds, ...nodeBuilds]; diff --git a/packages/installations-compat/package.json b/packages/installations-compat/package.json index 08d5f742cc5..bc9b923512f 100644 --- a/packages/installations-compat/package.json +++ b/packages/installations-compat/package.json @@ -3,8 +3,16 @@ "version": "0.1.2", "author": "Firebase (https://firebase.google.com/)", "main": "dist/index.cjs.js", - "module": "dist/index.esm2017.js", - "browser": "dist/index.esm2017.js", + "module": "dist/esm/index.esm2017.js", + "browser": "dist/esm/index.esm2017.js", + "esm5": "dist/esm/index.esm.js", + "exports": { + ".": { + "require": "./dist/index.cjs.js", + "default": "./dist/esm/index.esm2017.js" + }, + "./package.json": "./package.json" + }, "typings": "dist/installations-compat.d.ts", "license": "Apache-2.0", "files": [ @@ -54,6 +62,5 @@ "@firebase/component": "0.5.7", "idb": "3.0.2", "tslib": "^2.1.0" - }, - "esm5": "dist/index.esm.js" + } } \ No newline at end of file diff --git a/packages/installations-compat/rollup.config.js b/packages/installations-compat/rollup.config.js index b8de29ff5b0..dff41008688 100644 --- a/packages/installations-compat/rollup.config.js +++ b/packages/installations-compat/rollup.config.js @@ -19,29 +19,11 @@ import json from '@rollup/plugin-json'; import typescriptPlugin from 'rollup-plugin-typescript2'; import typescript from 'typescript'; import pkg from './package.json'; +import { emitModulePackageFile } from '../../scripts/build/rollup_emit_module_package_file'; const deps = Object.keys({ ...pkg.peerDependencies, ...pkg.dependencies }); -/** - * ES5 Builds - */ const es5BuildPlugins = [typescriptPlugin({ typescript }), json()]; - -const es5Builds = [ - { - input: 'src/index.ts', - output: [ - { file: pkg.main, format: 'cjs', sourcemap: true }, - { file: pkg.esm5, format: 'es', sourcemap: true } - ], - external: id => deps.some(dep => id === dep || id.startsWith(`${dep}/`)), - plugins: es5BuildPlugins - } -]; - -/** - * ES2017 Builds - */ const es2017BuildPlugins = [ typescriptPlugin({ typescript, @@ -54,7 +36,13 @@ const es2017BuildPlugins = [ json({ preferConst: true }) ]; -const es2017Builds = [ +const esmBuilds = [ + { + input: 'src/index.ts', + output: { file: pkg.esm5, format: 'es', sourcemap: true }, + external: id => deps.some(dep => id === dep || id.startsWith(`${dep}/`)), + plugins: [...es5BuildPlugins, emitModulePackageFile()] + }, { input: 'src/index.ts', output: { @@ -63,8 +51,17 @@ const es2017Builds = [ sourcemap: true }, external: id => deps.some(dep => id === dep || id.startsWith(`${dep}/`)), - plugins: es2017BuildPlugins + plugins: [...es2017BuildPlugins, emitModulePackageFile()] + } +]; + +const cjsBuilds = [ + { + input: 'src/index.ts', + output: { file: pkg.main, format: 'cjs', sourcemap: true }, + external: id => deps.some(dep => id === dep || id.startsWith(`${dep}/`)), + plugins: es5BuildPlugins } ]; -export default [...es5Builds, ...es2017Builds]; +export default [...esmBuilds, ...cjsBuilds]; diff --git a/packages/installations-compat/src/testing/setup.ts b/packages/installations-compat/src/testing/setup.ts index 463089fa69b..5d220d5e8fa 100644 --- a/packages/installations-compat/src/testing/setup.ts +++ b/packages/installations-compat/src/testing/setup.ts @@ -17,7 +17,7 @@ import { use } from 'chai'; import { restore } from 'sinon'; -import * as sinonChai from 'sinon-chai'; +import sinonChai from 'sinon-chai'; use(sinonChai); diff --git a/packages/installations/package.json b/packages/installations/package.json index 3c55bac1d6d..2bde391c14b 100644 --- a/packages/installations/package.json +++ b/packages/installations/package.json @@ -3,8 +3,16 @@ "version": "0.5.2", "author": "Firebase (https://firebase.google.com/)", "main": "dist/index.cjs.js", - "module": "dist/index.esm2017.js", - "browser": "dist/index.esm2017.js", + "module": "dist/esm/index.esm2017.js", + "browser": "dist/esm/index.esm2017.js", + "esm5": "dist/esm/index.esm.js", + "exports": { + ".": { + "require": "./dist/index.cjs.js", + "default": "./dist/esm/index.esm2017.js" + }, + "./package.json": "./package.json" + }, "typings": "dist/src/index.d.ts", "license": "Apache-2.0", "files": [ @@ -57,6 +65,5 @@ "@firebase/component": "0.5.7", "idb": "3.0.2", "tslib": "^2.1.0" - }, - "esm5": "dist/index.esm.js" + } } \ No newline at end of file diff --git a/packages/installations/rollup.config.js b/packages/installations/rollup.config.js index b997c9b2f8a..70628504fdb 100644 --- a/packages/installations/rollup.config.js +++ b/packages/installations/rollup.config.js @@ -21,38 +21,12 @@ import replace from 'rollup-plugin-replace'; import typescript from 'typescript'; import pkg from './package.json'; import { generateBuildTargetReplaceConfig } from '../../scripts/build/rollup_replace_build_target'; +import { emitModulePackageFile } from '../../scripts/build/rollup_emit_module_package_file'; const deps = [...Object.keys({ ...pkg.peerDependencies, ...pkg.dependencies })]; -/** - * ES5 Builds - */ const es5BuildPlugins = [typescriptPlugin({ typescript }), json()]; -const es5Builds = [ - { - input: 'src/index.ts', - output: [{ file: pkg.main, format: 'cjs', sourcemap: true }], - external: id => deps.some(dep => id === dep || id.startsWith(`${dep}/`)), - plugins: [ - ...es5BuildPlugins, - replace(generateBuildTargetReplaceConfig('cjs', 5)) - ] - }, - { - input: 'src/index.ts', - output: [{ file: pkg.esm5, format: 'es', sourcemap: true }], - external: id => deps.some(dep => id === dep || id.startsWith(`${dep}/`)), - plugins: [ - ...es5BuildPlugins, - replace(generateBuildTargetReplaceConfig('esm', 5)) - ] - } -]; - -/** - * ES2017 Builds - */ const es2017BuildPlugins = [ typescriptPlugin({ typescript, @@ -65,7 +39,17 @@ const es2017BuildPlugins = [ json({ preferConst: true }) ]; -const es2017Builds = [ +const esmBuilds = [ + { + input: 'src/index.ts', + output: [{ file: pkg.esm5, format: 'es', sourcemap: true }], + external: id => deps.some(dep => id === dep || id.startsWith(`${dep}/`)), + plugins: [ + ...es5BuildPlugins, + replace(generateBuildTargetReplaceConfig('esm', 5)), + emitModulePackageFile() + ] + }, { input: 'src/index.ts', output: { @@ -76,9 +60,22 @@ const es2017Builds = [ external: id => deps.some(dep => id === dep || id.startsWith(`${dep}/`)), plugins: [ ...es2017BuildPlugins, - replace(generateBuildTargetReplaceConfig('esm', 2017)) + replace(generateBuildTargetReplaceConfig('esm', 2017)), + emitModulePackageFile() + ] + } +]; + +const cjsBuilds = [ + { + input: 'src/index.ts', + output: [{ file: pkg.main, format: 'cjs', sourcemap: true }], + external: id => deps.some(dep => id === dep || id.startsWith(`${dep}/`)), + plugins: [ + ...es5BuildPlugins, + replace(generateBuildTargetReplaceConfig('cjs', 5)) ] } ]; -export default [...es5Builds, ...es2017Builds]; +export default [...esmBuilds, ...cjsBuilds]; diff --git a/packages/installations/src/testing/setup.ts b/packages/installations/src/testing/setup.ts index 3db746533e0..4e8623a5e8b 100644 --- a/packages/installations/src/testing/setup.ts +++ b/packages/installations/src/testing/setup.ts @@ -16,9 +16,9 @@ */ import { use } from 'chai'; -import * as chaiAsPromised from 'chai-as-promised'; +import chaiAsPromised from 'chai-as-promised'; import { restore } from 'sinon'; -import * as sinonChai from 'sinon-chai'; +import sinonChai from 'sinon-chai'; import { clear } from '../helpers/idb-manager'; use(chaiAsPromised); diff --git a/packages/logger/package.json b/packages/logger/package.json index 0749488a070..141a8558383 100644 --- a/packages/logger/package.json +++ b/packages/logger/package.json @@ -4,8 +4,15 @@ "description": "A logger package for use in the Firebase JS SDK", "author": "Firebase (https://firebase.google.com/)", "main": "dist/index.cjs.js", - "module": "dist/index.esm2017.js", - "esm5": "dist/index.esm5.js", + "module": "dist/esm/index.esm2017.js", + "esm5": "dist/esm/index.esm5.js", + "exports": { + ".": { + "require": "./dist/index.cjs.js", + "default": "./dist/esm/index.esm2017.js" + }, + "./package.json": "./package.json" + }, "files": [ "dist" ], @@ -46,4 +53,4 @@ ], "reportDir": "./coverage/node" } -} +} \ No newline at end of file diff --git a/packages/logger/rollup.config.js b/packages/logger/rollup.config.js index cdc6e860118..e6bfbb4efe5 100644 --- a/packages/logger/rollup.config.js +++ b/packages/logger/rollup.config.js @@ -1,6 +1,6 @@ /** * @license - * Copyright 2018 Google Inc. + * Copyright 2018 Google LLC * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -18,35 +18,14 @@ import typescriptPlugin from 'rollup-plugin-typescript2'; import typescript from 'typescript'; import pkg from './package.json'; +import { emitModulePackageFile } from '../../scripts/build/rollup_emit_module_package_file'; -/** - * ES5 Builds - */ const es5BuildPlugins = [ typescriptPlugin({ typescript }) ]; -const deps = Object.keys( - Object.assign({}, pkg.peerDependencies, pkg.dependencies) -); - -const es5Builds = [ - { - input: 'index.ts', - output: [ - { file: pkg.main, format: 'cjs', sourcemap: true }, - { file: pkg.esm5, format: 'es', sourcemap: true } - ], - plugins: es5BuildPlugins, - external: id => deps.some(dep => id === dep || id.startsWith(`${dep}/`)) - } -]; - -/** - * ES2017 BuildS - */ const es2017BuildPlugins = [ typescriptPlugin({ typescript, @@ -58,7 +37,17 @@ const es2017BuildPlugins = [ }) ]; -const es2017Builds = [ +const deps = Object.keys( + Object.assign({}, pkg.peerDependencies, pkg.dependencies) +); + +const esmBuilds = [ + { + input: 'index.ts', + output: { file: pkg.esm5, format: 'es', sourcemap: true }, + plugins: [...es5BuildPlugins, emitModulePackageFile()], + external: id => deps.some(dep => id === dep || id.startsWith(`${dep}/`)) + }, { input: 'index.ts', output: { @@ -66,9 +55,18 @@ const es2017Builds = [ format: 'es', sourcemap: true }, - plugins: es2017BuildPlugins, + plugins: [...es2017BuildPlugins, emitModulePackageFile()], + external: id => deps.some(dep => id === dep || id.startsWith(`${dep}/`)) + } +]; + +const cjsBuilds = [ + { + input: 'index.ts', + output: { file: pkg.main, format: 'cjs', sourcemap: true }, + plugins: es5BuildPlugins, external: id => deps.some(dep => id === dep || id.startsWith(`${dep}/`)) } ]; -export default [...es5Builds, ...es2017Builds]; +export default [...esmBuilds, ...cjsBuilds]; diff --git a/packages/messaging-compat/package.json b/packages/messaging-compat/package.json index 22f3e798fa6..e1577b8ccad 100644 --- a/packages/messaging-compat/package.json +++ b/packages/messaging-compat/package.json @@ -5,10 +5,17 @@ "description": "", "author": "Firebase (https://firebase.google.com/)", "main": "dist/index.cjs.js", - "browser": "dist/index.esm2017.js", - "module": "dist/index.esm2017.js", + "browser": "dist/esm/index.esm2017.js", + "module": "dist/esm/index.esm2017.js", + "esm5": "dist/esm/index.esm.js", + "exports": { + ".": { + "require": "./dist/index.cjs.js", + "default": "./dist/esm/index.esm2017.js" + }, + "./package.json": "./package.json" + }, "typings": "dist/src/index.d.ts", - "sw": "dist/index.sw.esm2017.js", "files": [ "dist" ], @@ -49,6 +56,5 @@ }, "bugs": { "url": "https://github.com/firebase/firebase-js-sdk/issues" - }, - "esm5": "dist/index.esm.js" + } } \ No newline at end of file diff --git a/packages/messaging-compat/rollup.config.js b/packages/messaging-compat/rollup.config.js index e27be804d8f..2bc0cecded0 100644 --- a/packages/messaging-compat/rollup.config.js +++ b/packages/messaging-compat/rollup.config.js @@ -19,14 +19,12 @@ import json from '@rollup/plugin-json'; import pkg from './package.json'; import typescript from 'typescript'; import typescriptPlugin from 'rollup-plugin-typescript2'; +import { emitModulePackageFile } from '../../scripts/build/rollup_emit_module_package_file'; const deps = Object.keys( Object.assign({}, pkg.peerDependencies, pkg.dependencies) ); -/** - * ES5 Builds - */ const es5BuildPlugins = [ typescriptPlugin({ typescript @@ -34,21 +32,6 @@ const es5BuildPlugins = [ json() ]; -const es5Builds = [ - { - input: 'src/index.ts', - output: [ - { file: pkg.main, format: 'cjs', sourcemap: true }, - { file: pkg.esm5, format: 'es', sourcemap: true } - ], - plugins: es5BuildPlugins, - external: id => deps.some(dep => id === dep || id.startsWith(`${dep}/`)) - } -]; - -/** - * ES2017 Builds - */ const es2017BuildPlugins = [ typescriptPlugin({ typescript, @@ -61,7 +44,13 @@ const es2017BuildPlugins = [ json({ preferConst: true }) ]; -const es2017Builds = [ +const esmBuilds = [ + { + input: 'src/index.ts', + output: { file: pkg.esm5, format: 'es', sourcemap: true }, + plugins: [...es5BuildPlugins, emitModulePackageFile()], + external: id => deps.some(dep => id === dep || id.startsWith(`${dep}/`)) + }, { input: 'src/index.ts', output: { @@ -69,9 +58,18 @@ const es2017Builds = [ format: 'es', sourcemap: true }, - plugins: es2017BuildPlugins, + plugins: [...es2017BuildPlugins, emitModulePackageFile()], + external: id => deps.some(dep => id === dep || id.startsWith(`${dep}/`)) + } +]; + +const cjsBuilds = [ + { + input: 'src/index.ts', + output: { file: pkg.main, format: 'cjs', sourcemap: true }, + plugins: es5BuildPlugins, external: id => deps.some(dep => id === dep || id.startsWith(`${dep}/`)) } ]; -export default [...es5Builds, ...es2017Builds]; +export default [...esmBuilds, ...cjsBuilds]; diff --git a/packages/messaging/package.json b/packages/messaging/package.json index 9e9e9e601e4..738cfed41b5 100644 --- a/packages/messaging/package.json +++ b/packages/messaging/package.json @@ -4,10 +4,20 @@ "description": "", "author": "Firebase (https://firebase.google.com/)", "main": "dist/index.cjs.js", - "browser": "dist/index.esm2017.js", - "module": "dist/index.esm2017.js", - "typings": "dist/src/index.d.ts", + "browser": "dist/esm/index.esm2017.js", + "module": "dist/esm/index.esm2017.js", "sw": "dist/index.sw.esm2017.js", + "esm5": "dist/esm/index.esm.js", + "exports": { + ".": { + "browser": "./dist/esm/index.esm2017.js", + "module": "./dist/esm/index.esm2017.js", + "default": "./dist/index.cjs.js" + }, + "./sw": "./dist/index.sw.esm2017.js", + "./package.json": "./package.json" + }, + "typings": "dist/src/index.d.ts", "files": [ "dist", "sw/package.json" @@ -58,6 +68,5 @@ }, "bugs": { "url": "https://github.com/firebase/firebase-js-sdk/issues" - }, - "esm5": "dist/index.esm.js" + } } diff --git a/packages/messaging/rollup.config.js b/packages/messaging/rollup.config.js index 034bf5e561d..5f2aaafd5fd 100644 --- a/packages/messaging/rollup.config.js +++ b/packages/messaging/rollup.config.js @@ -21,14 +21,12 @@ import typescript from 'typescript'; import replace from 'rollup-plugin-replace'; import typescriptPlugin from 'rollup-plugin-typescript2'; import { generateBuildTargetReplaceConfig } from '../../scripts/build/rollup_replace_build_target'; +import { emitModulePackageFile } from '../../scripts/build/rollup_emit_module_package_file'; const deps = Object.keys( Object.assign({}, pkg.peerDependencies, pkg.dependencies) ); -/** - * ES5 Builds - */ const es5BuildPlugins = [ typescriptPlugin({ typescript @@ -36,30 +34,6 @@ const es5BuildPlugins = [ json() ]; -const es5Builds = [ - { - input: 'src/index.ts', - output: [{ file: pkg.main, format: 'cjs', sourcemap: true }], - plugins: [ - ...es5BuildPlugins, - replace(generateBuildTargetReplaceConfig('cjs', 5)) - ], - external: id => deps.some(dep => id === dep || id.startsWith(`${dep}/`)) - }, - { - input: 'src/index.ts', - output: [{ file: pkg.esm5, format: 'es', sourcemap: true }], - plugins: [ - ...es5BuildPlugins, - replace(generateBuildTargetReplaceConfig('esm', 5)) - ], - external: id => deps.some(dep => id === dep || id.startsWith(`${dep}/`)) - } -]; - -/** - * ES2017 Builds - */ const es2017BuildPlugins = [ typescriptPlugin({ typescript, @@ -72,7 +46,17 @@ const es2017BuildPlugins = [ json({ preferConst: true }) ]; -const es2017Builds = [ +const esmBuilds = [ + { + input: 'src/index.ts', + output: { file: pkg.esm5, format: 'es', sourcemap: true }, + plugins: [ + ...es5BuildPlugins, + replace(generateBuildTargetReplaceConfig('esm', 5)), + emitModulePackageFile() + ], + external: id => deps.some(dep => id === dep || id.startsWith(`${dep}/`)) + }, { input: 'src/index.ts', output: { @@ -82,7 +66,8 @@ const es2017Builds = [ }, plugins: [ ...es2017BuildPlugins, - replace(generateBuildTargetReplaceConfig('esm', 2017)) + replace(generateBuildTargetReplaceConfig('esm', 2017)), + emitModulePackageFile() ], external: id => deps.some(dep => id === dep || id.startsWith(`${dep}/`)) }, @@ -95,4 +80,16 @@ const es2017Builds = [ } ]; -export default [...es5Builds, ...es2017Builds]; +const cjsBuilds = [ + { + input: 'src/index.ts', + output: [{ file: pkg.main, format: 'cjs', sourcemap: true }], + plugins: [ + ...es5BuildPlugins, + replace(generateBuildTargetReplaceConfig('cjs', 5)) + ], + external: id => deps.some(dep => id === dep || id.startsWith(`${dep}/`)) + } +]; + +export default [...esmBuilds, ...cjsBuilds]; diff --git a/packages/messaging/src/helpers/logToFirelog.test.ts b/packages/messaging/src/helpers/logToFirelog.test.ts index 133c1b3e8e8..04e201bfc3a 100644 --- a/packages/messaging/src/helpers/logToFirelog.test.ts +++ b/packages/messaging/src/helpers/logToFirelog.test.ts @@ -16,8 +16,8 @@ */ import * as LogModule from './logToFirelog'; -import * as chaiAsPromised from 'chai-as-promised'; -import * as sinonChai from 'sinon-chai'; +import chaiAsPromised from 'chai-as-promised'; +import sinonChai from 'sinon-chai'; import { expect, use } from 'chai'; import { diff --git a/packages/messaging/src/testing/setup.ts b/packages/messaging/src/testing/setup.ts index 61b3524ca74..eb4802a11a1 100644 --- a/packages/messaging/src/testing/setup.ts +++ b/packages/messaging/src/testing/setup.ts @@ -15,8 +15,8 @@ * limitations under the License. */ -import * as chaiAsPromised from 'chai-as-promised'; -import * as sinonChai from 'sinon-chai'; +import chaiAsPromised from 'chai-as-promised'; +import sinonChai from 'sinon-chai'; import { dbDelete } from '../internals/idb-manager'; import { deleteDb } from 'idb'; diff --git a/packages/performance-compat/package.json b/packages/performance-compat/package.json index f7a4e2270f1..f72d56fbcd6 100644 --- a/packages/performance-compat/package.json +++ b/packages/performance-compat/package.json @@ -4,8 +4,16 @@ "description": "The compatibility package of Firebase Performance", "author": "Firebase (https://firebase.google.com/)", "main": "dist/index.cjs.js", - "browser": "dist/index.esm2017.js", - "module": "dist/index.esm2017.js", + "browser": "dist/esm/index.esm2017.js", + "module": "dist/esm/index.esm2017.js", + "esm5": "dist/esm/index.esm5.js", + "exports": { + ".": { + "require": "./dist/index.cjs.js", + "default": "./dist/esm/index.esm2017.js" + }, + "./package.json": "./package.json" + }, "files": [ "dist" ], @@ -58,6 +66,5 @@ ".ts" ], "reportDir": "./coverage/node" - }, - "esm5": "dist/index.esm5.js" + } } \ No newline at end of file diff --git a/packages/performance-compat/rollup.config.js b/packages/performance-compat/rollup.config.js index 89b679548f7..d64b7bb89e5 100644 --- a/packages/performance-compat/rollup.config.js +++ b/packages/performance-compat/rollup.config.js @@ -19,13 +19,12 @@ import typescriptPlugin from 'rollup-plugin-typescript2'; import typescript from 'typescript'; import json from '@rollup/plugin-json'; import pkg from './package.json'; +import { emitModulePackageFile } from '../../scripts/build/rollup_emit_module_package_file'; const deps = Object.keys( Object.assign({}, pkg.peerDependencies, pkg.dependencies) ); -/** - * ES5 Builds - */ + const es5BuildPlugins = [ typescriptPlugin({ typescript @@ -33,24 +32,6 @@ const es5BuildPlugins = [ json() ]; -const es5Builds = [ - /** - * Browser Builds - */ - { - input: 'src/index.ts', - output: [ - { file: pkg.main, format: 'cjs', sourcemap: true }, - { file: pkg.esm5, format: 'es', sourcemap: true } - ], - external: id => deps.some(dep => id === dep || id.startsWith(`${dep}/`)), - plugins: es5BuildPlugins - } -]; - -/** - * ES2017 Builds - */ const es2017BuildPlugins = [ typescriptPlugin({ typescript, @@ -65,10 +46,13 @@ const es2017BuildPlugins = [ }) ]; -const es2017Builds = [ - /** - * Browser Builds - */ +const esmBuilds = [ + { + input: 'src/index.ts', + output: { file: pkg.esm5, format: 'es', sourcemap: true }, + external: id => deps.some(dep => id === dep || id.startsWith(`${dep}/`)), + plugins: [...es5BuildPlugins, emitModulePackageFile()] + }, { input: 'src/index.ts', output: { @@ -77,8 +61,17 @@ const es2017Builds = [ sourcemap: true }, external: id => deps.some(dep => id === dep || id.startsWith(`${dep}/`)), - plugins: es2017BuildPlugins + plugins: [...es2017BuildPlugins, emitModulePackageFile()] + } +]; + +const cjsBuilds = [ + { + input: 'src/index.ts', + output: { file: pkg.main, format: 'cjs', sourcemap: true }, + external: id => deps.some(dep => id === dep || id.startsWith(`${dep}/`)), + plugins: es5BuildPlugins } ]; -export default [...es5Builds, ...es2017Builds]; +export default [...esmBuilds, ...cjsBuilds]; diff --git a/packages/performance-compat/test/setup.ts b/packages/performance-compat/test/setup.ts index b1e3136529f..899b4867c1a 100644 --- a/packages/performance-compat/test/setup.ts +++ b/packages/performance-compat/test/setup.ts @@ -17,7 +17,7 @@ import { use } from 'chai'; import { restore } from 'sinon'; -import * as sinonChai from 'sinon-chai'; +import sinonChai from 'sinon-chai'; use(sinonChai); diff --git a/packages/performance/package.json b/packages/performance/package.json index ac24fe1b9d9..b9b5ad7f209 100644 --- a/packages/performance/package.json +++ b/packages/performance/package.json @@ -4,8 +4,16 @@ "description": "Firebase performance for web", "author": "Firebase (https://firebase.google.com/)", "main": "dist/index.cjs.js", - "browser": "dist/index.esm2017.js", - "module": "dist/index.esm2017.js", + "browser": "dist/esm/index.esm2017.js", + "module": "dist/esm/index.esm2017.js", + "esm5": "dist/esm/index.esm.js", + "exports": { + ".": { + "require": "./dist/index.cjs.js", + "default": "./dist/esm/index.esm2017.js" + }, + "./package.json": "./package.json" + }, "files": [ "dist" ], @@ -57,6 +65,5 @@ ".ts" ], "reportDir": "./coverage/node" - }, - "esm5": "dist/index.esm.js" + } } \ No newline at end of file diff --git a/packages/performance/rollup.config.js b/packages/performance/rollup.config.js index 8ff88dd1090..4816210933d 100644 --- a/packages/performance/rollup.config.js +++ b/packages/performance/rollup.config.js @@ -20,62 +20,59 @@ import typescriptPlugin from 'rollup-plugin-typescript2'; import replace from 'rollup-plugin-replace'; import typescript from 'typescript'; import { generateBuildTargetReplaceConfig } from '../../scripts/build/rollup_replace_build_target'; +import { emitModulePackageFile } from '../../scripts/build/rollup_emit_module_package_file'; import pkg from './package.json'; const deps = Object.keys( Object.assign({}, pkg.peerDependencies, pkg.dependencies) ); -/** - * ES5 Builds - */ + const es5BuildPlugins = [typescriptPlugin({ typescript }), json()]; +const es2017BuildPlugins = [ + typescriptPlugin({ + typescript, + tsconfigOverride: { + compilerOptions: { + target: 'es2017' + } + } + }), + json({ preferConst: true }) +]; -const es5Builds = [ +const esmBuilds = [ { input: 'src/index.ts', - output: [{ file: pkg.main, format: 'cjs', sourcemap: true }], + output: [{ file: pkg.esm5, format: 'es', sourcemap: true }], external: id => deps.some(dep => id === dep || id.startsWith(`${dep}/`)), plugins: [ ...es5BuildPlugins, - replace(generateBuildTargetReplaceConfig('cjs', 5)) + replace(generateBuildTargetReplaceConfig('esm', 5)), + emitModulePackageFile() ] }, { input: 'src/index.ts', - output: [{ file: pkg.esm5, format: 'es', sourcemap: true }], + output: [{ file: pkg.browser, format: 'es', sourcemap: true }], external: id => deps.some(dep => id === dep || id.startsWith(`${dep}/`)), plugins: [ - ...es5BuildPlugins, - replace(generateBuildTargetReplaceConfig('esm', 5)) + ...es2017BuildPlugins, + replace(generateBuildTargetReplaceConfig('esm', 2017)), + emitModulePackageFile() ] } ]; -/** - * ES2017 Builds - */ -const es2017BuildPlugins = [ - typescriptPlugin({ - typescript, - tsconfigOverride: { - compilerOptions: { - target: 'es2017' - } - } - }), - json({ preferConst: true }) -]; - -const es2017Builds = [ +const cjsBuilds = [ { input: 'src/index.ts', - output: [{ file: pkg.browser, format: 'es', sourcemap: true }], + output: [{ file: pkg.main, format: 'cjs', sourcemap: true }], external: id => deps.some(dep => id === dep || id.startsWith(`${dep}/`)), plugins: [ - ...es2017BuildPlugins, - replace(generateBuildTargetReplaceConfig('esm', 2017)) + ...es5BuildPlugins, + replace(generateBuildTargetReplaceConfig('cjs', 5)) ] } ]; -export default [...es5Builds, ...es2017Builds]; +export default [...esmBuilds, ...cjsBuilds]; diff --git a/packages/performance/src/services/transport_service.test.ts b/packages/performance/src/services/transport_service.test.ts index 43986e00817..b4f49db44e0 100644 --- a/packages/performance/src/services/transport_service.test.ts +++ b/packages/performance/src/services/transport_service.test.ts @@ -17,7 +17,7 @@ import { stub, useFakeTimers, SinonStub, SinonFakeTimers, match } from 'sinon'; import { use, expect } from 'chai'; -import * as sinonChai from 'sinon-chai'; +import sinonChai from 'sinon-chai'; import { transportHandler, setupTransportService, diff --git a/packages/performance/test/setup.ts b/packages/performance/test/setup.ts index 11f8e4cec16..ddc96a1edfd 100644 --- a/packages/performance/test/setup.ts +++ b/packages/performance/test/setup.ts @@ -17,8 +17,8 @@ import { restore } from 'sinon'; import { use } from 'chai'; -import * as chaiAsPromised from 'chai-as-promised'; -import * as sinonChai from 'sinon-chai'; +import chaiAsPromised from 'chai-as-promised'; +import sinonChai from 'sinon-chai'; use(chaiAsPromised); use(sinonChai); diff --git a/packages/remote-config-compat/package.json b/packages/remote-config-compat/package.json index 6c9ed5a185d..aa11dee5b85 100644 --- a/packages/remote-config-compat/package.json +++ b/packages/remote-config-compat/package.json @@ -4,8 +4,16 @@ "description": "The compatibility package of Remote Config", "author": "Firebase (https://firebase.google.com/)", "main": "dist/index.cjs.js", - "browser": "dist/index.esm2017.js", - "module": "dist/index.esm2017.js", + "browser": "dist/esm/index.esm2017.js", + "module": "dist/esm/index.esm2017.js", + "esm5": "dist/esm/index.esm5.js", + "exports": { + ".": { + "require": "./dist/index.cjs.js", + "default": "./dist/esm/index.esm2017.js" + }, + "./package.json": "./package.json" + }, "files": [ "dist" ], @@ -57,6 +65,5 @@ ".ts" ], "reportDir": "./coverage/node" - }, - "esm5": "dist/index.esm5.js" + } } \ No newline at end of file diff --git a/packages/remote-config-compat/rollup.config.js b/packages/remote-config-compat/rollup.config.js index 89b679548f7..d64b7bb89e5 100644 --- a/packages/remote-config-compat/rollup.config.js +++ b/packages/remote-config-compat/rollup.config.js @@ -19,13 +19,12 @@ import typescriptPlugin from 'rollup-plugin-typescript2'; import typescript from 'typescript'; import json from '@rollup/plugin-json'; import pkg from './package.json'; +import { emitModulePackageFile } from '../../scripts/build/rollup_emit_module_package_file'; const deps = Object.keys( Object.assign({}, pkg.peerDependencies, pkg.dependencies) ); -/** - * ES5 Builds - */ + const es5BuildPlugins = [ typescriptPlugin({ typescript @@ -33,24 +32,6 @@ const es5BuildPlugins = [ json() ]; -const es5Builds = [ - /** - * Browser Builds - */ - { - input: 'src/index.ts', - output: [ - { file: pkg.main, format: 'cjs', sourcemap: true }, - { file: pkg.esm5, format: 'es', sourcemap: true } - ], - external: id => deps.some(dep => id === dep || id.startsWith(`${dep}/`)), - plugins: es5BuildPlugins - } -]; - -/** - * ES2017 Builds - */ const es2017BuildPlugins = [ typescriptPlugin({ typescript, @@ -65,10 +46,13 @@ const es2017BuildPlugins = [ }) ]; -const es2017Builds = [ - /** - * Browser Builds - */ +const esmBuilds = [ + { + input: 'src/index.ts', + output: { file: pkg.esm5, format: 'es', sourcemap: true }, + external: id => deps.some(dep => id === dep || id.startsWith(`${dep}/`)), + plugins: [...es5BuildPlugins, emitModulePackageFile()] + }, { input: 'src/index.ts', output: { @@ -77,8 +61,17 @@ const es2017Builds = [ sourcemap: true }, external: id => deps.some(dep => id === dep || id.startsWith(`${dep}/`)), - plugins: es2017BuildPlugins + plugins: [...es2017BuildPlugins, emitModulePackageFile()] + } +]; + +const cjsBuilds = [ + { + input: 'src/index.ts', + output: { file: pkg.main, format: 'cjs', sourcemap: true }, + external: id => deps.some(dep => id === dep || id.startsWith(`${dep}/`)), + plugins: es5BuildPlugins } ]; -export default [...es5Builds, ...es2017Builds]; +export default [...esmBuilds, ...cjsBuilds]; diff --git a/packages/remote-config-compat/test/setup.ts b/packages/remote-config-compat/test/setup.ts index b1e3136529f..899b4867c1a 100644 --- a/packages/remote-config-compat/test/setup.ts +++ b/packages/remote-config-compat/test/setup.ts @@ -17,7 +17,7 @@ import { use } from 'chai'; import { restore } from 'sinon'; -import * as sinonChai from 'sinon-chai'; +import sinonChai from 'sinon-chai'; use(sinonChai); diff --git a/packages/remote-config/package.json b/packages/remote-config/package.json index 4edba4cff8d..bf628e71604 100644 --- a/packages/remote-config/package.json +++ b/packages/remote-config/package.json @@ -4,8 +4,16 @@ "description": "The Remote Config package of the Firebase JS SDK", "author": "Firebase (https://firebase.google.com/)", "main": "dist/index.cjs.js", - "browser": "dist/index.esm2017.js", - "module": "dist/index.esm2017.js", + "browser": "dist/esm/index.esm2017.js", + "module": "dist/esm/index.esm2017.js", + "esm5": "dist/esm/index.esm.js", + "exports": { + ".": { + "require": "./dist/index.cjs.js", + "default": "./dist/esm/index.esm2017.js" + }, + "./package.json": "./package.json" + }, "files": [ "dist" ], @@ -58,6 +66,5 @@ ".ts" ], "reportDir": "./coverage/node" - }, - "esm5": "dist/index.esm.js" + } } \ No newline at end of file diff --git a/packages/remote-config/rollup.config.js b/packages/remote-config/rollup.config.js index d3caf97d169..dba933fa417 100644 --- a/packages/remote-config/rollup.config.js +++ b/packages/remote-config/rollup.config.js @@ -20,6 +20,7 @@ import typescriptPlugin from 'rollup-plugin-typescript2'; import replace from 'rollup-plugin-replace'; import typescript from 'typescript'; import { generateBuildTargetReplaceConfig } from '../../scripts/build/rollup_replace_build_target'; +import { emitModulePackageFile } from '../../scripts/build/rollup_emit_module_package_file'; import pkg from './package.json'; const deps = Object.keys( @@ -35,33 +36,6 @@ const es5BuildPlugins = [ json() ]; -const es5Builds = [ - /** - * Browser Builds - */ - { - input: 'src/index.ts', - output: [{ file: pkg.main, format: 'cjs', sourcemap: true }], - external: id => deps.some(dep => id === dep || id.startsWith(`${dep}/`)), - plugins: [ - ...es5BuildPlugins, - replace(generateBuildTargetReplaceConfig('cjs', 5)) - ] - }, - { - input: 'src/index.ts', - output: [{ file: pkg.esm5, format: 'es', sourcemap: true }], - external: id => deps.some(dep => id === dep || id.startsWith(`${dep}/`)), - plugins: [ - ...es5BuildPlugins, - replace(generateBuildTargetReplaceConfig('esm', 5)) - ] - } -]; - -/** - * ES2017 Builds - */ const es2017BuildPlugins = [ typescriptPlugin({ typescript, @@ -74,7 +48,17 @@ const es2017BuildPlugins = [ json({ preferConst: true }) ]; -const es2017Builds = [ +const esmBuilds = [ + { + input: 'src/index.ts', + output: [{ file: pkg.esm5, format: 'es', sourcemap: true }], + external: id => deps.some(dep => id === dep || id.startsWith(`${dep}/`)), + plugins: [ + ...es5BuildPlugins, + replace(generateBuildTargetReplaceConfig('esm', 5)), + emitModulePackageFile() + ] + }, { /** * Browser Build @@ -88,9 +72,22 @@ const es2017Builds = [ external: id => deps.some(dep => id === dep || id.startsWith(`${dep}/`)), plugins: [ ...es2017BuildPlugins, - replace(generateBuildTargetReplaceConfig('esm', 2017)) + replace(generateBuildTargetReplaceConfig('esm', 2017)), + emitModulePackageFile() + ] + } +]; + +const cjsBuilds = [ + { + input: 'src/index.ts', + output: [{ file: pkg.main, format: 'cjs', sourcemap: true }], + external: id => deps.some(dep => id === dep || id.startsWith(`${dep}/`)), + plugins: [ + ...es5BuildPlugins, + replace(generateBuildTargetReplaceConfig('cjs', 5)) ] } ]; -export default [...es5Builds, ...es2017Builds]; +export default [...esmBuilds, ...cjsBuilds]; diff --git a/packages/remote-config/test/setup.ts b/packages/remote-config/test/setup.ts index 90d154f1400..0b1c6103072 100644 --- a/packages/remote-config/test/setup.ts +++ b/packages/remote-config/test/setup.ts @@ -16,8 +16,8 @@ */ import { use } from 'chai'; -import * as sinonChai from 'sinon-chai'; -import * as chaiAsPromised from 'chai-as-promised'; +import sinonChai from 'sinon-chai'; +import chaiAsPromised from 'chai-as-promised'; // Normalizes Sinon assertions to Chai syntax. use(sinonChai); diff --git a/packages/rules-unit-testing/test/setup.ts b/packages/rules-unit-testing/test/setup.ts index e0295f1590c..4c86e3376a6 100644 --- a/packages/rules-unit-testing/test/setup.ts +++ b/packages/rules-unit-testing/test/setup.ts @@ -16,9 +16,9 @@ */ import { use } from 'chai'; -import * as chaiAsPromised from 'chai-as-promised'; +import chaiAsPromised from 'chai-as-promised'; import { restore } from 'sinon'; -import * as sinonChai from 'sinon-chai'; +import sinonChai from 'sinon-chai'; use(chaiAsPromised); use(sinonChai); diff --git a/packages/storage-compat/package.json b/packages/storage-compat/package.json index 3752a28269e..c3ed3f3d328 100644 --- a/packages/storage-compat/package.json +++ b/packages/storage-compat/package.json @@ -4,9 +4,16 @@ "description": "The Firebase Firestore compatibility package", "author": "Firebase (https://firebase.google.com/)", "main": "./dist/index.cjs.js", - "browser": "./dist/index.esm2017.js", - "module": "./dist/index.esm2017.js", - "esm5": "./dist/index.esm5.js", + "browser": "./dist/esm/index.esm2017.js", + "module": "./dist/esm/index.esm2017.js", + "esm5": "./dist/esm/index.esm5.js", + "exports": { + ".": { + "require": "./dist/index.cjs.js", + "default": "./dist/esm/index.esm2017.js" + }, + "./package.json": "./package.json" + }, "license": "Apache-2.0", "typings": "./dist/src/index.d.ts", "scripts": { diff --git a/packages/storage-compat/rollup.config.js b/packages/storage-compat/rollup.config.js index c220eb88893..5aad0883255 100644 --- a/packages/storage-compat/rollup.config.js +++ b/packages/storage-compat/rollup.config.js @@ -19,13 +19,12 @@ import json from '@rollup/plugin-json'; import typescriptPlugin from 'rollup-plugin-typescript2'; import typescript from 'typescript'; import pkg from './package.json'; +import { emitModulePackageFile } from '../../scripts/build/rollup_emit_module_package_file'; const deps = Object.keys( Object.assign({}, pkg.peerDependencies, pkg.dependencies) ); -/** - * ES5 Builds - */ + const es5BuildPlugins = [ typescriptPlugin({ typescript, @@ -34,29 +33,6 @@ const es5BuildPlugins = [ json() ]; -const es5Builds = [ - { - input: './src/index.ts', - output: [ - { - file: pkg.main, - format: 'cjs', - sourcemap: true - }, - { - file: pkg.esm5, - format: 'es', - sourcemap: true - } - ], - plugins: [...es5BuildPlugins], - external: id => deps.some(dep => id === dep || id.startsWith(`${dep}/`)) - } -]; - -/** - * ES2017 Builds - */ const es2017BuildPlugins = [ typescriptPlugin({ typescript, @@ -70,7 +46,17 @@ const es2017BuildPlugins = [ json({ preferConst: true }) ]; -const es2017Builds = [ +const esmBuilds = [ + { + input: './src/index.ts', + output: { + file: pkg.esm5, + format: 'es', + sourcemap: true + }, + plugins: [...es5BuildPlugins, emitModulePackageFile()], + external: id => deps.some(dep => id === dep || id.startsWith(`${dep}/`)) + }, { input: './src/index.ts', output: { @@ -78,10 +64,23 @@ const es2017Builds = [ format: 'es', sourcemap: true }, - plugins: [...es2017BuildPlugins], + plugins: [...es2017BuildPlugins, emitModulePackageFile()], + external: id => deps.some(dep => id === dep || id.startsWith(`${dep}/`)) + } +]; + +const cjsBuilds = [ + { + input: './src/index.ts', + output: { + file: pkg.main, + format: 'cjs', + sourcemap: true + }, + plugins: [...es5BuildPlugins], external: id => deps.some(dep => id === dep || id.startsWith(`${dep}/`)) } ]; // eslint-disable-next-line import/no-default-export -export default [...es5Builds, ...es2017Builds]; +export default [...esmBuilds, ...cjsBuilds]; diff --git a/packages/storage-compat/test/setup.ts b/packages/storage-compat/test/setup.ts index 22ed9b0d112..e03cccec072 100644 --- a/packages/storage-compat/test/setup.ts +++ b/packages/storage-compat/test/setup.ts @@ -17,8 +17,8 @@ import { use } from 'chai'; import { restore } from 'sinon'; -import * as sinonChai from 'sinon-chai'; -import * as chaiAsPromised from 'chai-as-promised'; +import sinonChai from 'sinon-chai'; +import chaiAsPromised from 'chai-as-promised'; use(chaiAsPromised); use(sinonChai); diff --git a/packages/storage/package.json b/packages/storage/package.json index 9a86df3e014..bbe3e722195 100644 --- a/packages/storage/package.json +++ b/packages/storage/package.json @@ -3,10 +3,20 @@ "version": "0.8.4", "description": "", "author": "Firebase (https://firebase.google.com/)", - "main": "dist/index.cjs.js", + "main": "dist/index.node.cjs.js", "module": "dist/index.esm2017.js", "browser": "dist/index.esm2017.js", "esm5": "dist/index.esm5.js", + "exports": { + ".": { + "node": { + "import": "./dist/node-esm/index.node.esm.js", + "default": "./dist/index.node.cjs.js" + }, + "default": "./dist/index.esm2017.js" + }, + "./package.json": "./package.json" + }, "files": [ "dist" ], @@ -56,4 +66,4 @@ "url": "https://github.com/firebase/firebase-js-sdk/issues" }, "typings": "dist/src/index.d.ts" -} +} \ No newline at end of file diff --git a/packages/storage/rollup.config.js b/packages/storage/rollup.config.js index e129ca49015..aeaedaf32fb 100644 --- a/packages/storage/rollup.config.js +++ b/packages/storage/rollup.config.js @@ -21,6 +21,7 @@ import replace from 'rollup-plugin-replace'; import typescript from 'typescript'; import alias from '@rollup/plugin-alias'; import { generateBuildTargetReplaceConfig } from '../../scripts/build/rollup_replace_build_target'; +import { emitModulePackageFile } from '../../scripts/build/rollup_emit_module_package_file'; import pkg from './package.json'; function generateAliasConfig(platform) { @@ -48,14 +49,23 @@ const es5Plugins = [ json() ]; -const es5Builds = [ - // Browser +const es2017Plugins = [ + typescriptPlugin({ + typescript, + tsconfigOverride: { + compilerOptions: { + target: 'es2017' + } + }, + abortOnError: false + }), + json({ preferConst: true }) +]; + +const browserBuilds = [ { input: './src/index.ts', - output: [ - { file: 'dist/index.browser.cjs.js', format: 'cjs', sourcemap: true }, - { file: pkg.esm5, format: 'es', sourcemap: true } - ], + output: { file: pkg.esm5, format: 'es', sourcemap: true }, plugins: [ alias(generateAliasConfig('browser')), ...es5Plugins, @@ -69,6 +79,26 @@ const es5Builds = [ moduleSideEffects: false } }, + { + input: './src/index.ts', + output: { + file: pkg.browser, + format: 'es', + sourcemap: true + }, + plugins: [ + alias(generateAliasConfig('browser')), + ...es2017Plugins, + replace({ + ...generateBuildTargetReplaceConfig('esm', 2017), + '__RUNTIME_ENV__': '' + }) + ], + external: id => deps.some(dep => id === dep || id.startsWith(`${dep}/`)), + treeshake: { + moduleSideEffects: false + } + }, { // needed by Emulator UI input: './src/index.ts', @@ -90,21 +120,7 @@ const es5Builds = [ } ]; -const es2017Plugins = [ - typescriptPlugin({ - typescript, - tsconfigOverride: { - compilerOptions: { - target: 'es2017' - } - }, - abortOnError: false - }), - json({ preferConst: true }) -]; - -const es2017Builds = [ - // Node +const nodeBuilds = [ { input: './src/index.node.ts', output: { @@ -126,24 +142,24 @@ const es2017Builds = [ moduleSideEffects: false } }, - - // Browser { input: './src/index.ts', output: { - file: pkg.browser, - format: 'es', + file: pkg.exports['.'].node.import, + format: 'esm', sourcemap: true }, plugins: [ - alias(generateAliasConfig('browser')), + alias(generateAliasConfig('node')), ...es2017Plugins, replace({ ...generateBuildTargetReplaceConfig('esm', 2017), - '__RUNTIME_ENV__': '' - }) + '__RUNTIME_ENV__': 'node' + }), + emitModulePackageFile() ], - external: id => deps.some(dep => id === dep || id.startsWith(`${dep}/`)), + external: id => + nodeDeps.some(dep => id === dep || id.startsWith(`${dep}/`)), treeshake: { moduleSideEffects: false } @@ -151,4 +167,4 @@ const es2017Builds = [ ]; // eslint-disable-next-line import/no-default-export -export default [...es5Builds, ...es2017Builds]; +export default [...browserBuilds, ...nodeBuilds]; diff --git a/packages/storage/test/integration/integration.test.ts b/packages/storage/test/integration/integration.test.ts index c1f015c352e..312eb3dfe5b 100644 --- a/packages/storage/test/integration/integration.test.ts +++ b/packages/storage/test/integration/integration.test.ts @@ -33,7 +33,7 @@ import { } from '../../src/index'; import { use, expect } from 'chai'; -import * as chaiAsPromised from 'chai-as-promised'; +import chaiAsPromised from 'chai-as-promised'; import * as types from '../../src/public-types'; use(chaiAsPromised); diff --git a/packages/storage/test/unit/testshared.ts b/packages/storage/test/unit/testshared.ts index 2a35386b653..604b3a069ec 100644 --- a/packages/storage/test/unit/testshared.ts +++ b/packages/storage/test/unit/testshared.ts @@ -15,7 +15,7 @@ * limitations under the License. */ import { expect, use } from 'chai'; -import * as chaiAsPromised from 'chai-as-promised'; +import chaiAsPromised from 'chai-as-promised'; use(chaiAsPromised); diff --git a/packages/template/package.json b/packages/template/package.json index 0e8536cc4bd..ef15db2cb31 100644 --- a/packages/template/package.json +++ b/packages/template/package.json @@ -5,9 +5,19 @@ "description": "A template package for new firebase packages", "author": "Firebase (https://firebase.google.com/)", "main": "dist/index.node.cjs.js", - "browser": "dist/index.esm.js", - "module": "dist/index.esm.js", - "esm2017": "dist/index.esm2017.js", + "browser": "dist/index.esm2017.js", + "module": "dist/index.esm2017.js", + "esm5": "dist/index.esm5.js", + "exports": { + ".": { + "node": { + "import": "./dist/node-esm/index.node.esm.js", + "require": "./dist/index.node.cjs.js" + }, + "default": "./dist/index.esm2017.js" + }, + "./package.json": "./package.json" + }, "files": [ "dist" ], @@ -53,4 +63,4 @@ ], "reportDir": "./coverage/node" } -} +} \ No newline at end of file diff --git a/packages/template/rollup.config.js b/packages/template/rollup.config.js index 2539715af91..5c95031f734 100644 --- a/packages/template/rollup.config.js +++ b/packages/template/rollup.config.js @@ -18,44 +18,18 @@ import typescriptPlugin from 'rollup-plugin-typescript2'; import typescript from 'typescript'; import pkg from './package.json'; +import { emitModulePackageFile } from '../../scripts/build/rollup_emit_module_package_file'; const deps = Object.keys( Object.assign({}, pkg.peerDependencies, pkg.dependencies) ); -/** - * ES5 Builds - */ const es5BuildPlugins = [ typescriptPlugin({ typescript }) ]; -const es5Builds = [ - /** - * Browser Builds - */ - { - input: 'index.ts', - output: [{ file: pkg.module, format: 'es', sourcemap: true }], - plugins: es5BuildPlugins, - external: id => deps.some(dep => id === dep || id.startsWith(`${dep}/`)) - }, - /** - * Node.js Build - */ - { - input: 'index.node.ts', - output: [{ file: pkg.main, format: 'cjs', sourcemap: true }], - plugins: es5BuildPlugins, - external: id => deps.some(dep => id === dep || id.startsWith(`${dep}/`)) - } -]; - -/** - * ES2017 Builds - */ const es2017BuildPlugins = [ typescriptPlugin({ typescript, @@ -67,14 +41,17 @@ const es2017BuildPlugins = [ }) ]; -const es2017Builds = [ - /** - * Browser Builds - */ +const browserBuilds = [ + { + input: 'index.ts', + output: [{ file: pkg.esm5, format: 'es', sourcemap: true }], + plugins: es5BuildPlugins, + external: id => deps.some(dep => id === dep || id.startsWith(`${dep}/`)) + }, { input: 'index.ts', output: { - file: pkg.esm2017, + file: pkg.module, format: 'es', sourcemap: true }, @@ -83,4 +60,21 @@ const es2017Builds = [ } ]; -export default [...es5Builds, ...es2017Builds]; +const nodeBuilds = [ + { + input: 'index.node.ts', + output: [{ file: pkg.main, format: 'cjs', sourcemap: true }], + plugins: es2017BuildPlugins, + external: id => deps.some(dep => id === dep || id.startsWith(`${dep}/`)) + }, + { + input: 'index.node.ts', + output: [ + { file: pkg.exports['.'].node.import, format: 'es', sourcemap: true } + ], + plugins: [...es2017BuildPlugins, emitModulePackageFile()], + external: id => deps.some(dep => id === dep || id.startsWith(`${dep}/`)) + } +]; + +export default [...browserBuilds, ...nodeBuilds]; diff --git a/packages/util/package.json b/packages/util/package.json index afdd04731cd..f11d8fabee0 100644 --- a/packages/util/package.json +++ b/packages/util/package.json @@ -7,6 +7,16 @@ "browser": "dist/index.esm2017.js", "module": "dist/index.esm2017.js", "esm5": "dist/index.esm5.js", + "exports": { + ".": { + "node": { + "import": "./dist/node-esm/index.node.esm.js", + "require": "./dist/index.node.cjs.js" + }, + "default": "./dist/index.esm2017.js" + }, + "./package.json": "./package.json" + }, "files": [ "dist" ], @@ -46,4 +56,4 @@ ], "reportDir": "./coverage/node" } -} +} \ No newline at end of file diff --git a/packages/util/rollup.config.js b/packages/util/rollup.config.js index f34ae0ee74a..4bd11731821 100644 --- a/packages/util/rollup.config.js +++ b/packages/util/rollup.config.js @@ -18,45 +18,18 @@ import typescriptPlugin from 'rollup-plugin-typescript2'; import typescript from 'typescript'; import pkg from './package.json'; +import { emitModulePackageFile } from '../../scripts/build/rollup_emit_module_package_file'; const deps = Object.keys( Object.assign({}, pkg.peerDependencies, pkg.dependencies) ); -/** - * ES5 Builds - */ - const es5BuildPlugins = [ typescriptPlugin({ typescript }) ]; -const es5Builds = [ - /** - * Browser Builds - */ - { - input: 'index.ts', - output: [{ file: pkg.esm5, format: 'es', sourcemap: true }], - plugins: es5BuildPlugins, - external: id => deps.some(dep => id === dep || id.startsWith(`${dep}/`)) - }, - /** - * Node.js Build - */ - { - input: 'index.node.ts', - output: [{ file: pkg.main, format: 'cjs', sourcemap: true }], - plugins: es5BuildPlugins, - external: id => deps.some(dep => id === dep || id.startsWith(`${dep}/`)) - } -]; - -/** - * ES2017 Builds - */ const es2017BuildPlugins = [ typescriptPlugin({ typescript, @@ -68,7 +41,13 @@ const es2017BuildPlugins = [ }) ]; -const es2017Builds = [ +const browserBuilds = [ + { + input: 'index.ts', + output: [{ file: pkg.esm5, format: 'es', sourcemap: true }], + plugins: es5BuildPlugins, + external: id => deps.some(dep => id === dep || id.startsWith(`${dep}/`)) + }, { input: 'index.ts', output: { @@ -81,4 +60,21 @@ const es2017Builds = [ } ]; -export default [...es5Builds, ...es2017Builds]; +const nodeBuilds = [ + { + input: 'index.node.ts', + output: [{ file: pkg.main, format: 'cjs', sourcemap: true }], + plugins: es5BuildPlugins, + external: id => deps.some(dep => id === dep || id.startsWith(`${dep}/`)) + }, + { + input: 'index.node.ts', + output: [ + { file: pkg.exports['.'].node.import, format: 'es', sourcemap: true } + ], + plugins: [...es2017BuildPlugins, emitModulePackageFile()], + external: id => deps.some(dep => id === dep || id.startsWith(`${dep}/`)) + } +]; + +export default [...browserBuilds, ...nodeBuilds]; diff --git a/packages/webchannel-wrapper/package.json b/packages/webchannel-wrapper/package.json index c89c87a8e4e..d9f30f5fc42 100644 --- a/packages/webchannel-wrapper/package.json +++ b/packages/webchannel-wrapper/package.json @@ -6,6 +6,13 @@ "main": "dist/index.js", "module": "dist/index.esm2017.js", "esm5": "dist/index.esm.js", + "exports": { + ".": { + "require": "./dist/index.js", + "default": "./dist/index.esm2017.js" + }, + "./package.json": "./package.json" + }, "files": [ "dist" ], @@ -36,4 +43,4 @@ "bugs": { "url": "https://github.com/firebase/firebase-js-sdk/issues" } -} +} \ No newline at end of file diff --git a/scripts/build/rollup_emit_module_package_file.js b/scripts/build/rollup_emit_module_package_file.js new file mode 100644 index 00000000000..626d984fc62 --- /dev/null +++ b/scripts/build/rollup_emit_module_package_file.js @@ -0,0 +1,38 @@ +/** + * @license + * Copyright 2021 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. + */ + +/** + * + * @returns a rollup plugin that creates a package.json file in the output folder + * The package.json contains only {"type":"module"} to make Nodejs parse files in the output folder as + * ES modules without using the .mjs extension. + * + * This is useful for packages that support both Nodejs and Browser, so that they don't have to build 2 + * esm files with the same content but with different extensions. + */ +export function emitModulePackageFile() { + return { + generateBundle() { + this.emitFile({ + fileName: 'package.json', + source: `{"type":"module"}`, + type: 'asset' + }); + }, + name: 'emit-module-package-file' + }; +} diff --git a/scripts/emulator-testing/firestore-test-runner.ts b/scripts/emulator-testing/firestore-test-runner.ts index 12b2b7e9107..a542c9dbc3a 100644 --- a/scripts/emulator-testing/firestore-test-runner.ts +++ b/scripts/emulator-testing/firestore-test-runner.ts @@ -23,7 +23,7 @@ import { } from 'child-process-promise'; import * as path from 'path'; // @ts-ignore -import * as freePortFinder from 'find-free-port'; +import freePortFinder from 'find-free-port'; import { FirestoreEmulator } from './emulators/firestore-emulator';