Skip to content

Commit bd2ac17

Browse files
With replace
1 parent ef5710f commit bd2ac17

File tree

1 file changed

+39
-32
lines changed

1 file changed

+39
-32
lines changed

packages/firestore/rollup.config.js

Lines changed: 39 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -102,14 +102,16 @@ export function resolveMemoryExterns(deps, externsId, referencedBy) {
102102
const es5BuildPlugins = [
103103
typescriptPlugin({
104104
typescript,
105-
tsconfigOverride: {
106-
compilerOptions: {
107-
allowJs: true
108-
}
109-
},
110-
include: ["*.js", "**/*.js"],
105+
transformers: appendPrivatePrefixTransformers,
106+
cacheRoot: `./.cache/es5.mangled/`
111107
}),
112-
sourcemaps()
108+
{
109+
transform(code, id) {
110+
return code.replace(/\/\*\* @class \*\//g, "\/*@__PURE__*\/");
111+
}
112+
},
113+
json(),
114+
terser(manglePrivatePropertiesOptions)
113115
];
114116

115117
const es2017BuildPlugins = [
@@ -120,14 +122,33 @@ const es2017BuildPlugins = [
120122
target: 'es2017'
121123
}
122124
},
123-
cacheRoot: './.cache/browser/',
125+
cacheRoot: './.cache/es2017.mangled/',
124126
transformers: appendPrivatePrefixTransformers
125127
}),
126128
json({ preferConst: true }),
127129
terser(manglePrivatePropertiesOptions)
128130
];
129131

130132
const browserBuilds = [
133+
// ES5 ESM Build (with persistence)
134+
{
135+
input: 'index.ts',
136+
output: { file: pkg.module, format: 'es', sourcemap: true },
137+
plugins: es5BuildPlugins,
138+
external: resolveBrowserExterns
139+
},
140+
// ES5 ESM Build (memory-only)
141+
{
142+
input: 'index.memory.ts',
143+
output: {
144+
file: path.resolve('./memory', memoryPkg.module),
145+
format: 'es',
146+
sourcemap: true
147+
},
148+
plugins: es5BuildPlugins,
149+
external: (id, referencedBy) =>
150+
resolveMemoryExterns(browserDeps, id, referencedBy)
151+
},
131152
// ES2017 ESM build (with persistence)
132153
{
133154
input: 'index.ts',
@@ -151,41 +172,27 @@ const browserBuilds = [
151172
external: (id, referencedBy) =>
152173
resolveMemoryExterns(browserDeps, id, referencedBy)
153174
},
154-
// ES5 ESM Build (with persistence)
155-
//
156-
// This and all following builds are based on the mangling and tree-shaking
157-
// in the ESM2017 build, since the ESM2017 build results in improved tree
158-
// shaking and property name mangling.
159-
{
160-
input: pkg.esm2017,
161-
output: { file: pkg.module, format: 'es', sourcemap: true },
162-
plugins: es5BuildPlugins
163-
},
164-
// ES5 ESM Build (memory-only)
165-
{
166-
input: path.resolve('./memory', memoryPkg.esm2017),
167-
output: {
168-
file: path.resolve('./memory', memoryPkg.module),
169-
format: 'es',
170-
sourcemap: true
171-
},
172-
plugins: es5BuildPlugins
173-
},
174175
// ES5 CJS Build (with persistence)
176+
//
177+
// This build is based on the mangling in the ESM build above, since
178+
// Terser's Property name mangling doesn't work well with CJS's syntax.
175179
{
176-
input: pkg.esm2017,
180+
input: pkg.module,
177181
output: { file: pkg.browser, format: 'cjs', sourcemap: true },
178-
plugins: es5BuildPlugins
182+
plugins: [sourcemaps()]
179183
},
180184
// ES5 CJS Build (memory-only)
185+
//
186+
// This build is based on the mangling in the ESM build above, since
187+
// Terser's Property name mangling doesn't work well with CJS's syntax.
181188
{
182-
input: path.resolve('./memory', memoryPkg.esm2017),
189+
input: path.resolve('./memory', memoryPkg.module),
183190
output: {
184191
file: path.resolve('./memory', memoryPkg.browser),
185192
format: 'cjs',
186193
sourcemap: true
187194
},
188-
plugins: es5BuildPlugins
195+
plugins: [sourcemaps()]
189196
}
190197
];
191198

0 commit comments

Comments
 (0)