Unverified Commit 2f3e77f5 authored by Niklas Mischkulnig's avatar Niklas Mischkulnig Committed by GitHub

Turbopack: analyze mode tracing imports only (#98825)

We had 3 modes, now we just have 2 boolean for all possible 2*2 = 4
modes
parent 812c88f3
...@@ -404,7 +404,7 @@ pub async fn get_client_module_options_context( ...@@ -404,7 +404,7 @@ pub async fn get_client_module_options_context(
.await?, .await?,
), ),
keep_last_successful_parse: next_mode.is_development(), keep_last_successful_parse: next_mode.is_development(),
analyze_mode: AnalyzeMode::CodeGeneration, analyze_mode: AnalyzeMode::code_generation(),
..Default::default() ..Default::default()
}; };
......
...@@ -573,9 +573,9 @@ pub async fn get_server_module_options_context( ...@@ -573,9 +573,9 @@ pub async fn get_server_module_options_context(
.await?, .await?,
), ),
analyze_mode: if enable_tracing { analyze_mode: if enable_tracing {
AnalyzeMode::CodeGenerationAndTracing AnalyzeMode::code_generation_and_tracing()
} else { } else {
AnalyzeMode::CodeGeneration AnalyzeMode::code_generation()
}, },
enable_externals_tracing: if enable_tracing { enable_externals_tracing: if enable_tracing {
Some( Some(
......
...@@ -82,7 +82,7 @@ pub fn benchmark(c: &mut Criterion) { ...@@ -82,7 +82,7 @@ pub fn benchmark(c: &mut Criterion) {
arena.get_or_default(), arena.get_or_default(),
&program, &program,
&eval_context, &eval_context,
AnalyzeMode::CodeGenerationAndTracing, AnalyzeMode::code_generation_and_tracing(),
true, true,
SpecifiedModuleType::Automatic, SpecifiedModuleType::Automatic,
true, true,
...@@ -121,7 +121,7 @@ fn bench_create_graph(b: &mut Bencher, input: &BenchInput) { ...@@ -121,7 +121,7 @@ fn bench_create_graph(b: &mut Bencher, input: &BenchInput) {
arena.get_or_default(), arena.get_or_default(),
&input.program, &input.program,
&input.eval_context, &input.eval_context,
AnalyzeMode::CodeGenerationAndTracing, AnalyzeMode::code_generation_and_tracing(),
true, true,
SpecifiedModuleType::Automatic, SpecifiedModuleType::Automatic,
true, true,
......
...@@ -52,9 +52,9 @@ pub fn benchmark(c: &mut Criterion) { ...@@ -52,9 +52,9 @@ pub fn benchmark(c: &mut Criterion) {
root_dir, root_dir,
file, file,
analyze_mode: if trace_only { analyze_mode: if trace_only {
AnalyzeMode::Tracing AnalyzeMode::tracing()
} else { } else {
AnalyzeMode::CodeGenerationAndTracing AnalyzeMode::code_generation_and_tracing()
}, },
}, },
bench_full, bench_full,
...@@ -89,7 +89,7 @@ async fn setup( ...@@ -89,7 +89,7 @@ async fn setup(
ResolvedVc::upcast(module_asset_context), ResolvedVc::upcast(module_asset_context),
EcmascriptInputTransforms::empty().to_resolved().await?, EcmascriptInputTransforms::empty().to_resolved().await?,
EcmascriptOptions { EcmascriptOptions {
follow_reexports: analyze_mode != AnalyzeMode::Tracing, follow_reexports: analyze_mode.is_codegen,
module_fragments_enabled: false, module_fragments_enabled: false,
analyze_mode, analyze_mode,
..Default::default() ..Default::default()
......
...@@ -95,13 +95,13 @@ pub fn create_graph<'a>( ...@@ -95,13 +95,13 @@ pub fn create_graph<'a>(
// CommonJS export recognition runs for a CommonJS module that emits code when either CJS // CommonJS export recognition runs for a CommonJS module that emits code when either CJS
// tree-shaking or CJS scope hoisting is enabled (both consume the static export analysis). // tree-shaking or CJS scope hoisting is enabled (both consume the static export analysis).
if (cjs_tree_shaking || cjs_scope_hoisting) if (cjs_tree_shaking || cjs_scope_hoisting)
&& analyze_mode.is_code_gen() && analyze_mode.is_codegen
&& eval_context.is_cjs(specified_module_type) && eval_context.is_cjs(specified_module_type)
{ {
analyzer.enable_cjs_exports(); analyzer.enable_cjs_exports();
} }
if cjs_tree_shaking && analyze_mode.is_code_gen() { if cjs_tree_shaking && analyze_mode.is_codegen {
analyzer.enable_require_usage(&eval_context.imports); analyzer.enable_require_usage(&eval_context.imports);
} }
......
...@@ -486,7 +486,7 @@ mod analyzer_state { ...@@ -486,7 +486,7 @@ mod analyzer_state {
start_ast_path, start_ast_path,
} => { } => {
self.effects = prev_effects; self.effects = prev_effects;
if self.analyze_mode.is_code_gen() { if self.analyze_mode.is_codegen {
self.effects self.effects
.push(self.arena, Effect::Unreachable { start_ast_path }); .push(self.arena, Effect::Unreachable { start_ast_path });
} }
...@@ -1444,7 +1444,7 @@ impl<'a> Analyzer<'a, '_> { ...@@ -1444,7 +1444,7 @@ impl<'a> Analyzer<'a, '_> {
} }
fn add_esm_module_item(&mut self, ast_path: &AstNodePath<AstParentNodeRef<'_>>) { fn add_esm_module_item(&mut self, ast_path: &AstNodePath<AstParentNodeRef<'_>>) {
if self.analyze_mode.is_code_gen() { if self.analyze_mode.is_codegen {
let path = self.ast_paths.intern(ast_path.kinds().iter().copied()); let path = self.ast_paths.intern(ast_path.kinds().iter().copied());
self.code_gens self.code_gens
.push(EsmModuleItem::new(path, self.supports_block_scoping).into()); .push(EsmModuleItem::new(path, self.supports_block_scoping).into());
...@@ -2484,7 +2484,7 @@ impl VisitAstPath for Analyzer<'_, '_> { ...@@ -2484,7 +2484,7 @@ impl VisitAstPath for Analyzer<'_, '_> {
} }
// If this identifier is free, produce an effect so we can potentially replace it later. // If this identifier is free, produce an effect so we can potentially replace it later.
if self.analyze_mode.is_code_gen() if self.analyze_mode.is_codegen
&& let JsValue::FreeVar(var) = self.eval_context.eval_id(self.arena, ident.to_id()) && let JsValue::FreeVar(var) = self.eval_context.eval_id(self.arena, ident.to_id())
{ {
// TODO(lukesandberg): we should consider filtering effects here, e.g. there is no // TODO(lukesandberg): we should consider filtering effects here, e.g. there is no
...@@ -2502,7 +2502,7 @@ impl VisitAstPath for Analyzer<'_, '_> { ...@@ -2502,7 +2502,7 @@ impl VisitAstPath for Analyzer<'_, '_> {
node: &'ast ThisExpr, node: &'ast ThisExpr,
ast_path: &mut swc_core::ecma::visit::AstNodePath<'r>, ast_path: &mut swc_core::ecma::visit::AstNodePath<'r>,
) { ) {
if !self.analyze_mode.is_code_gen() { if !self.analyze_mode.is_codegen {
return; return;
} }
...@@ -2550,7 +2550,7 @@ impl VisitAstPath for Analyzer<'_, '_> { ...@@ -2550,7 +2550,7 @@ impl VisitAstPath for Analyzer<'_, '_> {
expr: &'ast MetaPropExpr, expr: &'ast MetaPropExpr,
ast_path: &mut AstNodePath<AstParentNodeRef<'r>>, ast_path: &mut AstNodePath<AstParentNodeRef<'r>>,
) { ) {
if self.analyze_mode.is_code_gen() && expr.kind == MetaPropKind::ImportMeta { if self.analyze_mode.is_codegen && expr.kind == MetaPropKind::ImportMeta {
// MetaPropExpr also covers `new.target`. Only consider `import.meta` // MetaPropExpr also covers `new.target`. Only consider `import.meta`
// an effect. // an effect.
self.add_effect(Effect::ImportMeta { self.add_effect(Effect::ImportMeta {
...@@ -2801,7 +2801,7 @@ impl VisitAstPath for Analyzer<'_, '_> { ...@@ -2801,7 +2801,7 @@ impl VisitAstPath for Analyzer<'_, '_> {
n: &'ast UnaryExpr, n: &'ast UnaryExpr,
ast_path: &mut swc_core::ecma::visit::AstNodePath<'r>, ast_path: &mut swc_core::ecma::visit::AstNodePath<'r>,
) { ) {
if n.op == UnaryOp::TypeOf && self.analyze_mode.is_code_gen() { if n.op == UnaryOp::TypeOf && self.analyze_mode.is_codegen {
let arg_value = BumpBox::new_in(self.eval_context.eval(self.arena, &n.arg), self.arena); let arg_value = BumpBox::new_in(self.eval_context.eval(self.arena, &n.arg), self.arena);
self.add_effect(Effect::TypeOf { self.add_effect(Effect::TypeOf {
......
...@@ -364,7 +364,7 @@ mod tests { ...@@ -364,7 +364,7 @@ mod tests {
arena.get_or_default(), arena.get_or_default(),
&m, &m,
&eval_context, &eval_context,
AnalyzeMode::CodeGenerationAndTracing, AnalyzeMode::code_generation_and_tracing(),
true, true,
SpecifiedModuleType::EcmaScript, SpecifiedModuleType::EcmaScript,
true, true,
......
...@@ -164,35 +164,50 @@ pub enum SpecifiedModuleType { ...@@ -164,35 +164,50 @@ pub enum SpecifiedModuleType {
Debug, Debug,
Clone, Clone,
Copy, Copy,
Default,
Deserialize, Deserialize,
TraceRawVcs, TraceRawVcs,
Encode, Encode,
Decode, Decode,
)] )]
pub enum AnalyzeMode { pub struct AnalyzeMode {
/// For bundling only, no tracing of referenced files. /// Whether code generation will be performed after analyzing.
#[default] pub is_codegen: bool,
CodeGeneration, /// Whether references to external files should be traced.
/// For bundling and finding references to external referenced files pub trace_file_references: bool,
CodeGenerationAndTracing, }
/// For tracing transitive external references (i.e. no codegen).
Tracing, impl Default for AnalyzeMode {
fn default() -> Self {
Self::code_generation()
}
} }
impl AnalyzeMode { impl AnalyzeMode {
/// Are we currently collecting references to external assets. e.g. filesystem dependencies pub const fn code_generation() -> Self {
pub fn is_tracing_assets(self) -> bool { Self {
match self { is_codegen: true,
AnalyzeMode::Tracing | AnalyzeMode::CodeGenerationAndTracing => true, trace_file_references: false,
AnalyzeMode::CodeGeneration => false,
} }
} }
pub fn is_code_gen(self) -> bool { pub const fn code_generation_and_tracing() -> Self {
match self { Self {
AnalyzeMode::CodeGeneration | AnalyzeMode::CodeGenerationAndTracing => true, is_codegen: true,
AnalyzeMode::Tracing => false, trace_file_references: true,
}
}
pub const fn tracing_import_only() -> Self {
Self {
is_codegen: false,
trace_file_references: false,
}
}
pub const fn tracing() -> Self {
Self {
is_codegen: false,
trace_file_references: true,
} }
} }
} }
...@@ -856,7 +871,9 @@ impl EcmascriptModuleAsset { ...@@ -856,7 +871,9 @@ impl EcmascriptModuleAsset {
self.ty, self.ty,
*self.transforms, *self.transforms,
node_env, node_env,
options.analyze_mode == AnalyzeMode::Tracing, // When not codegen-ing at all, turn string encoding and AST parsing issues into
// warnings instead.
!options.analyze_mode.is_codegen,
options.inline_helpers, options.inline_helpers,
)) ))
} }
......
...@@ -280,7 +280,7 @@ pub async fn parse( ...@@ -280,7 +280,7 @@ pub async fn parse(
ty: EcmascriptModuleAssetType, ty: EcmascriptModuleAssetType,
transforms: ResolvedVc<EcmascriptInputTransforms>, transforms: ResolvedVc<EcmascriptInputTransforms>,
node_env: RcStr, node_env: RcStr,
is_external_tracing: bool, loose_errors: bool,
inline_helpers: bool, inline_helpers: bool,
) -> Result<Vc<ParseResult>> { ) -> Result<Vc<ParseResult>> {
let span = tracing::info_span!( let span = tracing::info_span!(
...@@ -294,7 +294,7 @@ pub async fn parse( ...@@ -294,7 +294,7 @@ pub async fn parse(
ty, ty,
transforms, transforms,
node_env, node_env,
is_external_tracing, loose_errors,
inline_helpers, inline_helpers,
) )
.instrument(span) .instrument(span)
......
...@@ -228,7 +228,7 @@ pub async fn get_constants( ...@@ -228,7 +228,7 @@ pub async fn get_constants(
arena.get_or_default(), arena.get_or_default(),
program, program,
eval_context, eval_context,
AnalyzeMode::Tracing, AnalyzeMode::tracing(),
supports_block_scoping, supports_block_scoping,
// This is currently ignored with cjs_tree_shaking:false // This is currently ignored with cjs_tree_shaking:false
SpecifiedModuleType::Automatic, SpecifiedModuleType::Automatic,
......
...@@ -39,13 +39,13 @@ fn fixture(input: PathBuf) { ...@@ -39,13 +39,13 @@ fn fixture(input: PathBuf) {
noop_backing_storage(), noop_backing_storage(),
)); ));
tt.run_once(async move { tt.run_once(async move {
fixture_op(input.clone(), AnalyzeMode::CodeGeneration) fixture_op(input.clone(), AnalyzeMode::code_generation())
.read_strongly_consistent() .read_strongly_consistent()
.await?; .await?;
fixture_op(input.clone(), AnalyzeMode::Tracing) fixture_op(input.clone(), AnalyzeMode::tracing())
.read_strongly_consistent() .read_strongly_consistent()
.await?; .await?;
fixture_op(input, AnalyzeMode::CodeGenerationAndTracing) fixture_op(input, AnalyzeMode::code_generation_and_tracing())
.read_strongly_consistent() .read_strongly_consistent()
.await?; .await?;
anyhow::Ok(()) anyhow::Ok(())
...@@ -144,10 +144,11 @@ async fn fixture_op(input: RcStr, analyze_mode: AnalyzeMode) -> anyhow::Result<( ...@@ -144,10 +144,11 @@ async fn fixture_op(input: RcStr, analyze_mode: AnalyzeMode) -> anyhow::Result<(
NormalizedOutput::from(value) NormalizedOutput::from(value)
.compare_to_file(input.with_file_name(format!( .compare_to_file(input.with_file_name(format!(
"env-vars{}.snapshot", "env-vars{}.snapshot",
match analyze_mode { match (analyze_mode.is_codegen, analyze_mode.trace_file_references,) {
AnalyzeMode::CodeGenerationAndTracing => "", (true, true) => "",
AnalyzeMode::CodeGeneration => ".codegen", (true, false) => ".codegen",
AnalyzeMode::Tracing => ".tracing", (false, true) => ".tracing",
(false, false) => ".tracing-import-only",
} }
))) )))
.unwrap(); .unwrap();
......
...@@ -99,7 +99,7 @@ async fn node_file_trace_operation( ...@@ -99,7 +99,7 @@ async fn node_file_trace_operation(
// Environment is not passed in order to avoid downleveling JS / CSS for // Environment is not passed in order to avoid downleveling JS / CSS for
// node-file-trace. // node-file-trace.
environment: None, environment: None,
analyze_mode: AnalyzeMode::Tracing, analyze_mode: AnalyzeMode::tracing(),
// Disable tree shaking. Even side-effect-free imports need to be traced, as they will // Disable tree shaking. Even side-effect-free imports need to be traced, as they will
// execute at runtime. // execute at runtime.
..Default::default() ..Default::default()
......
...@@ -441,7 +441,7 @@ async fn run_test_operation(resource: RcStr) -> Result<Vc<FileSystemPath>> { ...@@ -441,7 +441,7 @@ async fn run_test_operation(resource: RcStr) -> Result<Vc<FileSystemPath>> {
environment: Some(env), environment: Some(env),
follow_reexports: options.follow_reexports, follow_reexports: options.follow_reexports,
module_fragments_enabled: options.module_fragments_enabled, module_fragments_enabled: options.module_fragments_enabled,
analyze_mode: AnalyzeMode::CodeGenerationAndTracing, analyze_mode: AnalyzeMode::code_generation_and_tracing(),
..Default::default() ..Default::default()
} }
.resolved_cell(), .resolved_cell(),
...@@ -449,7 +449,7 @@ async fn run_test_operation(resource: RcStr) -> Result<Vc<FileSystemPath>> { ...@@ -449,7 +449,7 @@ async fn run_test_operation(resource: RcStr) -> Result<Vc<FileSystemPath>> {
module_rules: vec![module_rules], module_rules: vec![module_rules],
follow_reexports: options.follow_reexports, follow_reexports: options.follow_reexports,
module_fragments_enabled: options.module_fragments_enabled, module_fragments_enabled: options.module_fragments_enabled,
analyze_mode: AnalyzeMode::CodeGenerationAndTracing, analyze_mode: AnalyzeMode::code_generation_and_tracing(),
..Default::default() ..Default::default()
} }
.cell(), .cell(),
......
...@@ -415,7 +415,7 @@ async fn node_file_trace_operation( ...@@ -415,7 +415,7 @@ async fn node_file_trace_operation(
// Environment is not passed in order to avoid downleveling JS / CSS for // Environment is not passed in order to avoid downleveling JS / CSS for
// node-file-trace. // node-file-trace.
environment: None, environment: None,
analyze_mode: AnalyzeMode::Tracing, analyze_mode: AnalyzeMode::tracing(),
// Disable tree shaking. Even side-effect-free imports need to be traced, as they will // Disable tree shaking. Even side-effect-free imports need to be traced, as they will
// execute at runtime. // execute at runtime.
follow_reexports: false, follow_reexports: false,
......
...@@ -305,7 +305,7 @@ async fn node_file_trace_operation( ...@@ -305,7 +305,7 @@ async fn node_file_trace_operation(
// Environment is not passed in order to avoid downleveling JS / CSS for // Environment is not passed in order to avoid downleveling JS / CSS for
// node-file-trace. // node-file-trace.
environment: None, environment: None,
analyze_mode: AnalyzeMode::Tracing, analyze_mode: AnalyzeMode::tracing(),
// Disable tree shaking. Even side-effect-free imports need to be traced, as they will // Disable tree shaking. Even side-effect-free imports need to be traced, as they will
// execute at runtime. // execute at runtime.
follow_reexports: false, follow_reexports: false,
......
...@@ -924,7 +924,7 @@ pub async fn externals_tracing_module_context( ...@@ -924,7 +924,7 @@ pub async fn externals_tracing_module_context(
// Environment is not passed in order to avoid downleveling JS / CSS for // Environment is not passed in order to avoid downleveling JS / CSS for
// node-file-trace. // node-file-trace.
environment: None, environment: None,
analyze_mode: AnalyzeMode::Tracing, analyze_mode: AnalyzeMode::tracing(),
module_rules: prune_rules, module_rules: prune_rules,
// Disable tree shaking. Even side-effect-free imports need to be traced, as they will // Disable tree shaking. Even side-effect-free imports need to be traced, as they will
// execute at runtime. // execute at runtime.
......
...@@ -27,10 +27,9 @@ use turbopack_core::{ ...@@ -27,10 +27,9 @@ use turbopack_core::{
}; };
use turbopack_css::CssModuleType; use turbopack_css::CssModuleType;
use turbopack_ecmascript::{ use turbopack_ecmascript::{
AnalyzeMode, EcmascriptInputTransform, EcmascriptInputTransforms, EcmascriptOptions, EcmascriptInputTransform, EcmascriptInputTransforms, EcmascriptOptions, SpecifiedModuleType,
SpecifiedModuleType, bytes_source_transform::BytesSourceTransform, bytes_source_transform::BytesSourceTransform, json_source_transform::JsonSourceTransform,
json_source_transform::JsonSourceTransform, text_source_transform::TextSourceTransform, text_source_transform::TextSourceTransform, transform::PresetEnvConfig,
transform::PresetEnvConfig,
}; };
use turbopack_mdx::MdxTransform; use turbopack_mdx::MdxTransform;
use turbopack_node::{ use turbopack_node::{
...@@ -405,7 +404,7 @@ impl ModuleOptions { ...@@ -405,7 +404,7 @@ impl ModuleOptions {
// which produces virtual paths that don't exist on disk. This breaks NFT file tracing // which produces virtual paths that don't exist on disk. This breaks NFT file tracing
// and standalone build file copying. Use Raw module type instead so the original // and standalone build file copying. Use Raw module type instead so the original
// filesystem path is preserved in the trace. // filesystem path is preserved in the trace.
let is_tracing = analyze_mode == AnalyzeMode::Tracing; let is_only_tracing = !analyze_mode.is_codegen;
// Import attribute rules (bytes/text) must come BEFORE config rules. // Import attribute rules (bytes/text) must come BEFORE config rules.
// Import attributes have a stronger API contract - they're explicit in the source code // Import attributes have a stronger API contract - they're explicit in the source code
...@@ -415,7 +414,7 @@ impl ModuleOptions { ...@@ -415,7 +414,7 @@ impl ModuleOptions {
RuleCondition::ReferenceType(ReferenceTypeCondition::EcmaScriptModules(Some( RuleCondition::ReferenceType(ReferenceTypeCondition::EcmaScriptModules(Some(
EcmaScriptModulesReferenceSubType::ImportWithType("bytes".into()), EcmaScriptModulesReferenceSubType::ImportWithType("bytes".into()),
))), ))),
if is_tracing { if is_only_tracing {
vec![ModuleRuleEffect::ModuleType(ModuleType::Raw)] vec![ModuleRuleEffect::ModuleType(ModuleType::Raw)]
} else { } else {
vec![ModuleRuleEffect::SourceTransforms(ResolvedVc::cell(vec![ vec![ModuleRuleEffect::SourceTransforms(ResolvedVc::cell(vec![
...@@ -429,7 +428,7 @@ impl ModuleOptions { ...@@ -429,7 +428,7 @@ impl ModuleOptions {
RuleCondition::ReferenceType(ReferenceTypeCondition::EcmaScriptModules(Some( RuleCondition::ReferenceType(ReferenceTypeCondition::EcmaScriptModules(Some(
EcmaScriptModulesReferenceSubType::ImportWithType("text".into()), EcmaScriptModulesReferenceSubType::ImportWithType("text".into()),
))), ))),
if is_tracing { if is_only_tracing {
vec![ModuleRuleEffect::ModuleType(ModuleType::Raw)] vec![ModuleRuleEffect::ModuleType(ModuleType::Raw)]
} else { } else {
vec![ModuleRuleEffect::SourceTransforms(ResolvedVc::cell(vec![ vec![ModuleRuleEffect::SourceTransforms(ResolvedVc::cell(vec![
...@@ -611,7 +610,7 @@ impl ModuleOptions { ...@@ -611,7 +610,7 @@ impl ModuleOptions {
RuleCondition::ReferenceType(ReferenceTypeCondition::EcmaScriptModules(Some( RuleCondition::ReferenceType(ReferenceTypeCondition::EcmaScriptModules(Some(
EcmaScriptModulesReferenceSubType::ImportWithType("json".into()), EcmaScriptModulesReferenceSubType::ImportWithType("json".into()),
))), ))),
if is_tracing { if is_only_tracing {
vec![ModuleRuleEffect::ModuleType(ModuleType::Raw)] vec![ModuleRuleEffect::ModuleType(ModuleType::Raw)]
} else { } else {
vec![ModuleRuleEffect::SourceTransforms(ResolvedVc::cell(vec![ vec![ModuleRuleEffect::SourceTransforms(ResolvedVc::cell(vec![
...@@ -629,7 +628,7 @@ impl ModuleOptions { ...@@ -629,7 +628,7 @@ impl ModuleOptions {
RuleCondition::ResourcePathEndsWith(".json".to_string()), RuleCondition::ResourcePathEndsWith(".json".to_string()),
RuleCondition::ContentTypeStartsWith("application/json".to_string()), RuleCondition::ContentTypeStartsWith("application/json".to_string()),
]), ]),
if is_tracing { if is_only_tracing {
vec![ModuleRuleEffect::ModuleType(ModuleType::Raw)] vec![ModuleRuleEffect::ModuleType(ModuleType::Raw)]
} else { } else {
vec![ModuleRuleEffect::SourceTransforms(ResolvedVc::cell(vec![ vec![ModuleRuleEffect::SourceTransforms(ResolvedVc::cell(vec![
...@@ -705,7 +704,7 @@ impl ModuleOptions { ...@@ -705,7 +704,7 @@ impl ModuleOptions {
RuleCondition::ResourcePathEndsWith(".wasm".to_string()), RuleCondition::ResourcePathEndsWith(".wasm".to_string()),
RuleCondition::ContentTypeStartsWith("application/wasm".to_string()), RuleCondition::ContentTypeStartsWith("application/wasm".to_string()),
]), ]),
if is_tracing { if is_only_tracing {
vec![ModuleRuleEffect::ModuleType(ModuleType::Raw)] vec![ModuleRuleEffect::ModuleType(ModuleType::Raw)]
} else { } else {
vec![ModuleRuleEffect::ModuleType(ModuleType::WebAssembly { vec![ModuleRuleEffect::ModuleType(ModuleType::WebAssembly {
...@@ -717,7 +716,7 @@ impl ModuleOptions { ...@@ -717,7 +716,7 @@ impl ModuleOptions {
RuleCondition::any(vec![RuleCondition::ResourcePathEndsWith( RuleCondition::any(vec![RuleCondition::ResourcePathEndsWith(
".wat".to_string(), ".wat".to_string(),
)]), )]),
if is_tracing { if is_only_tracing {
vec![ModuleRuleEffect::ModuleType(ModuleType::Raw)] vec![ModuleRuleEffect::ModuleType(ModuleType::Raw)]
} else { } else {
vec![ModuleRuleEffect::ModuleType(ModuleType::WebAssembly { vec![ModuleRuleEffect::ModuleType(ModuleType::WebAssembly {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment