Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion crates/perry/src/commands/compile/cjs_wrap/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
//! follows up to a small depth (2 levels) to handle one level of env
//! switching; deeper indirection is rare and gets the no-op fallback.

mod detect;
pub(in crate::commands::compile) mod detect;
mod extract_exports;
mod extract_requires;
mod hoist_classes;
Expand Down
8 changes: 4 additions & 4 deletions crates/perry/src/commands/compile/collect_modules.rs
Original file line number Diff line number Diff line change
Expand Up @@ -31,18 +31,17 @@ use super::{
ParseCache,
};

mod create_require_transform;
mod crypto_ns;
mod dynamic_glob;
mod feature_detect;
mod import_helpers;
mod native_addon;
mod parse_error;
mod static_require_transform;
#[cfg(test)]
mod tests;
mod wasm_asset;

use create_require_transform::transform_create_require_literal_requires;
use dynamic_glob::expand_dynamic_import_glob;
use import_helpers::{
cached_resolve_import_with_lexical_base, collect_js_module_imports, env_defines_for_lowering,
Expand All @@ -52,6 +51,7 @@ use import_helpers::{
pub(super) use import_helpers::known_node_submodule_key;
use native_addon::refuse_compile_package_native_addon;
use parse_error::annotate_parse_error;
use static_require_transform::transform_static_literal_requires;
use wasm_asset::{is_wasm_asset, synthesize_wasm_stub_module};

const MAX_CROSS_MODULE_INLINE_PRIOR_MODULES: usize = 128;
Expand Down Expand Up @@ -427,13 +427,13 @@ fn collect_module_one(
} else {
raw_source
};
// #5247: the create-require transform may prepend `import * as` lines,
// #5247: the static-require transform may prepend `import * as` lines,
// shifting BOTH the prefix and the body down by the same number of lines.
// Capture the wrapped line count, run the transform, then add the line
// delta to the prefix so the wrapped-line → original-line subtraction is
// computed against the FINAL parsed source.
let lines_before_transform = source.bytes().filter(|&b| b == b'\n').count();
let source = transform_create_require_literal_requires(&source, &ctx.compile_packages);
let source = transform_static_literal_requires(&source, &ctx.compile_packages);
if was_cjs_wrapped && ctx.debug_symbols {
if let Some(prefix_lines) = cjs_wrap_body_prefix_lines {
let lines_after_transform = source.bytes().filter(|&b| b == b'\n').count();
Expand Down

This file was deleted.

Loading