Skip to content

Commit d596caf

Browse files
De-mangle Node and CJS build
1 parent 2919c0a commit d596caf

File tree

1 file changed

+34
-21
lines changed

1 file changed

+34
-21
lines changed

packages/firestore/rollup.config.js

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

5252
const terserOptions = {
5353
output: {
54-
comments: false
54+
beautify: true
5555
},
5656
mangle: {
5757
properties: {
@@ -60,19 +60,6 @@ const terserOptions = {
6060
}
6161
};
6262

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-
7663
const es5Builds = [
7764
/**
7865
* Node.js Build
@@ -81,7 +68,11 @@ const es5Builds = [
8168
input: 'index.node.ts',
8269
output: [{ file: pkg.main, format: 'cjs', sourcemap: true }],
8370
plugins: [
84-
...es5BuildPlugins,
71+
typescriptPlugin({
72+
typescript,
73+
cacheRoot: './.cache/node.cjs/'
74+
}),
75+
json(),
8576
// Needed as we also use the *.proto files
8677
copy({
8778
assets: ['./src/protos']
@@ -96,15 +87,37 @@ const es5Builds = [
9687
)
9788
},
9889
/**
99-
* Browser Builds
90+
* Browser CJS Build
91+
*
92+
* The Browser CJS build is not mangled as Terser's property name mangling
93+
* does not work well with CommonJS-style files.
10094
*/
10195
{
10296
input: 'index.ts',
103-
output: [
104-
{ file: pkg.browser, format: 'cjs', sourcemap: true },
105-
{ file: pkg.module, format: 'es', sourcemap: true }
97+
output:{ file: pkg.browser, format: 'cjs', sourcemap: true },
98+
plugins: [
99+
typescriptPlugin({
100+
typescript,
101+
cacheRoot: './.cache/cjs/'
102+
}),
103+
json()
104+
],
105+
},
106+
/**
107+
* Browser ESM Build
108+
*/
109+
{
110+
input: 'index.ts',
111+
output: { file: pkg.module, format: 'es', sourcemap: true },
112+
plugins: [
113+
typescriptPlugin({
114+
typescript,
115+
transformers,
116+
cacheRoot: './.cache/esm/'
117+
}),
118+
json(),
119+
terser(terserOptions)
106120
],
107-
plugins: es5BuildPlugins,
108121
external: id => deps.some(dep => id === dep || id.startsWith(`${dep}/`))
109122
}
110123
];
@@ -120,7 +133,7 @@ const es2017BuildPlugins = [
120133
target: 'es2017'
121134
}
122135
},
123-
cacheRoot: './.cache/es2017.min/',
136+
cacheRoot: './.cache/esm2017/',
124137
transformers
125138
}),
126139
json({ preferConst: true }),

0 commit comments

Comments
 (0)