Skip to content

Commit

Permalink
Update: when transforming javascript is Script, not include importing…
Browse files Browse the repository at this point in the history
… swc/helpers
  • Loading branch information
Shinyaigeek committed Jan 23, 2022
1 parent 74fcc3f commit e9bd92a
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion packages/transformers/js/core/src/lib.rs
Expand Up @@ -223,9 +223,15 @@ pub fn transform(config: Config) -> Result<TransformResult, std::io::Error> {
let should_inline_fs = config.inline_fs
&& config.source_type != SourceType::Script
&& code.contains("readFileSync");
let should_import_swc_helpers = match config.source_type {
SourceType::Module => true,
SourceType::Script => false,
};
swc_common::GLOBALS.set(&Globals::new(), || {
helpers::HELPERS.set(
&helpers::Helpers::new(/* external helpers from @swc/helpers */ true),
&helpers::Helpers::new(
/* external helpers from @swc/helpers */ should_import_swc_helpers,
),
|| {
let mut react_options = react::Options::default();
if config.is_jsx {
Expand Down

0 comments on commit e9bd92a

Please sign in to comment.