Skip to content

Commit 7955cc8

Browse files
committed
No seperate export, better naming
1 parent 10f959b commit 7955cc8

File tree

5 files changed

+28
-28
lines changed

5 files changed

+28
-28
lines changed

packages/util/package.json

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -19,11 +19,6 @@
1919
},
2020
"default": "./dist/index.esm2017.js"
2121
},
22-
"./autoinit_env": {
23-
"require": "./dist/autoinit_env.js",
24-
"import": "./dist/autoinit_env.mjs",
25-
"default": "./dist/autoinit_env.mjs"
26-
},
2722
"./package.json": "./package.json"
2823
},
2924
"files": [

packages/util/postinstall.js

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -132,15 +132,15 @@ getPartialConfig()
132132

133133
await Promise.all([
134134
writeFile(
135-
join(__dirname, 'dist', 'autoinit_env.js'),
135+
join(__dirname, 'dist', 'postinstall.js'),
136136
`'use strict';
137137
Object.defineProperty(exports, '__esModule', { value: true });
138-
exports.postinstallDefaults = ${JSON.stringify(defaults)};`
138+
exports.getDefaultsFromPostinstall = () => (${JSON.stringify(defaults)});`
139139
),
140140
writeFile(
141-
join(__dirname, 'dist', 'autoinit_env.mjs'),
142-
`const postinstallDefaults = ${JSON.stringify(defaults)};
143-
export { postinstallDefaults };`
141+
join(__dirname, 'dist', 'postinstall.mjs'),
142+
`const getDefaultsFromPostinstall = () => (${JSON.stringify(defaults)});
143+
export { getDefaultsFromPostinstall };`
144144
)
145145
]);
146146

packages/util/rollup.config.js

Lines changed: 20 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -23,17 +23,18 @@ import { emitModulePackageFile } from '../../scripts/build/rollup_emit_module_pa
2323

2424
const deps = [
2525
...Object.keys(Object.assign({}, pkg.peerDependencies, pkg.dependencies)),
26-
'./autoinit_env'
26+
'./postinstall'
2727
];
2828

29-
const buildPlugins = [
30-
typescriptPlugin({ typescript }),
31-
replacePlugin({
32-
'./src/autoinit_env': '"@firebase/util/autoinit_env"',
29+
const buildPlugins = [typescriptPlugin({ typescript })];
30+
31+
function replaceSrcPostinstallWith(path) {
32+
return replacePlugin({
33+
'./src/postinstall': `'${path}'`,
3334
delimiters: ["'", "'"],
3435
preventAssignment: true
35-
})
36-
];
36+
});
37+
}
3738

3839
const browserBuilds = [
3940
{
@@ -43,7 +44,7 @@ const browserBuilds = [
4344
format: 'es',
4445
sourcemap: true
4546
},
46-
plugins: buildPlugins,
47+
plugins: [...buildPlugins, replaceSrcPostinstallWith('./postinstall.mjs')],
4748
external: id => deps.some(dep => id === dep || id.startsWith(`${dep}/`))
4849
},
4950
{
@@ -53,7 +54,7 @@ const browserBuilds = [
5354
format: 'cjs',
5455
sourcemap: true
5556
},
56-
plugins: buildPlugins,
57+
plugins: [...buildPlugins, replaceSrcPostinstallWith('./postinstall.js')],
5758
external: id => deps.some(dep => id === dep || id.startsWith(`${dep}/`))
5859
}
5960
];
@@ -66,7 +67,7 @@ const nodeBuilds = [
6667
format: 'cjs',
6768
sourcemap: true
6869
},
69-
plugins: buildPlugins,
70+
plugins: [...buildPlugins, replaceSrcPostinstallWith('./postinstall.js')],
7071
external: id => deps.some(dep => id === dep || id.startsWith(`${dep}/`))
7172
},
7273
{
@@ -76,24 +77,28 @@ const nodeBuilds = [
7677
format: 'es',
7778
sourcemap: true
7879
},
79-
plugins: [...buildPlugins, emitModulePackageFile()],
80+
plugins: [
81+
...buildPlugins,
82+
emitModulePackageFile(),
83+
replaceSrcPostinstallWith('../postinstall.mjs')
84+
],
8085
external: id => deps.some(dep => id === dep || id.startsWith(`${dep}/`))
8186
}
8287
];
8388

8489
const autoinitBuild = [
8590
{
86-
input: './src/autoinit_env.ts',
91+
input: './src/postinstall.ts',
8792
output: {
88-
file: './dist/autoinit_env.js',
93+
file: './dist/postinstall.js',
8994
format: 'cjs'
9095
},
9196
plugins: buildPlugins
9297
},
9398
{
94-
input: './src/autoinit_env.ts',
99+
input: './src/postinstall.ts',
95100
output: {
96-
file: './dist/autoinit_env.mjs',
101+
file: './dist/postinstall.mjs',
97102
format: 'es'
98103
},
99104
plugins: buildPlugins

packages/util/src/defaults.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717

1818
import { base64Decode } from './crypt';
1919
import { getGlobal } from './global';
20-
import { postinstallDefaults } from './autoinit_env';
20+
import { getDefaultsFromPostinstall } from './postinstall';
2121

2222
/**
2323
* Keys for experimental properties on the `FirebaseDefaults` object.
@@ -101,7 +101,7 @@ const getDefaultsFromCookie = (): FirebaseDefaults | undefined => {
101101
export const getDefaults = (): FirebaseDefaults | undefined => {
102102
try {
103103
return (
104-
postinstallDefaults ||
104+
getDefaultsFromPostinstall() ||
105105
getDefaultsFromGlobal() ||
106106
getDefaultsFromEnvVariable() ||
107107
getDefaultsFromCookie()

packages/util/src/autoinit_env.ts renamed to packages/util/src/postinstall.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,4 +18,4 @@
1818
import type { FirebaseDefaults } from './defaults';
1919

2020
// This value is retrieved and hardcoded by the NPM postinstall script
21-
export const postinstallDefaults: FirebaseDefaults | undefined = undefined;
21+
export const getDefaultsFromPostinstall: () => FirebaseDefaults | undefined = () => undefined;

0 commit comments

Comments
 (0)