Skip to content

Commit fef87c6

Browse files
committed
created testing structure
1 parent c96e1e1 commit fef87c6

File tree

17 files changed

+1576
-65
lines changed

17 files changed

+1576
-65
lines changed

packages-exp/dummy-exp/test/util.ts

Lines changed: 0 additions & 49 deletions
This file was deleted.

scripts/exp/modular-export-binary-size-analysis/test.js renamed to scripts/exp/modular-export-binary-size-analysis/.eslintrc.js

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,4 +14,13 @@
1414
* See the License for the specific language governing permissions and
1515
* limitations under the License.
1616
*/
17-
export { LogLevel } from '/Users/xuechunhou/Desktop/Google/firebase-js-sdk/packages-exp/dummy-exp/dist/index.esm2017.js';
17+
18+
module.exports = {
19+
extends: '../../config/.eslintrc.js',
20+
parserOptions: {
21+
project: 'tsconfig.json',
22+
// to make vscode-eslint work with monorepo
23+
// https://github.com/typescript-eslint/typescript-eslint/issues/251#issuecomment-463943250
24+
tsconfigRootDir: __dirname
25+
}
26+
};

scripts/exp/modular-export-binary-size-analysis/analysis-helper.ts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,6 @@ export async function extractDependenciesAndSize(
9393

9494
// Extract size of minified build
9595
const afterContent = fs.readFileSync(output, 'utf-8');
96-
//console.log(afterContent);
9796
const { code } = terser.minify(afterContent, {
9897
output: {
9998
comments: false
@@ -266,7 +265,6 @@ function isReExported(symbol: string, reExportedSymbols: string[]): boolean {
266265
}
267266

268267
function extractRealSymbolName(exportSpecifier: ts.ExportSpecifier): string {
269-
//console.log(exportSpecifier);
270268
// if property name is not null -> export is renamed
271269
if (exportSpecifier.propertyName) {
272270
return exportSpecifier.propertyName.escapedText.toString();

scripts/exp/modular-export-binary-size-analysis/analysis.ts

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -23,10 +23,7 @@ import {
2323
MemberList,
2424
ExportData
2525
} from './analysis-helper';
26-
import {
27-
mapWorkspaceToPackages,
28-
mapPkgNameToPkgPath
29-
} from '../../release/utils/workspace';
26+
import { mapWorkspaceToPackages } from '../../release/utils/workspace';
3027
import { projectRoot } from '../../utils';
3128
import { getTsBuildInfoEmitOutputFilePath } from 'typescript';
3229

@@ -129,7 +126,6 @@ async function main() {
129126
// retrieve All Modules Name
130127
const allModulesLocation = await mapWorkspaceToPackages([
131128
`${projectRoot}/packages-exp/*`
132-
// `${projectRoot}/packages/*`
133129
]);
134130
for (const moduleLocation of allModulesLocation) {
135131
// we traverse the dir in order to include binaries for submodules, e.g. @firebase/firestore/memory
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
{
2+
"extends": "../../../../../config/api-extractor.json",
3+
// Point it to your entry point d.ts file.
4+
"mainEntryPointFilePath": "<projectFolder>/dist/scripts/exp/modular-export-binary-size-analysis/test/test-exp/src/index.d.ts",
5+
"dtsRollup": {
6+
"enabled": true,
7+
"untrimmedFilePath": "<projectFolder>/dist/<unscopedPackageName>.d.ts",
8+
"publicTrimmedFilePath": "<projectFolder>/dist/<unscopedPackageName>-public.d.ts"
9+
}
10+
}
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
/**
2+
* @license
3+
* Copyright 2019 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+
const karmaBase = require('../../config/karma.base');
19+
20+
const files = ['src/**/*.test.ts'];
21+
22+
module.exports = function(config) {
23+
const karmaConfig = Object.assign({}, karmaBase, {
24+
// files to load into karma
25+
files: files,
26+
preprocessors: { '**/*.ts': ['webpack', 'sourcemap'] },
27+
// frameworks to use
28+
// available frameworks: https://npmjs.org/browse/keyword/karma-adapter
29+
frameworks: ['mocha']
30+
});
31+
32+
config.set(karmaConfig);
33+
};
34+
35+
module.exports.files = files;
Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
{
2+
"name": "@firebase/test-exp",
3+
"version": "0.0.800",
4+
"private": true,
5+
"description": "TestSizeAnalysis",
6+
"author": "Firebase <[email protected]> (https://firebase.google.com/)",
7+
"main": "dist/index.cjs.js",
8+
"browser": "dist/index.esm5.js",
9+
"module": "dist/index.esm5.js",
10+
"esm2017": "dist/index.esm2017.js",
11+
"files": [
12+
"dist"
13+
],
14+
"scripts": {
15+
"lint": "eslint -c .eslintrc.js '**/*.ts' --ignore-path '../../.gitignore'",
16+
"lint:fix": "eslint --fix -c .eslintrc.js '**/*.ts' --ignore-path '../../.gitignore'",
17+
"build": "rollup -c",
18+
"build:release": "rollup -c rollup.config.release.js && yarn api-report && yarn typings:public",
19+
"build:deps": "lerna run --scope @firebase/test-exp --include-dependencies build",
20+
"dev": "rollup -c -w",
21+
"test": "yarn type-check && run-p lint test:node",
22+
"test:ci": "node ../../scripts/run_tests_in_ci.js",
23+
"test:browser": "karma start --single-run",
24+
"test:node": "TS_NODE_COMPILER_OPTIONS='{\"module\":\"commonjs\"}' nyc --reporter lcovonly -- mocha src/**/*.test.ts --config ../../../../../config/mocharc.node.js",
25+
"type-check": "tsc -p . --noEmit",
26+
"prepare": "rollup -c rollup.config.release.js",
27+
"api-report": "api-extractor run --local --verbose",
28+
"predoc": "node ../../scripts/exp/remove-exp.js temp",
29+
"doc": "api-documenter markdown --input temp --output docs",
30+
"build:doc": "yarn build && yarn doc",
31+
"typings:public": "node ./use_public_typings.js --public",
32+
"typings:internal": "node ./use_public_typings.js"
33+
},
34+
"dependencies": {
35+
"@firebase/logger": "0.2.5",
36+
"tslib": "1.11.1",
37+
"typescript": "3.8.3"
38+
},
39+
"license": "Apache-2.0",
40+
"devDependencies": {
41+
"@rollup/plugin-alias": "3.1.1",
42+
"rollup": "1.32.1",
43+
"rollup-plugin-json": "4.0.0",
44+
"rollup-plugin-replace": "2.2.0",
45+
"rollup-plugin-typescript2": "0.27.0",
46+
"typescript": "3.8.3"
47+
},
48+
"repository": {
49+
"directory": "packages-exp/test-exp",
50+
"type": "git",
51+
"url": "https://github.com/firebase/firebase-js-sdk.git"
52+
},
53+
"bugs": {
54+
"url": "https://github.com/firebase/firebase-js-sdk/issues"
55+
},
56+
"typings": "./dist/scripts/exp/modular-export-binary-size-analysis/test/test-exp/src/index.d.ts",
57+
"nyc": {
58+
"extension": [
59+
".ts"
60+
],
61+
"reportDir": "./coverage/node"
62+
}
63+
}
Lines changed: 91 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,91 @@
1+
/**
2+
* @license
3+
* Copyright 2019 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 typescriptPlugin from 'rollup-plugin-typescript2';
19+
import typescript from 'typescript';
20+
import json from 'rollup-plugin-json';
21+
import pkg from './package.json';
22+
23+
const deps = Object.keys(
24+
Object.assign({}, pkg.peerDependencies, pkg.dependencies)
25+
);
26+
27+
/**
28+
* ES5 Builds
29+
*/
30+
const es5BuildPlugins = [
31+
typescriptPlugin({
32+
typescript
33+
}),
34+
json()
35+
];
36+
37+
const es5Builds = [
38+
/**
39+
* Browser Builds
40+
*/
41+
{
42+
input: 'src/index.ts',
43+
output: [{ file: pkg.browser, format: 'es', sourcemap: true }],
44+
plugins: es5BuildPlugins,
45+
external: id => deps.some(dep => id === dep || id.startsWith(`${dep}/`))
46+
},
47+
/**
48+
* Node.js Build
49+
*/
50+
{
51+
input: 'src/index.ts',
52+
output: [{ file: pkg.main, format: 'cjs', sourcemap: true }],
53+
plugins: es5BuildPlugins,
54+
external: id => deps.some(dep => id === dep || id.startsWith(`${dep}/`))
55+
}
56+
];
57+
58+
/**
59+
* ES2017 Builds
60+
*/
61+
const es2017BuildPlugins = [
62+
typescriptPlugin({
63+
typescript,
64+
tsconfigOverride: {
65+
compilerOptions: {
66+
target: 'es2017'
67+
}
68+
}
69+
}),
70+
json({
71+
preferConst: true
72+
})
73+
];
74+
75+
const es2017Builds = [
76+
/**
77+
* Browser Builds
78+
*/
79+
{
80+
input: 'src/index.ts',
81+
output: {
82+
file: pkg.esm2017,
83+
format: 'es',
84+
sourcemap: true
85+
},
86+
plugins: es2017BuildPlugins,
87+
external: id => deps.some(dep => id === dep || id.startsWith(`${dep}/`))
88+
}
89+
];
90+
91+
export default [...es5Builds, ...es2017Builds];

0 commit comments

Comments
 (0)