Skip to content

Add yarn build:debug #5432

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Sep 3, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion packages/firestore/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,14 @@
"author": "Firebase <[email protected]> (https://firebase.google.com/)",
"scripts": {
"bundle": "rollup -c",
"prebuild": "tsc --emitDeclarationOnly --declaration -p tsconfig.json; yarn api-report",
"prebuild": "yarn test:prepare && tsc --emitDeclarationOnly --declaration -p tsconfig.json; yarn api-report",
"build": "run-p build:lite build:main",
"build:release": "yarn build && yarn typings:public",
"build:scripts": "tsc -moduleResolution node --module commonjs scripts/*.ts && ls scripts/*.js | xargs -I % sh -c 'terser % -o %'",
"build:deps": "lerna run --scope @firebase/firestore --include-dependencies build",
"build:main": "rollup -c rollup.config.js",
"build:lite": "rollup -c rollup.config.lite.js",
"build:debug": "rollup -c rollup.config.debug.js",
"predev": "yarn prebuild",
"dev": "rollup -c -w",
"lint": "eslint -c .eslintrc.js '**/*.ts' --ignore-path '../../.gitignore'",
Expand Down
81 changes: 81 additions & 0 deletions packages/firestore/rollup.config.debug.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
/**
* @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.
*/

import tmp from 'tmp';
import json from '@rollup/plugin-json';
import alias from '@rollup/plugin-alias';
import typescriptPlugin from 'rollup-plugin-typescript2';
import typescript from 'typescript';

import pkg from './package.json';

// This rollup configuration creates a single non-minified build for browser
// testing. You can test code changes by running `yarn build:debug`. This
// creates the file "dist/index.esm2017.js" that you can use in your sample
// app as a replacement for
// "node_modules/@firebase/firestore/dist/index.esm2017.js".

const browserPlugins = function () {
return [
typescriptPlugin({
typescript,
tsconfigOverride: {
compilerOptions: {
target: 'es2017'
}
},
cacheDir: tmp.dirSync(),
clean: true,
abortOnError: false
}),
json({ preferConst: true })
];
};

const aliasConfig = {
entries: [
{
find: /^(.*)\/platform\/([^.\/]*)(\.ts)?$/,
replacement: `$1\/platform/browser/$2.ts`
}
]
};

const browserDeps = [
...Object.keys(Object.assign({}, pkg.peerDependencies, pkg.dependencies)),
'@firebase/app'
];

export default [
{
input: './src/index.ts',
output: {
file: pkg.browser,
format: 'es',
sourcemap: true
},
plugins: [alias(aliasConfig), ...browserPlugins()],
external: id => {
return [...browserDeps, '@firebase/firestore'].some(
dep => id === dep || id.startsWith(`${dep}/`)
);
},
treeshake: {
moduleSideEffects: false
}
}
];