Skip to content

Commit 6212341

Browse files
Merge branch 'master' into mrschmidt/components
2 parents 9be4a50 + 2dd560b commit 6212341

26 files changed

+411
-476
lines changed

package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,9 +22,9 @@
2222
],
2323
"scripts": {
2424
"dev": "lerna run --parallel --scope @firebase/* --scope firebase --scope rxfire dev",
25-
"build": "lerna run --scope @firebase/* --scope firebase --scope rxfire build",
25+
"build": "lerna run --scope @firebase/app-exp build:deps && lerna run --scope @firebase/* --scope firebase --scope rxfire --ignore @firebase/app-exp build",
2626
"build:exp": "lerna run --scope @firebase/*-exp --scope firebase-exp build",
27-
"build:release": "lerna run --scope @firebase/app-exp build:deps && lerna run --scope @firebase/* --scope firebase --ignore @firebase/*-exp --ignore firebase-exp prepare",
27+
"build:release": "lerna run --scope @firebase/app-exp build:deps && lerna run --scope @firebase/* --scope firebase --scope rxfire --ignore @firebase/*-exp prepare",
2828
"build:exp:release": "yarn --cwd packages/app build:deps && lerna run --scope @firebase/*-exp --scope firebase-exp prepare && yarn --cwd packages-exp/app-exp typings:public",
2929
"link:packages": "lerna exec --scope @firebase/* --scope firebase --scope rxfire -- yarn link",
3030
"stage:packages": "./scripts/prepublish.sh",

packages-exp/firebase-exp/functions/index.cdn.ts renamed to packages-exp/firebase-exp/firestore/index.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,4 +14,5 @@
1414
* See the License for the specific language governing permissions and
1515
* limitations under the License.
1616
*/
17-
export * from '@firebase/functions-exp';
17+
18+
export * from '@firebase/firestore';
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
/**
2+
* @license
3+
* Copyright 2020 Google LLC
4+
*
5+
* Licensed under the Apache License, Version 2.0 (the "License");
6+
* you may not use this file except in compliance with the License.
7+
* You may obtain a copy of the License at
8+
*
9+
* http://www.apache.org/licenses/LICENSE-2.0
10+
*
11+
* Unless required by applicable law or agreed to in writing, software
12+
* distributed under the License is distributed on an "AS IS" BASIS,
13+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
* See the License for the specific language governing permissions and
15+
* limitations under the License.
16+
*/
17+
18+
export * from '@firebase/firestore/lite';
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
{
2+
"name": "firebase-exp/firestore/lite",
3+
"main": "dist/index.cjs.js",
4+
"browser": "dist/index.esm.js",
5+
"module": "dist/index.esm.js",
6+
"typings": "dist/firestore/lite/index.d.ts"
7+
}
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
{
2+
"name": "firebase-exp/firestore",
3+
"main": "dist/index.cjs.js",
4+
"browser": "dist/index.esm.js",
5+
"module": "dist/index.esm.js",
6+
"typings": "dist/firestore/index.d.ts"
7+
}

packages-exp/firebase-exp/gulpfile.js

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,9 +21,10 @@ var sourcemaps = require('gulp-sourcemaps');
2121

2222
const OUTPUT_FILE = 'firebase.js';
2323
const pkgJson = require('./package.json');
24-
const files = [
25-
...pkgJson.components.map(component => `firebase-${component}.js`)
26-
];
24+
const files = pkgJson.components.map(component => {
25+
const componentName = component.replace('/', '-');
26+
return `firebase-${componentName}.js`;
27+
});
2728

2829
gulp.task('firebase-js', function () {
2930
return gulp

packages-exp/firebase-exp/package.json

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,8 @@
3636
},
3737
"dependencies": {
3838
"@firebase/app-exp": "0.0.800",
39-
"@firebase/functions-exp": "0.0.800"
39+
"@firebase/functions-exp": "0.0.800",
40+
"@firebase/firestore": "1.16.1"
4041
},
4142
"devDependencies": {
4243
"rollup": "2.21.0",
@@ -54,6 +55,8 @@
5455
},
5556
"components": [
5657
"app",
57-
"functions"
58+
"functions",
59+
"firestore",
60+
"firestore/lite"
5861
]
5962
}

packages-exp/firebase-exp/rollup.config.release.js

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ import pkg from './package.json';
2828
import appPkg from './app/package.json';
2929

3030
// remove -exp from dependencies name
31-
const external = Object.keys(pkg.dependencies || {}).map(name =>
31+
const deps = Object.keys(pkg.dependencies || {}).map(name =>
3232
name.replace('-exp', '')
3333
);
3434

@@ -99,7 +99,7 @@ const appBuilds = [
9999
{ file: resolve('app', appPkg.module), format: 'es', sourcemap: true }
100100
],
101101
plugins: [...plugins, typescriptPlugin],
102-
external
102+
external: id => deps.some(dep => id === dep || id.startsWith(`${dep}/`))
103103
},
104104
/**
105105
* App UMD Builds
@@ -121,6 +121,9 @@ const componentBuilds = pkg.components
121121
.filter(component => component !== 'app')
122122
.map(component => {
123123
const pkg = require(`./${component}/package.json`);
124+
// It is needed for handling sub modules, for example firestore/lite which should produce firebase-firestore-lite.js
125+
// Otherwise, we will create a directory with '/' in the name.
126+
const componentName = component.replace('/', '-');
124127
return [
125128
{
126129
input: `${component}/index.ts`,
@@ -137,11 +140,14 @@ const componentBuilds = pkg.components
137140
}
138141
],
139142
plugins: [...plugins, typescriptPlugin],
140-
external
143+
external: id => deps.some(dep => id === dep || id.startsWith(`${dep}/`))
141144
},
142145
{
143146
input: `${component}/index.ts`,
144-
output: createUmdOutputConfig(`firebase-${component}.js`, component),
147+
output: createUmdOutputConfig(
148+
`firebase-${componentName}.js`,
149+
componentName
150+
),
145151
plugins: [...plugins, typescriptPluginUMD],
146152
external: ['@firebase/app']
147153
}

packages-exp/functions-exp/package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
"lint:fix": "eslint --fix -c .eslintrc.js '**/*.ts' --ignore-path '../../.gitignore'",
1515
"build": "rollup -c && yarn api-report",
1616
"build:deps": "lerna run --scope @firebase/functions-exp --include-dependencies build",
17+
"build:release": "rollup -c rollup.config.release.js && yarn api-report",
1718
"dev": "rollup -c -w",
1819
"test": "yarn type-check && run-p lint test:browser test:node",
1920
"test:ci": "node ../../scripts/run_tests_in_ci.js",
@@ -22,7 +23,7 @@
2223
"test:browser:debug": "karma start --browsers=Chrome --auto-watch",
2324
"test:node": "TS_NODE_COMPILER_OPTIONS='{\"module\":\"commonjs\"}' nyc --reporter lcovonly -- mocha 'src/{,!(browser)/**/}*.test.ts' --file src/index.node.ts --config ../../config/mocharc.node.js",
2425
"test:emulator": "env FIREBASE_FUNCTIONS_EMULATOR_ORIGIN=http://localhost:5005 run-p test:node",
25-
"prepare": "rollup -c rollup.config.release.js && yarn api-report",
26+
"prepare": "yarn build:release",
2627
"api-report": "api-extractor run --local --verbose",
2728
"predoc": "node ../../scripts/exp/remove-exp.js temp",
2829
"doc": "api-documenter markdown --input temp --output docs",

packages/firestore/exp/package.json

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,9 @@
22
"name": "@firebase/firestore/exp",
33
"description": "A tree-shakeable version of the Firestore SDK",
44
"main": "../dist/exp/index.node.umd.js",
5+
"module": "../dist/exp/index.browser.esm2017.js",
56
"browser": "../dist/exp/index.browser.esm2017.js",
67
"react-native": "../dist/exp/index.rn.esm2017.js",
8+
"typings": "../exp-types/index.d.ts",
79
"private": true
810
}

packages/firestore/lite/package.json

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,10 @@
11
{
22
"name": "@firebase/firestore/lite",
33
"description": "A lite version of the Firestore SDK",
4-
"main": "../dist/lite/index.node.umd.js",
4+
"main": "../dist/lite/index.node.esm2017.js",
5+
"module": "../dist/lite/index.browser.esm2017.js",
56
"browser": "../dist/lite/index.browser.esm2017.js",
67
"react-native": "../dist/lite/index.rn.esm2017.js",
8+
"typings": "../lite-types/index.d.ts",
79
"private": true
810
}

packages/firestore/package.json

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -8,12 +8,13 @@
88
"author": "Firebase <[email protected]> (https://firebase.google.com/)",
99
"scripts": {
1010
"build": "rollup -c rollup.config.es2017.js && rollup -c rollup.config.es5.js && yarn build:lite && yarn build:exp",
11-
"build:scripts": "tsc -moduleResolution node --module commonjs scripts/*.ts",
11+
"build:scripts": "tsc -moduleResolution node --module commonjs scripts/*.ts && ls scripts/*.js | xargs -I % sh -c 'terser % -o %'",
1212
"build:release": "rollup -c rollup.config.es2017.js && rollup -c rollup.config.es5.js",
1313
"build:deps": "lerna run --scope @firebase/'{app,firestore}' --include-dependencies build",
1414
"build:console": "node tools/console.build.js",
1515
"build:exp": "rollup -c rollup.config.exp.js",
1616
"build:lite": "rollup -c rollup.config.lite.js",
17+
"build:exp:release": "yarn build:exp && yarn build:lite",
1718
"predev": "yarn prebuild",
1819
"dev": "rollup -c -w",
1920
"lint": "eslint -c .eslintrc.js '**/*.ts' --ignore-path '../../.gitignore'",
@@ -23,22 +24,22 @@
2324
"gendeps:exp": "../../scripts/exp/extract-deps.sh --types ./exp-types/index.d.ts --bundle ./dist/exp/tmp.js --output ./exp/dependencies.json",
2425
"pregendeps:lite": "node scripts/build-bundle.js --input ./lite/index.ts --output ./dist/lite/tmp.js",
2526
"gendeps:lite": "../../scripts/exp/extract-deps.sh --types ./lite-types/index.d.ts --bundle ./dist/lite/tmp.js --output ./lite/dependencies.json",
26-
"test:lite": "TS_NODE_CACHE=NO TS_NODE_COMPILER_OPTIONS='{\"module\":\"commonjs\"}' nyc --reporter lcovonly -- mocha 'lite/test/**/*.test.ts' --require ts-node/register --file lite/index.ts --config ../../config/mocharc.node.js",
27+
"test:lite": "node ./scripts/run-tests.js --emulator --main=lite/index.ts 'lite/test/**/*.test.ts'",
2728
"test:lite:browser": "karma start --single-run --lite",
2829
"test:lite:browser:debug": "karma start --single-run --lite --auto-watch",
29-
"test:exp": "TS_NODE_CACHE=NO TS_NODE_COMPILER_OPTIONS='{\"module\":\"commonjs\"}' nyc --reporter lcovonly -- mocha 'test/integration/api/*.test.ts' --file exp/index.ts --config ../../config/mocharc.node.js",
30-
"test:exp:persistence": "USE_MOCK_PERSISTENCE=YES TS_NODE_CACHE=NO TS_NODE_COMPILER_OPTIONS='{\"module\":\"commonjs\"}' nyc --reporter lcovonly -- mocha 'test/integration/api/*.test.ts' --require ts-node/register --require exp/index.ts --require test/util/node_persistence.ts --config ../../config/mocharc.node.js",
30+
"test:exp": "node ./scripts/run-tests.js --emulator --main=exp/index.ts test/integration/api/*.test.ts",
31+
"test:exp:persistence": "node ./scripts/run-tests.js --emulator --persistence --main=exp/index.ts test/integration/api/*.test.ts",
3132
"test:exp:browser": "karma start --single-run --exp",
3233
"test:exp:browser:debug": "karma start --single-run --exp --auto-watch",
3334
"test": "run-s lint test:all",
3435
"test:ci": "node ../../scripts/run_tests_in_ci.js",
3536
"test:all": "run-p test:browser test:lite:browser test:exp:browser test:travis test:minified test:exp test:lite",
3637
"test:browser": "karma start --single-run",
3738
"test:browser:debug": "karma start --browsers=Chrome --auto-watch",
38-
"test:node": "FIRESTORE_EMULATOR_PORT=8080 FIRESTORE_EMULATOR_PROJECT_ID=test-emulator TS_NODE_CACHE=NO TS_NODE_COMPILER_OPTIONS='{\"module\":\"commonjs\"}' nyc --reporter lcovonly -- mocha 'test/{,!(browser)/**/}*.test.ts' --file index.node.ts --config ../../config/mocharc.node.js",
39-
"test:node:prod": "TS_NODE_CACHE=NO TS_NODE_COMPILER_OPTIONS='{\"module\":\"commonjs\"}' nyc --reporter lcovonly -- mocha 'test/{,!(browser)/**/}*.test.ts' --file index.node.ts --config ../../config/mocharc.node.js",
40-
"test:node:persistence": "FIRESTORE_EMULATOR_PORT=8080 FIRESTORE_EMULATOR_PROJECT_ID=test-emulator USE_MOCK_PERSISTENCE=YES TS_NODE_CACHE=NO TS_NODE_COMPILER_OPTIONS='{\"module\":\"commonjs\"}' nyc --reporter lcovonly -- mocha 'test/{,!(browser)/**/}*.test.ts' --require ts-node/register --require index.node.ts --require test/util/node_persistence.ts --config ../../config/mocharc.node.js",
41-
"test:node:persistence:prod": "USE_MOCK_PERSISTENCE=YES TS_NODE_CACHE=NO TS_NODE_COMPILER_OPTIONS='{\"module\":\"commonjs\"}' nyc --reporter lcovonly -- mocha 'test/{,!(browser)/**/}*.test.ts' --require ts-node/register --require index.node.ts --require test/util/node_persistence.ts --config ../../config/mocharc.node.js",
39+
"test:node": "node ./scripts/run-tests.js --main=index.node.ts --emulator 'test/{,!(browser)/**/}*.test.ts'",
40+
"test:node:prod": "node ./scripts/run-tests.js --main=index.node.ts 'test/{,!(browser)/**/}*.test.ts'",
41+
"test:node:persistence": "node ./scripts/run-tests.js --main=index.node.ts --persistence --emulator 'test/{,!(browser)/**/}*.test.ts'",
42+
"test:node:persistence:prod": "node ./scripts/run-tests.js --main=index.node.ts --persistence 'test/{,!(browser)/**/}*.test.ts'",
4243
"test:travis": "ts-node --compiler-options='{\"module\":\"commonjs\"}' ../../scripts/emulator-testing/firestore-test-runner.ts",
4344
"test:minified": "(cd ../../integration/firestore ; yarn test)",
4445
"prepare": "yarn build:release"

packages/firestore/rollup.config.es2017.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ const browserBuildPlugins = [
6666
}
6767
},
6868
clean: true,
69-
transformers: util.removeAssertAndPrefixInternalTransformer
69+
transformers: [util.removeAssertAndPrefixInternalTransformer]
7070
}),
7171
json({ preferConst: true }),
7272
terser(util.manglePrivatePropertiesOptions)
@@ -139,7 +139,7 @@ const nodeBuildPlugins = [
139139
}
140140
},
141141
clean: true,
142-
transformers: util.removeAssertTransformer
142+
transformers: [util.removeAssertTransformer]
143143
}),
144144
json(),
145145
// Needed as we also use the *.proto files

packages/firestore/rollup.config.exp.js

Lines changed: 20 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ import typescriptPlugin from 'rollup-plugin-typescript2';
2121
import typescript from 'typescript';
2222
import path from 'path';
2323
import { terser } from 'rollup-plugin-terser';
24+
import { importPathTransformer } from '../../scripts/exp/ts-transform-import-path';
2425

2526
import pkg from './exp/package.json';
2627

@@ -35,7 +36,8 @@ const nodePlugins = [
3536
}
3637
},
3738
clean: true,
38-
transformers: util.removeAssertTransformer
39+
abortOnError: false,
40+
transformers: [util.removeAssertTransformer, importPathTransformer]
3941
}),
4042
json()
4143
];
@@ -49,7 +51,11 @@ const browserPlugins = [
4951
}
5052
},
5153
clean: true,
52-
transformers: util.removeAssertAndPrefixInternalTransformer
54+
abortOnError: false,
55+
transformers: [
56+
util.removeAssertAndPrefixInternalTransformer,
57+
importPathTransformer
58+
]
5359
}),
5460
json({ preferConst: true }),
5561
terser(util.manglePrivatePropertiesOptions)
@@ -65,7 +71,10 @@ const allBuilds = [
6571
name: 'firebase.firestore'
6672
},
6773
plugins: [alias(util.generateAliasConfig('node')), ...nodePlugins],
68-
external: util.resolveNodeExterns
74+
external: util.resolveNodeExterns,
75+
treeshake: {
76+
moduleSideEffects: false
77+
}
6978
},
7079
// Browser build
7180
{
@@ -75,7 +84,10 @@ const allBuilds = [
7584
format: 'es'
7685
},
7786
plugins: [alias(util.generateAliasConfig('browser')), ...browserPlugins],
78-
external: util.resolveBrowserExterns
87+
external: util.resolveBrowserExterns,
88+
treeshake: {
89+
moduleSideEffects: false
90+
}
7991
},
8092
// RN build
8193
{
@@ -85,7 +97,10 @@ const allBuilds = [
8597
format: 'es'
8698
},
8799
plugins: [alias(util.generateAliasConfig('rn')), ...browserPlugins],
88-
external: util.resolveBrowserExterns
100+
external: util.resolveBrowserExterns,
101+
treeshake: {
102+
moduleSideEffects: false
103+
}
89104
}
90105
];
91106

packages/firestore/rollup.config.lite.js

Lines changed: 20 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ import alias from '@rollup/plugin-alias';
2121
import typescriptPlugin from 'rollup-plugin-typescript2';
2222
import typescript from 'typescript';
2323
import { terser } from 'rollup-plugin-terser';
24+
import { importPathTransformer } from '../../scripts/exp/ts-transform-import-path';
2425

2526
import pkg from './lite/package.json';
2627

@@ -35,7 +36,8 @@ const nodePlugins = [
3536
}
3637
},
3738
clean: true,
38-
transformers: util.removeAssertTransformer
39+
abortOnError: false,
40+
transformers: [util.removeAssertTransformer, importPathTransformer]
3941
}),
4042
json()
4143
];
@@ -49,7 +51,11 @@ const browserPlugins = [
4951
}
5052
},
5153
clean: true,
52-
transformers: util.removeAssertAndPrefixInternalTransformer
54+
abortOnError: false,
55+
transformers: [
56+
util.removeAssertAndPrefixInternalTransformer,
57+
importPathTransformer
58+
]
5359
}),
5460
json({ preferConst: true }),
5561
terser(util.manglePrivatePropertiesOptions)
@@ -65,7 +71,10 @@ const allBuilds = [
6571
name: 'firebase.firestore'
6672
},
6773
plugins: [alias(util.generateAliasConfig('node')), ...nodePlugins],
68-
external: util.resolveNodeExterns
74+
external: util.resolveNodeExterns,
75+
treeshake: {
76+
moduleSideEffects: false
77+
}
6978
},
7079
// Browser build
7180
{
@@ -75,7 +84,10 @@ const allBuilds = [
7584
format: 'es'
7685
},
7786
plugins: [alias(util.generateAliasConfig('browser')), ...browserPlugins],
78-
external: util.resolveBrowserExterns
87+
external: util.resolveBrowserExterns,
88+
treeshake: {
89+
moduleSideEffects: false
90+
}
7991
},
8092
// RN build
8193
{
@@ -85,7 +97,10 @@ const allBuilds = [
8597
format: 'es'
8698
},
8799
plugins: [alias(util.generateAliasConfig('rn')), ...browserPlugins],
88-
external: util.resolveBrowserExterns
100+
external: util.resolveBrowserExterns,
101+
treeshake: {
102+
moduleSideEffects: false
103+
}
89104
}
90105
];
91106

0 commit comments

Comments
 (0)