Skip to content

Commit

Permalink
Add exports to all packages (#5646)
Browse files Browse the repository at this point in the history
* exports for analytics

* support exports for app

* support exports for app-check

* add exports to auth

* support exports for auth-compat

* add exports to component

* add exports to database packages

* exports for firestore

* add exports to functions

* add exports to installations

* add exports to logger

* add exports to messaging

* add exports to perf

* add exports to rc

* add exports to storage

* update template

* add exports to util

* add exports to webchannel

* use default import to import cjs libs

* make node code esm compatible

* remove esm entrypoint for app in nodejs to mininize dual package hazard

* reorganize builds by env

* fix typo

* format

* remove esm entrypoint for nodejs for fcm

* expose package.json to nodejs

* fix

* fix path in build

* simplify exports

* formatting

* enable esModuleInterop

* use default import

* use default import

* remove esm support for Nodejs in messaging
  • Loading branch information
Feiyang1 authored Nov 2, 2021
1 parent 6160497 commit 0b3ca78
Show file tree
Hide file tree
Showing 179 changed files with 1,406 additions and 1,196 deletions.
1 change: 1 addition & 0 deletions config/tsconfig.base.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
"module": "ES2015",
"moduleResolution": "node",
"resolveJsonModule": true,
"esModuleInterop": true,
"sourceMap": true,
"target": "es5",
"typeRoots": [
Expand Down
15 changes: 11 additions & 4 deletions packages/analytics-compat/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,16 @@
"description": "",
"author": "Firebase <[email protected]> (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"
],
Expand Down Expand Up @@ -54,6 +62,5 @@
".ts"
],
"reportDir": "./coverage/node"
},
"esm5": "dist/index.esm.js"
}
}
47 changes: 20 additions & 27 deletions packages/analytics-compat/rollup.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,39 +18,20 @@
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
}),
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,
Expand All @@ -63,20 +44,32 @@ const es2017BuildPlugins = [
json({ preferConst: true })
];

const es2017Builds = [
const esmBuilds = [
{
/**
* Browser Build
*/
input: 'src/index.ts',
output: {
file: pkg.browser,
format: 'es',
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];
2 changes: 1 addition & 1 deletion packages/analytics-compat/src/service.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down
15 changes: 11 additions & 4 deletions packages/analytics/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,16 @@
"description": "A analytics package for new firebase packages",
"author": "Firebase <[email protected]> (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"
],
Expand Down Expand Up @@ -60,6 +68,5 @@
".ts"
],
"reportDir": "./coverage/node"
},
"esm5": "dist/index.esm.js"
}
}
69 changes: 33 additions & 36 deletions packages/analytics/rollup.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,49 +20,20 @@ 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 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,
Expand All @@ -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,
Expand All @@ -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];
4 changes: 2 additions & 2 deletions packages/analytics/testing/setup.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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);
17 changes: 12 additions & 5 deletions packages/app-check-compat/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,16 @@
"description": "A compat App Check package for new firebase packages",
"author": "Firebase <[email protected]> (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"
],
Expand Down Expand Up @@ -55,6 +63,5 @@
".ts"
],
"reportDir": "./coverage/node"
},
"esm5": "dist/index.esm.js"
}
}
}
47 changes: 20 additions & 27 deletions packages/app-check-compat/rollup.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,39 +18,20 @@
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
}),
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,
Expand All @@ -63,20 +44,32 @@ 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,
format: 'es',
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];
16 changes: 0 additions & 16 deletions packages/app-check-compat/rollup.shared.js

This file was deleted.

Loading

0 comments on commit 0b3ca78

Please sign in to comment.