Skip to content

Commit b491209

Browse files
committed
Add Firestore Lite Node CJS build with build target reporting
1 parent 0b4cb9f commit b491209

File tree

1 file changed

+47
-37
lines changed

1 file changed

+47
-37
lines changed

packages/firestore/rollup.config.lite.js

Lines changed: 47 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -30,40 +30,26 @@ import { generateBuildTargetReplaceConfig } from '../../scripts/build/rollup_rep
3030

3131
const util = require('./rollup.shared');
3232

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

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

6854
const allBuilds = [
6955
// Intermediate Node ESM build without build target reporting
@@ -78,7 +64,7 @@ const allBuilds = [
7864
},
7965
plugins: [
8066
alias(util.generateAliasConfig('node_lite')),
81-
...nodePlugins(),
67+
...nodePlugins,
8268
replace({
8369
'__RUNTIME_ENV__': 'node'
8470
})
@@ -89,7 +75,31 @@ const allBuilds = [
8975
},
9076
onwarn: util.onwarn
9177
},
92-
// TODO: Node CJS build
78+
// Node CJS build
79+
{
80+
input: path.resolve('./lite', pkg['main-esm']),
81+
output: {
82+
file: path.resolve('./lite', pkg.main),
83+
format: 'cjs',
84+
sourcemap: true
85+
},
86+
plugins: [
87+
typescriptPlugin({
88+
typescript,
89+
compilerOptions: {
90+
allowJs: true,
91+
},
92+
include: ['dist/lite/*.js']
93+
}),
94+
json(),
95+
sourcemaps(),
96+
replace(generateBuildTargetReplaceConfig('cjs', 2017))
97+
],
98+
external: util.resolveNodeExterns,
99+
treeshake: {
100+
moduleSideEffects: false
101+
}
102+
},
93103
// Node ESM build
94104
{
95105
input: path.resolve('./lite', pkg['main-esm']),
@@ -119,7 +129,7 @@ const allBuilds = [
119129
},
120130
plugins: [
121131
alias(util.generateAliasConfig('browser_lite')),
122-
...browserPlugins(),
132+
...browserPlugins,
123133
// setting it to empty string because browser is the default env
124134
replace({
125135
'__RUNTIME_ENV__': ''
@@ -178,7 +188,7 @@ const allBuilds = [
178188
},
179189
plugins: [
180190
alias(util.generateAliasConfig('rn_lite')),
181-
...browserPlugins(),
191+
...browserPlugins,
182192
replace({
183193
...generateBuildTargetReplaceConfig('esm', 2017),
184194
'__RUNTIME_ENV__': 'rn'

0 commit comments

Comments
 (0)