Skip to content

Commit 95d712f

Browse files
committed
add exp release rollup config
1 parent 97f8b10 commit 95d712f

File tree

4 files changed

+200
-6
lines changed

4 files changed

+200
-6
lines changed

packages/firestore/package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
"build:console": "node tools/console.build.js",
1616
"build:exp": "rollup -c rollup.config.exp.js",
1717
"build:lite": "rollup -c rollup.config.lite.js",
18+
"build:exp:release": "rollup -c rollup.config.exp.release.js && rollup -c rollup.config.lite.release.js",
1819
"predev": "yarn prebuild",
1920
"dev": "rollup -c -w",
2021
"lint": "eslint -c .eslintrc.js '**/*.ts' --ignore-path '../../.gitignore'",
Lines changed: 99 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,99 @@
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+
import json from 'rollup-plugin-json';
19+
import alias from '@rollup/plugin-alias';
20+
import typescriptPlugin from 'rollup-plugin-typescript2';
21+
import typescript from 'typescript';
22+
import path from 'path';
23+
import { terser } from 'rollup-plugin-terser';
24+
import { importPathTransformer } from '../../scripts/exp/ts-transform-import-path';
25+
26+
import {
27+
firestoreTransformers,
28+
generateAliasConfig,
29+
manglePrivatePropertiesOptions,
30+
resolveBrowserExterns,
31+
resolveNodeExterns
32+
} from './rollup.shared';
33+
34+
import pkg from './exp/package.json';
35+
36+
const plugins = [
37+
typescriptPlugin({
38+
typescript,
39+
tsconfigOverride: {
40+
compilerOptions: {
41+
target: 'es2017'
42+
}
43+
},
44+
clean: true,
45+
abortOnError: false
46+
}),
47+
json({ preferConst: true })
48+
];
49+
50+
const minifiedPlugins = [
51+
typescriptPlugin({
52+
typescript,
53+
tsconfigOverride: {
54+
compilerOptions: {
55+
target: 'es2017'
56+
}
57+
},
58+
clean: true,
59+
abortOnError: false,
60+
transformers: [...firestoreTransformers, importPathTransformer]
61+
}),
62+
json({ preferConst: true }),
63+
terser(manglePrivatePropertiesOptions)
64+
];
65+
66+
const allBuilds = [
67+
// Node build
68+
{
69+
input: './exp/index.ts',
70+
output: {
71+
file: path.resolve('./exp', pkg.main),
72+
format: 'es'
73+
},
74+
plugins: [alias(generateAliasConfig('node')), ...plugins],
75+
external: resolveNodeExterns
76+
},
77+
// Browser build
78+
{
79+
input: './exp/index.ts',
80+
output: {
81+
file: path.resolve('./exp', pkg.browser),
82+
format: 'es'
83+
},
84+
plugins: [alias(generateAliasConfig('browser')), ...minifiedPlugins],
85+
external: resolveBrowserExterns
86+
},
87+
// RN build
88+
{
89+
input: './exp/index.ts',
90+
output: {
91+
file: path.resolve('./exp', pkg['react-native']),
92+
format: 'es'
93+
},
94+
plugins: [alias(generateAliasConfig('rn')), ...minifiedPlugins],
95+
external: resolveBrowserExterns
96+
}
97+
];
98+
99+
export default allBuilds;
Lines changed: 99 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,99 @@
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+
import json from 'rollup-plugin-json';
19+
import alias from '@rollup/plugin-alias';
20+
import typescriptPlugin from 'rollup-plugin-typescript2';
21+
import typescript from 'typescript';
22+
import { terser } from 'rollup-plugin-terser';
23+
import { importPathTransformer } from '../../scripts/exp/ts-transform-import-path';
24+
25+
import {
26+
resolveNodeExterns,
27+
generateAliasConfig,
28+
resolveBrowserExterns,
29+
firestoreTransformers,
30+
manglePrivatePropertiesOptions
31+
} from './rollup.shared';
32+
33+
import pkg from './lite/package.json';
34+
import path from 'path';
35+
36+
const plugins = [
37+
typescriptPlugin({
38+
typescript,
39+
tsconfigOverride: {
40+
compilerOptions: {
41+
target: 'es2017'
42+
}
43+
},
44+
clean: true,
45+
abortOnError: false
46+
}),
47+
json({ preferConst: true })
48+
];
49+
50+
const minifiedPlugins = [
51+
typescriptPlugin({
52+
typescript,
53+
tsconfigOverride: {
54+
compilerOptions: {
55+
target: 'es2017'
56+
}
57+
},
58+
clean: true,
59+
abortOnError: false,
60+
transformers: [...firestoreTransformers, importPathTransformer]
61+
}),
62+
json({ preferConst: true }),
63+
terser(manglePrivatePropertiesOptions)
64+
];
65+
66+
const allBuilds = [
67+
// Node build
68+
{
69+
input: './lite/index.ts',
70+
output: {
71+
file: path.resolve('./lite', pkg.main),
72+
format: 'es'
73+
},
74+
plugins: [alias(generateAliasConfig('node')), ...plugins],
75+
external: resolveNodeExterns
76+
},
77+
// Browser build
78+
{
79+
input: './lite/index.ts',
80+
output: {
81+
file: path.resolve('./lite', pkg.browser),
82+
format: 'es'
83+
},
84+
plugins: [alias(generateAliasConfig('browser')), ...minifiedPlugins],
85+
external: resolveBrowserExterns
86+
},
87+
// RN build
88+
{
89+
input: './lite/index.ts',
90+
output: {
91+
file: path.resolve('./lite', pkg['react-native']),
92+
format: 'es'
93+
},
94+
plugins: [alias(generateAliasConfig('rn')), ...minifiedPlugins],
95+
external: resolveBrowserExterns
96+
}
97+
];
98+
99+
export default allBuilds;

scripts/exp/prepare-firestore-for-exp-release.ts

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -25,12 +25,7 @@ const packagePath = `${projectRoot}/packages/firestore`;
2525
// Prepare @firebase/firestore, so scripts/exp/release.ts can be used to release it
2626
export async function prepare() {
2727
// Build exp and lite packages
28-
await spawn('yarn', ['build:exp'], {
29-
cwd: packagePath,
30-
stdio: 'inherit'
31-
});
32-
33-
await spawn('yarn', ['build:lite'], {
28+
await spawn('yarn', ['build:exp:release'], {
3429
cwd: packagePath,
3530
stdio: 'inherit'
3631
});

0 commit comments

Comments
 (0)