Skip to content

Commit bdfc572

Browse files
Add yarn build:debug (#5432)
1 parent d77adb1 commit bdfc572

File tree

2 files changed

+83
-1
lines changed

2 files changed

+83
-1
lines changed

packages/firestore/package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,13 +8,14 @@
88
"author": "Firebase <[email protected]> (https://firebase.google.com/)",
99
"scripts": {
1010
"bundle": "rollup -c",
11-
"prebuild": "tsc --emitDeclarationOnly --declaration -p tsconfig.json; yarn api-report",
11+
"prebuild": "yarn test:prepare && tsc --emitDeclarationOnly --declaration -p tsconfig.json; yarn api-report",
1212
"build": "run-p build:lite build:main",
1313
"build:release": "yarn build && yarn typings:public",
1414
"build:scripts": "tsc -moduleResolution node --module commonjs scripts/*.ts && ls scripts/*.js | xargs -I % sh -c 'terser % -o %'",
1515
"build:deps": "lerna run --scope @firebase/firestore --include-dependencies build",
1616
"build:main": "rollup -c rollup.config.js",
1717
"build:lite": "rollup -c rollup.config.lite.js",
18+
"build:debug": "rollup -c rollup.config.debug.js",
1819
"predev": "yarn prebuild",
1920
"dev": "rollup -c -w",
2021
"lint": "eslint -c .eslintrc.js '**/*.ts' --ignore-path '../../.gitignore'",
Lines changed: 81 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,81 @@
1+
/**
2+
* @license
3+
* Copyright 2021 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+
import tmp from 'tmp';
19+
import json from '@rollup/plugin-json';
20+
import alias from '@rollup/plugin-alias';
21+
import typescriptPlugin from 'rollup-plugin-typescript2';
22+
import typescript from 'typescript';
23+
24+
import pkg from './package.json';
25+
26+
// This rollup configuration creates a single non-minified build for browser
27+
// testing. You can test code changes by running `yarn build:debug`. This
28+
// creates the file "dist/index.esm2017.js" that you can use in your sample
29+
// app as a replacement for
30+
// "node_modules/@firebase/firestore/dist/index.esm2017.js".
31+
32+
const browserPlugins = function () {
33+
return [
34+
typescriptPlugin({
35+
typescript,
36+
tsconfigOverride: {
37+
compilerOptions: {
38+
target: 'es2017'
39+
}
40+
},
41+
cacheDir: tmp.dirSync(),
42+
clean: true,
43+
abortOnError: false
44+
}),
45+
json({ preferConst: true })
46+
];
47+
};
48+
49+
const aliasConfig = {
50+
entries: [
51+
{
52+
find: /^(.*)\/platform\/([^.\/]*)(\.ts)?$/,
53+
replacement: `$1\/platform/browser/$2.ts`
54+
}
55+
]
56+
};
57+
58+
const browserDeps = [
59+
...Object.keys(Object.assign({}, pkg.peerDependencies, pkg.dependencies)),
60+
'@firebase/app'
61+
];
62+
63+
export default [
64+
{
65+
input: './src/index.ts',
66+
output: {
67+
file: pkg.browser,
68+
format: 'es',
69+
sourcemap: true
70+
},
71+
plugins: [alias(aliasConfig), ...browserPlugins()],
72+
external: id => {
73+
return [...browserDeps, '@firebase/firestore'].some(
74+
dep => id === dep || id.startsWith(`${dep}/`)
75+
);
76+
},
77+
treeshake: {
78+
moduleSideEffects: false
79+
}
80+
}
81+
];

0 commit comments

Comments
 (0)