Skip to content

Commit fe06e91

Browse files
De-mangle Node and CJS build (#2658)
1 parent da9c2a2 commit fe06e91

File tree

2 files changed

+36
-22
lines changed

2 files changed

+36
-22
lines changed

packages/firestore/rollup.config.js

Lines changed: 35 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,8 @@ const transformers = [
5151

5252
const terserOptions = {
5353
output: {
54-
comments: false
54+
comments: "all",
55+
beautify: true
5556
},
5657
mangle: {
5758
properties: {
@@ -60,19 +61,6 @@ const terserOptions = {
6061
}
6162
};
6263

63-
/**
64-
* ES5 Builds
65-
*/
66-
const es5BuildPlugins = [
67-
typescriptPlugin({
68-
typescript,
69-
transformers,
70-
cacheRoot: './.cache/es5.min/'
71-
}),
72-
json(),
73-
terser(terserOptions)
74-
];
75-
7664
const es5Builds = [
7765
/**
7866
* Node.js Build
@@ -81,7 +69,11 @@ const es5Builds = [
8169
input: 'index.node.ts',
8270
output: [{ file: pkg.main, format: 'cjs', sourcemap: true }],
8371
plugins: [
84-
...es5BuildPlugins,
72+
typescriptPlugin({
73+
typescript,
74+
cacheRoot: './.cache/node.cjs/'
75+
}),
76+
json(),
8577
// Needed as we also use the *.proto files
8678
copy({
8779
assets: ['./src/protos']
@@ -96,15 +88,37 @@ const es5Builds = [
9688
)
9789
},
9890
/**
99-
* Browser Builds
91+
* Browser CJS Build
92+
*
93+
* The Browser CJS build is not mangled as Terser's property name mangling
94+
* does not work well with CommonJS-style files.
10095
*/
10196
{
10297
input: 'index.ts',
103-
output: [
104-
{ file: pkg.browser, format: 'cjs', sourcemap: true },
105-
{ file: pkg.module, format: 'es', sourcemap: true }
98+
output:{ file: pkg.browser, format: 'cjs', sourcemap: true },
99+
plugins: [
100+
typescriptPlugin({
101+
typescript,
102+
cacheRoot: './.cache/cjs/'
103+
}),
104+
json()
105+
],
106+
},
107+
/**
108+
* Browser ESM Build
109+
*/
110+
{
111+
input: 'index.ts',
112+
output: { file: pkg.module, format: 'es', sourcemap: true },
113+
plugins: [
114+
typescriptPlugin({
115+
typescript,
116+
transformers,
117+
cacheRoot: './.cache/esm/'
118+
}),
119+
json(),
120+
terser(terserOptions)
106121
],
107-
plugins: es5BuildPlugins,
108122
external: id => deps.some(dep => id === dep || id.startsWith(`${dep}/`))
109123
}
110124
];
@@ -120,7 +134,7 @@ const es2017BuildPlugins = [
120134
target: 'es2017'
121135
}
122136
},
123-
cacheRoot: './.cache/es2017.min/',
137+
cacheRoot: './.cache/esm2017/',
124138
transformers
125139
}),
126140
json({ preferConst: true }),

packages/firestore/src/util/api.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ export function makeConstructorPrivate<T extends Function>(
4747

4848
// Copy any static methods/members
4949
Object.assign(PublicConstructor, cls);
50-
50+
5151
// eslint-disable-next-line @typescript-eslint/no-explicit-any
5252
return PublicConstructor as any;
5353
}

0 commit comments

Comments
 (0)