Skip to content

Commit 742dc44

Browse files
committed
fix: replace __DEV__ with process.env.NODE_ENV for environment checks
Refactor the build process to remove the custom `__DEV__` global declaration and replace it with a more standard `process.env.NODE_ENV !== 'production'` pattern. Adjusted rollup configuration accordingly.
1 parent a2a733a commit 742dc44

File tree

3 files changed

+7
-13
lines changed

3 files changed

+7
-13
lines changed

rollup.config.js

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -67,15 +67,7 @@ export default [
6767
// ESM build
6868
{
6969
input: "src/index.ts",
70-
plugins: [
71-
...basePlugins,
72-
replace({
73-
preventAssignment: true,
74-
values: {
75-
__DEV__: 'process.env.NODE_ENV !== "production"',
76-
},
77-
}),
78-
],
70+
plugins: [...basePlugins],
7971
output: {
8072
file: "dist/index.js",
8173
format: "esm",

src/index.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -59,8 +59,9 @@ interface APILibraryMap {
5959

6060
type APILibraryName = keyof APILibraryMap;
6161

62-
// The __DEV__ global variable is set by rollup during the build process.
63-
declare const __DEV__: boolean;
62+
// Development mode check - bundlers will replace process.env.NODE_ENV at build time
63+
declare const process: { env: { NODE_ENV?: string } };
64+
const __DEV__ = process.env.NODE_ENV !== 'production';
6465

6566
let setOptionsWasCalled_ = false;
6667

src/messages.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,8 +44,9 @@ export const MSG_SCRIPT_ELEMENT_EXISTS =
4444
"problems using the API. Make sure to remove the script " +
4545
"loading the API.";
4646

47-
// The __DEV__ global variable is set by rollup during the build process.
48-
declare const __DEV__: boolean;
47+
// Development mode check - bundlers will replace process.env.NODE_ENV at build time
48+
declare const process: { env: { NODE_ENV?: string } };
49+
const __DEV__ = process.env.NODE_ENV !== 'production';
4950

5051
export const logError = (message: string) => {
5152
console.error(`[@googlemaps/js-api-loader] ${message}`);

0 commit comments

Comments
 (0)