Skip to content

Firestore Standalone Build #293

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

Closed
wants to merge 2 commits into from
Closed
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
28 changes: 28 additions & 0 deletions packages/firestore/console.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
/**
* Copyright 2017 Google Inc.
*
* 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.
*/

// Local console build for
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This comment seems incomplete. Could you explain how this file works (i.e. what it plugs into, etc)?

declare var firebase;

import './src/platform_browser/browser_init';
import { Firestore } from './src/api/database';
import { configureForFirebase } from './src/platform/config';

export function registerFirestore(instance) {
configureForFirebase(instance);
}

registerFirestore(firebase);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This seems to be identical to index.ts except it expects firebase to be an existing global, but I don't think this is actually what console needs.

firebase will not exist in the console (or if it is, it isn't what we want) and we need to expose our public constructor to the console environment somewhere (see goog_module_config.ts for how we did this previously).

So unless I'm confused, this isn't going to work for console folks. If you haven't already, I'd work with the console folks to get an end-to-end solution working before sending this out before trying to get this checked in... and it would be great if you could document how the integration works somewhere (how to trigger this build, what it exposes, how console consumes it, etc.).

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Was up working with @samhorlbeck and was under the impression that FB existed and that this was all that was needed. I'll sync back up w/ him and @tstirrat.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I could be confused. As long as we have a (manual) end-to-end "build from github => integrate into console => console still works" validation, then I'll be happy. :-)

2 changes: 2 additions & 0 deletions packages/firestore/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
"version": "0.1.3",
"description": "",
"scripts": {
"build:console": "webpack",
"dev": "gulp dev",
"test": "run-p test:browser test:node",
"test:browser": "karma start --single-run",
Expand All @@ -27,6 +28,7 @@
"@types/chai": "^4.0.4",
"@types/mocha": "^2.2.44",
"@types/sinon": "^2.3.7",
"awesome-typescript-loader": "^3.3.0",
"chai": "^4.1.1",
"grpc": "^1.6.6",
"gulp": "gulpjs/gulp#4.0",
Expand Down
74 changes: 74 additions & 0 deletions packages/firestore/webpack.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
/**
* Copyright 2017 Google Inc.
*
* 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.
*/

const { CheckerPlugin } = require('awesome-typescript-loader');
const { resolve } = require('path');
const webpack = require('webpack');

const baseConfig = {
devtool: 'source-map',
entry: resolve(__dirname, 'console.ts'),
output: {
filename: 'firestore-standalone.js',
path: resolve(__dirname, 'dist')
},
module: {
loaders: [
{
test: /\.tsx?$/,
loader: 'awesome-typescript-loader'
}
]
},
plugins: [
new CheckerPlugin(),
new webpack.optimize.ModuleConcatenationPlugin(),
new webpack.optimize.UglifyJsPlugin({
sourceMap: true,
mangle: {
props: {
ignore_quoted: true,
/**
* This regex will trigger minification of subproperties that match
* any of the following use cases:
*
* - Prefixed with an underscore (i.e. _)
* - Suffixed with an underscore (i.e. _)
*
* Exceptions:
* - Double underscore prefix/suffix (we have some props that rely on
* this naming convention)
* - `_lat` (we have a property in auth that depends on this name)
*
* This will be kept up to date as this changes
*/
regex: /^_[^_][^lat]|[^_]_$/
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This regex doesn't do what you say. You probably broke the _lat property but are tests aren't sensitive enough to see it.

The first branches matches underscore followed by not underscore followed any single character that is none of "l", "a", or "t".

Better to treat _lat as a reserved keyword.

Alternatively, you can phrase this with a negative lookahead, something like:

/^(?!_lat)_[^_]|[^_]_$/

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Turns out they don't need the minification. So this will be pulled.

}
},
compress: {
passes: 3,
unsafe: true,
warnings: false
}
})
],
resolve: {
modules: ['node_modules', resolve(__dirname, '../../node_modules')],
extensions: ['.js', '.ts']
}
};

module.exports = baseConfig;
Loading