Skip to content

Commit 29ad0b2

Browse files
committed
add release build for auth-exp
1 parent 572cc77 commit 29ad0b2

File tree

4 files changed

+197
-134
lines changed

4 files changed

+197
-134
lines changed

packages-exp/auth-exp/package.json

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
"lint:fix": "eslint --fix -c .eslintrc.js '**/*.ts' --ignore-path '../../.gitignore'",
1919
"build": "rollup -c",
2020
"build:deps": "lerna run --scope @firebase/auth-exp --include-dependencies build",
21-
"build:release": "rollup -c rollup.config.release.js && yarn api-report && yarn typings:public",
21+
"build:release": "rollup -c rollup.config.release.js",
2222
"dev": "rollup -c -w",
2323
"test": "run-p lint test:all",
2424
"test:all": "run-p test:browser test:node",
@@ -29,9 +29,7 @@
2929
"test:browser:debug": "karma start --auto-watch",
3030
"test:browser:unit:debug": "karma start --auto-watch --unit",
3131
"test:node": "TS_NODE_COMPILER_OPTIONS='{\"module\":\"commonjs\"}' nyc --reporter lcovonly -- mocha 'src/!(platform_browser|platform_react_native)/**/*.test.ts' --file index.node.ts --config ../../config/mocharc.node.js",
32-
"prepare": "yarn build",
33-
"typings:public": "node ./use_typings.js --public",
34-
"typings:internal": "node ./use_typings.js"
32+
"prepare": "rollup -c rollup.config.release.js"
3533
},
3634
"peerDependencies": {
3735
"@firebase/app-exp": "0.x",

packages-exp/auth-exp/rollup.config.js

Lines changed: 2 additions & 130 deletions
Original file line numberDiff line numberDiff line change
@@ -15,134 +15,6 @@
1515
* limitations under the License.
1616
*/
1717

18-
import strip from '@rollup/plugin-strip';
19-
import typescriptPlugin from 'rollup-plugin-typescript2';
20-
import json from 'rollup-plugin-json';
21-
import typescript from 'typescript';
22-
import pkg from './package.json';
18+
import { getConfig } from './rollup.config.shared';
2319

24-
const deps = Object.keys(
25-
Object.assign({}, pkg.peerDependencies, pkg.dependencies)
26-
);
27-
28-
/**
29-
* Common plugins for all builds
30-
*/
31-
const commonPlugins = [
32-
json(),
33-
strip({
34-
functions: ['debugAssert.*']
35-
})
36-
];
37-
38-
/**
39-
* ES5 Builds
40-
*/
41-
const es5BuildPlugins = [
42-
...commonPlugins,
43-
typescriptPlugin({
44-
typescript
45-
})
46-
];
47-
48-
const es5Builds = [
49-
/**
50-
* Browser Builds
51-
*/
52-
{
53-
input: {
54-
index: 'index.ts',
55-
internal: 'internal/index.ts'
56-
},
57-
output: [{ dir: 'dist/esm5', format: 'esm', sourcemap: true }],
58-
plugins: es5BuildPlugins,
59-
external: id => deps.some(dep => id === dep || id.startsWith(`${dep}/`))
60-
},
61-
/**
62-
* Web Worker Build (compiled without DOM)
63-
*/
64-
{
65-
input: 'index.webworker.ts',
66-
output: [{ file: pkg.webworker, format: 'es', sourcemap: true }],
67-
plugins: [
68-
...commonPlugins,
69-
typescriptPlugin({
70-
typescript,
71-
tsconfigOverride: {
72-
compilerOptions: {
73-
lib: [
74-
// Remove dom after we figure out why navigator stuff doesn't exist
75-
'dom',
76-
'es2015',
77-
'webworker'
78-
]
79-
}
80-
}
81-
})
82-
],
83-
external: id => deps.some(dep => id === dep || id.startsWith(`${dep}/`))
84-
},
85-
/**
86-
* Node.js Build
87-
*/
88-
{
89-
input: {
90-
index: 'index.node.ts',
91-
internal: 'internal/index.ts'
92-
},
93-
output: [{ dir: 'dist/node', format: 'cjs', sourcemap: true }],
94-
plugins: es5BuildPlugins,
95-
external: id => deps.some(dep => id === dep || id.startsWith(`${dep}/`))
96-
},
97-
/**
98-
* React Native Builds
99-
*/
100-
{
101-
input: {
102-
index: 'index.rn.ts',
103-
internal: 'internal/index.ts'
104-
},
105-
output: [{ dir: 'dist/rn', format: 'cjs', sourcemap: true }],
106-
plugins: es5BuildPlugins,
107-
external: id =>
108-
[...deps, 'react-native'].some(
109-
dep => id === dep || id.startsWith(`${dep}/`)
110-
)
111-
}
112-
];
113-
114-
/**
115-
* ES2017 Builds
116-
*/
117-
const es2017BuildPlugins = [
118-
...commonPlugins,
119-
typescriptPlugin({
120-
typescript,
121-
tsconfigOverride: {
122-
compilerOptions: {
123-
target: 'es2017'
124-
}
125-
}
126-
})
127-
];
128-
129-
const es2017Builds = [
130-
/**
131-
* Browser Builds
132-
*/
133-
{
134-
input: {
135-
index: 'index.ts',
136-
internal: 'internal/index.ts'
137-
},
138-
output: {
139-
dir: 'dist/esm2017',
140-
format: 'es',
141-
sourcemap: true
142-
},
143-
plugins: es2017BuildPlugins,
144-
external: id => deps.some(dep => id === dep || id.startsWith(`${dep}/`))
145-
}
146-
];
147-
148-
export default [...es5Builds, ...es2017Builds];
20+
export default getConfig({ isReleaseBuild: false });
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
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 { getConfig } from './rollup.config.shared';
19+
20+
export default getConfig({ isReleaseBuild: true });
Lines changed: 173 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,173 @@
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 strip from '@rollup/plugin-strip';
19+
import typescriptPlugin from 'rollup-plugin-typescript2';
20+
import json from 'rollup-plugin-json';
21+
import typescript from 'typescript';
22+
import pkg from './package.json';
23+
import { importPathTransformer } from '../../scripts/exp/ts-transform-import-path';
24+
25+
const deps = Object.keys(
26+
Object.assign({}, pkg.peerDependencies, pkg.dependencies)
27+
);
28+
29+
/**
30+
* Common plugins for all builds
31+
*/
32+
const commonPlugins = [
33+
json(),
34+
strip({
35+
functions: ['debugAssert.*']
36+
})
37+
];
38+
39+
export function getConfig({ isReleaseBuild }) {
40+
/**
41+
* ES5 Builds
42+
*/
43+
const es5BuildPlugins = [
44+
...commonPlugins,
45+
getTypesScriptPlugin({ isReleaseBuild })
46+
];
47+
48+
const es5Builds = [
49+
/**
50+
* Browser Builds
51+
*/
52+
{
53+
input: {
54+
index: 'index.ts',
55+
internal: 'internal/index.ts'
56+
},
57+
output: [{ dir: 'dist/esm5', format: 'esm', sourcemap: true }],
58+
plugins: es5BuildPlugins,
59+
external: id => deps.some(dep => id === dep || id.startsWith(`${dep}/`))
60+
},
61+
/**
62+
* Web Worker Build (compiled without DOM)
63+
*/
64+
{
65+
input: 'index.webworker.ts',
66+
output: [{ file: pkg.webworker, format: 'es', sourcemap: true }],
67+
plugins: [
68+
...commonPlugins,
69+
typescriptPlugin({
70+
typescript,
71+
tsconfigOverride: {
72+
compilerOptions: {
73+
lib: [
74+
// Remove dom after we figure out why navigator stuff doesn't exist
75+
'dom',
76+
'es2015',
77+
'webworker'
78+
]
79+
}
80+
}
81+
})
82+
],
83+
external: id => deps.some(dep => id === dep || id.startsWith(`${dep}/`))
84+
},
85+
/**
86+
* Node.js Build
87+
*/
88+
{
89+
input: {
90+
index: 'index.node.ts',
91+
internal: 'internal/index.ts'
92+
},
93+
output: [{ dir: 'dist/node', format: 'cjs', sourcemap: true }],
94+
plugins: es5BuildPlugins,
95+
external: id => deps.some(dep => id === dep || id.startsWith(`${dep}/`))
96+
},
97+
/**
98+
* React Native Builds
99+
*/
100+
{
101+
input: {
102+
index: 'index.rn.ts',
103+
internal: 'internal/index.ts'
104+
},
105+
output: [{ dir: 'dist/rn', format: 'cjs', sourcemap: true }],
106+
plugins: es5BuildPlugins,
107+
external: id =>
108+
[...deps, 'react-native'].some(
109+
dep => id === dep || id.startsWith(`${dep}/`)
110+
)
111+
}
112+
];
113+
114+
/**
115+
* ES2017 Builds
116+
*/
117+
const es2017BuildPlugins = [
118+
...commonPlugins,
119+
getTypesScriptPlugin({ isReleaseBuild, target: 'es2017' })
120+
];
121+
122+
const es2017Builds = [
123+
/**
124+
* Browser Builds
125+
*/
126+
{
127+
input: {
128+
index: 'index.ts',
129+
internal: 'internal/index.ts'
130+
},
131+
output: {
132+
dir: 'dist/esm2017',
133+
format: 'es',
134+
sourcemap: true
135+
},
136+
plugins: es2017BuildPlugins,
137+
external: id => deps.some(dep => id === dep || id.startsWith(`${dep}/`))
138+
}
139+
];
140+
141+
const allBuilds = [...es5Builds, ...es2017Builds];
142+
143+
if (isReleaseBuild) {
144+
for (const build of allBuilds) {
145+
build.treeshake = {
146+
moduleSideEffects: false
147+
};
148+
}
149+
}
150+
151+
return allBuilds;
152+
}
153+
154+
function getTypesScriptPlugin({ target = 'es5', isReleaseBuild }) {
155+
let options = {
156+
typescript,
157+
tsconfigOverride: {
158+
compilerOptions: {
159+
target
160+
}
161+
}
162+
};
163+
164+
if (isReleaseBuild) {
165+
options = {
166+
...options,
167+
clean: true,
168+
transformers: [importPathTransformer]
169+
};
170+
}
171+
172+
return typescriptPlugin(options);
173+
}

0 commit comments

Comments
 (0)