Skip to content

Commit 9b91e33

Browse files
committed
chore: use explicit undefined
1 parent cc2e0ce commit 9b91e33

File tree

6 files changed

+34
-34
lines changed

6 files changed

+34
-34
lines changed

app-config-esbuild/src/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ export const createPlugin = ({
3030
if (noBundledConfig) {
3131
const { validationFunctionCode } = await loadSchema(schemaLoadingOptions);
3232

33-
const code = generateModuleText('no-config', {
33+
const code = generateModuleText(undefined, {
3434
environment: undefined,
3535
useGlobalNamespace: true,
3636
validationFunctionCode: injectValidationFunction ? validationFunctionCode : undefined,

app-config-rollup/src/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ export default function appConfigRollup({
4343
if (noBundledConfig) {
4444
const { validationFunctionCode } = await loadSchema(schemaLoadingOptions);
4545

46-
return generateModuleText('no-config', {
46+
return generateModuleText(undefined, {
4747
environment: undefined,
4848
useGlobalNamespace: true,
4949
validationFunctionCode: injectValidationFunction ? validationFunctionCode : undefined,

app-config-utils/src/__snapshots__/index.test.ts.snap

Lines changed: 28 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -6,32 +6,13 @@ exports[`generateModuleText creates config module 1`] = `
66
77
export { config };
88
export default config;
9-
9+
1010
export function currentEnvironment() {
1111
return \\"test\\";
1212
}
1313
"
1414
`;
1515

16-
exports[`generateModuleText creates config module with noBundledConfig 1`] = `
17-
"
18-
const globalNamespace = (typeof window === 'undefined' ? globalThis : window) || {};
19-
20-
const config = globalNamespace._appConfig;
21-
22-
if (typeof config === 'undefined') {
23-
throw new Error('Config is not loaded in _appConfig');
24-
}
25-
26-
export { config };
27-
export default config;
28-
29-
export function currentEnvironment() {
30-
return globalNamespace._appConfigEnvironment || \\"test\\";
31-
}
32-
"
33-
`;
34-
3516
exports[`generateModuleText creates config module with esm validation function 1`] = `
3617
"
3718
const globalNamespace = (typeof window === 'undefined' ? globalThis : window) || {};
@@ -51,19 +32,19 @@ exports[`generateModuleText creates config module with esm validation function 1
5132
5233
export { config };
5334
export default config;
54-
35+
5536
const foo = 'bar';
5637
57-
38+
5839
function genValidateConfig(){
5940
const validateConfigModule = {};
6041
(function(module){import foo from \\"bar\\";})(validateConfigModule);
6142
return validateConfigModule.exports;
6243
}
6344
64-
45+
6546
export const validateConfig = /*#__PURE__*/ genValidateConfig();
66-
47+
6748
export function currentEnvironment() {
6849
return globalNamespace._appConfigEnvironment || \\"test\\";
6950
}
@@ -89,7 +70,26 @@ exports[`generateModuleText creates config module with global namespace 1`] = `
8970
9071
export { config };
9172
export default config;
73+
74+
export function currentEnvironment() {
75+
return globalNamespace._appConfigEnvironment || \\"test\\";
76+
}
77+
"
78+
`;
79+
80+
exports[`generateModuleText creates config module with noBundledConfig 1`] = `
81+
"
82+
const globalNamespace = (typeof window === 'undefined' ? globalThis : window) || {};
83+
84+
const config = globalNamespace._appConfig;
85+
86+
if (typeof config === 'undefined') {
87+
throw new Error('Config is not loaded in _appConfig');
88+
}
9289
90+
export { config };
91+
export default config;
92+
9393
export function currentEnvironment() {
9494
return globalNamespace._appConfigEnvironment || \\"test\\";
9595
}
@@ -115,8 +115,8 @@ exports[`generateModuleText creates config module with validation function 1`] =
115115
116116
export { config };
117117
export default config;
118-
119-
118+
119+
120120
function genValidateConfig(){
121121
const validateConfigModule = {};
122122
(function(module){
@@ -125,9 +125,9 @@ exports[`generateModuleText creates config module with validation function 1`] =
125125
return validateConfigModule.exports;
126126
}
127127
128-
128+
129129
export const validateConfig = /*#__PURE__*/ genValidateConfig();
130-
130+
131131
export function currentEnvironment() {
132132
return globalNamespace._appConfigEnvironment || \\"test\\";
133133
}

app-config-utils/src/index.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ describe('generateModuleText', () => {
6161

6262
it('creates config module with noBundledConfig', () => {
6363
expect(
64-
generateModuleText('no-config', {
64+
generateModuleText(undefined, {
6565
environment: 'test',
6666
useGlobalNamespace: true,
6767
esmValidationCode: false,

app-config-utils/src/index.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ export function isPrimitive(obj: Json): obj is JsonPrimitive {
2626
}
2727

2828
export function generateModuleText(
29-
fullConfig: Json | 'no-config',
29+
fullConfig: Json | undefined,
3030
{
3131
environment,
3232
useGlobalNamespace,
@@ -45,7 +45,7 @@ export function generateModuleText(
4545

4646
let generatedText = '';
4747

48-
if (fullConfig === 'no-config') {
48+
if (fullConfig === undefined) {
4949
generatedText += `
5050
const globalNamespace = (typeof window === 'undefined' ? globalThis : window) || {};
5151

app-config-webpack/src/loader.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ const loader = function AppConfigLoader(this: Loader) {
2727
.then(({ validationFunctionCode }) => {
2828
callback(
2929
null,
30-
generateModuleText('no-config', {
30+
generateModuleText(undefined, {
3131
environment: undefined,
3232
useGlobalNamespace: true,
3333
validationFunctionCode: injectValidationFunction ? validationFunctionCode : undefined,

0 commit comments

Comments
 (0)