Skip to content

Commit 0347d90

Browse files
authored
disable environment variable replacing in library builds (#10102)
1 parent 9d47995 commit 0347d90

File tree

2 files changed

+9
-2
lines changed

2 files changed

+9
-2
lines changed

packages/core/test-utils/src/utils.js

+7
Original file line numberDiff line numberDiff line change
@@ -788,6 +788,13 @@ function prepareBrowserContext(
788788
globals,
789789
);
790790

791+
if (bundle.env.isLibrary) {
792+
ctx.process = {
793+
browser: true,
794+
env: {},
795+
};
796+
}
797+
791798
ctx.window = ctx.self = ctx;
792799
return {ctx, promises};
793800
}

packages/transformers/js/core/src/lib.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -182,7 +182,7 @@ impl Config {
182182
}
183183

184184
fn insert_node_globals(&self) -> bool {
185-
!self.is_node() && self.source_type != SourceType::Script
185+
!self.is_node() && self.source_type != SourceType::Script && !self.is_library
186186
}
187187

188188
fn replace_env(&self) -> bool {
@@ -502,7 +502,7 @@ pub fn transform(
502502
diagnostics: &mut diagnostics,
503503
unresolved_mark,
504504
},
505-
config.source_type != SourceType::Script,
505+
config.source_type != SourceType::Script && !config.is_library,
506506
),
507507
paren_remover(Some(&comments)),
508508
// Simplify expressions and remove dead branches so that we

0 commit comments

Comments
 (0)