Skip to content

Commit de6464c

Browse files
committed
Upgrade Firestore Node CJS builds to es2017
1 parent ea3efa9 commit de6464c

File tree

2 files changed

+37
-105
lines changed

2 files changed

+37
-105
lines changed

packages/firestore/rollup.config.js

Lines changed: 33 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -32,43 +32,29 @@ import pkg from './package.json';
3232
const sourcemaps = require('rollup-plugin-sourcemaps');
3333
const util = require('./rollup.shared');
3434

35-
const nodePlugins = function () {
36-
return [
37-
typescriptPlugin({
38-
typescript,
39-
tsconfigOverride: {
40-
compilerOptions: {
41-
target: 'es2017'
42-
}
43-
},
44-
cacheDir: tmp.dirSync(),
45-
abortOnError: true,
46-
transformers: [util.removeAssertTransformer]
47-
}),
48-
json({ preferConst: true }),
49-
replace({
50-
'__GRPC_VERSION__': grpcVersion
51-
})
52-
];
53-
};
35+
const nodePlugins = [
36+
typescriptPlugin({
37+
typescript,
38+
cacheDir: tmp.dirSync(),
39+
abortOnError: true,
40+
transformers: [util.removeAssertTransformer]
41+
}),
42+
json({ preferConst: true }),
43+
replace({
44+
'__GRPC_VERSION__': grpcVersion
45+
})
46+
];
5447

55-
const browserPlugins = function () {
56-
return [
57-
typescriptPlugin({
58-
typescript,
59-
tsconfigOverride: {
60-
compilerOptions: {
61-
target: 'es2017'
62-
}
63-
},
64-
cacheDir: tmp.dirSync(),
65-
abortOnError: true,
66-
transformers: [util.removeAssertAndPrefixInternalTransformer]
67-
}),
68-
json({ preferConst: true }),
69-
terser(util.manglePrivatePropertiesOptions)
70-
];
71-
};
48+
const browserPlugins = [
49+
typescriptPlugin({
50+
typescript,
51+
cacheDir: tmp.dirSync(),
52+
abortOnError: true,
53+
transformers: [util.removeAssertAndPrefixInternalTransformer]
54+
}),
55+
json({ preferConst: true }),
56+
terser(util.manglePrivatePropertiesOptions)
57+
];
7258

7359
const allBuilds = [
7460
// Intermediate Node ESM build without build target reporting
@@ -97,7 +83,17 @@ const allBuilds = [
9783
sourcemap: true
9884
},
9985
plugins: [
100-
...util.es2017ToEs5Plugins(/* mangled= */ false),
86+
typescriptPlugin({
87+
typescript,
88+
tsconfigOverride: {
89+
compilerOptions: {
90+
allowJs: true
91+
}
92+
},
93+
include: ['dist/**/*.js'],
94+
cacheDir: tmp.dirSync()
95+
}),
96+
sourcemaps(),
10197
replace(generateBuildTargetReplaceConfig('cjs', 2017))
10298
],
10399
external: util.resolveNodeExterns,

packages/firestore/rollup.shared.js

Lines changed: 4 additions & 68 deletions
Original file line numberDiff line numberDiff line change
@@ -34,17 +34,17 @@ const pkg = require('./package.json');
3434
// This file contains shared utilities for Firestore's rollup builds.
3535

3636
// Firestore is released in a number of different build configurations:
37-
// - Browser builds that support persistence in ES5 CJS and ES5 ESM formats and
38-
// ES2017 in ESM format.
39-
// - In-memory Browser builds that support persistence in ES5 CJS and ES5 ESM
40-
// formats and ES2017 in ESM format.
37+
// - Browser builds that support persistence in ES2017 CJS and ESM formats.
38+
// - In-memory Browser builds that support persistence in ES2017 CJS and ESM
39+
// formats.
4140
// - A NodeJS build that supports persistence (to be used with an IndexedDb
4241
// shim)
4342
// - A in-memory only NodeJS build
4443
//
4544
// The in-memory builds are roughly 130 KB smaller, but throw an exception
4645
// for calls to `enablePersistence()` or `clearPersistence()`.
4746
//
47+
// TODO(dlarocque): Update this pipeline, since we no longer need to target ES5.
4848
// We use two different rollup pipelines to take advantage of tree shaking,
4949
// as Rollup does not support tree shaking for TypeScript classes transpiled
5050
// down to ES5 (see https://bit.ly/340P23U). The build pipeline in this file
@@ -248,11 +248,6 @@ exports.es2017Plugins = function (platform, mangled = false) {
248248
alias(generateAliasConfig(platform)),
249249
typescriptPlugin({
250250
typescript,
251-
tsconfigOverride: {
252-
compilerOptions: {
253-
target: 'es2017'
254-
}
255-
},
256251
cacheDir: tmp.dirSync(),
257252
transformers: [removeAssertAndPrefixInternalTransformer]
258253
}),
@@ -264,11 +259,6 @@ exports.es2017Plugins = function (platform, mangled = false) {
264259
alias(generateAliasConfig(platform)),
265260
typescriptPlugin({
266261
typescript,
267-
tsconfigOverride: {
268-
compilerOptions: {
269-
target: 'es2017'
270-
}
271-
},
272262
cacheDir: tmp.dirSync(),
273263
transformers: [removeAssertTransformer]
274264
}),
@@ -277,50 +267,6 @@ exports.es2017Plugins = function (platform, mangled = false) {
277267
}
278268
};
279269

280-
exports.es2017ToEs5Plugins = function (mangled = false) {
281-
if (mangled) {
282-
return [
283-
typescriptPlugin({
284-
typescript,
285-
tsconfigOverride: {
286-
compilerOptions: {
287-
allowJs: true
288-
}
289-
},
290-
include: ['dist/**/*.js'],
291-
cacheDir: tmp.dirSync()
292-
}),
293-
terser({
294-
output: {
295-
comments: 'all',
296-
beautify: true
297-
},
298-
// See comment above `manglePrivatePropertiesOptions`. This build did
299-
// not have the identical variable name issue but we should be
300-
// consistent.
301-
mangle: {
302-
reserved: ['_getProvider']
303-
}
304-
}),
305-
sourcemaps()
306-
];
307-
} else {
308-
return [
309-
typescriptPlugin({
310-
typescript,
311-
tsconfigOverride: {
312-
compilerOptions: {
313-
allowJs: true
314-
}
315-
},
316-
include: ['dist/**/*.js'],
317-
cacheDir: tmp.dirSync()
318-
}),
319-
sourcemaps()
320-
];
321-
}
322-
};
323-
324270
exports.es2017PluginsCompat = function (
325271
platform,
326272
pathTransformer,
@@ -331,11 +277,6 @@ exports.es2017PluginsCompat = function (
331277
alias(generateAliasConfig(platform)),
332278
typescriptPlugin({
333279
typescript,
334-
tsconfigOverride: {
335-
compilerOptions: {
336-
target: 'es2017'
337-
}
338-
},
339280
cacheDir: tmp.dirSync(),
340281
abortOnError: true,
341282
transformers: [
@@ -351,11 +292,6 @@ exports.es2017PluginsCompat = function (
351292
alias(generateAliasConfig(platform)),
352293
typescriptPlugin({
353294
typescript,
354-
tsconfigOverride: {
355-
compilerOptions: {
356-
target: 'es2017'
357-
}
358-
},
359295
cacheDir: tmp.dirSync(),
360296
abortOnError: true,
361297
transformers: [removeAssertTransformer, pathTransformer]

0 commit comments

Comments
 (0)