Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Detect minified umd with leading fn declarations #788

Merged
merged 6 commits into from
Jan 16, 2024
Merged
Changes from 1 commit
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
6 changes: 3 additions & 3 deletions packages/esm-cjs-lexer/src/cjs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1200,7 +1200,7 @@ impl CJSLexer {
}

if webpack_require_props == 2 {
stmts.iter().skip(first_stmt_index + 1).find(|stmt| match stmt {
stmts.iter().skip(first_stmt_index + 1).take(8).find(|stmt| match stmt {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nice take!

Stmt::Expr(ExprStmt { expr, .. }) => {
if let Expr::Seq(SeqExpr { exprs, .. }) = &**expr {
let mut found_webpack_require_exprs = false;
Expand Down Expand Up @@ -1298,7 +1298,7 @@ impl CJSLexer {
}

if webpack_require_props == 2 {
stmts.iter().skip(first_stmt_index + 1).find(|stmt| match stmt {
stmts.iter().skip(first_stmt_index + 1).take(8).find(|stmt| match stmt {
Stmt::Expr(ExprStmt { expr, .. }) => {
if let Expr::Seq(SeqExpr { exprs, .. }) = &**expr {
let mut found_webpack_require_exprs = false;
Expand Down Expand Up @@ -1440,7 +1440,7 @@ impl CJSLexer {
if let Some(expr) = exprs.get(0) {
if let Expr::Call(call) = &**expr {
if let Some(stmts) = is_iife_call(call) {
stmts.iter().find(|stmt| match stmt {
stmts.iter().take(8).find(|stmt| match stmt {
Stmt::Expr(ExprStmt { expr, .. }) => {
if let Expr::Seq(SeqExpr { exprs, .. }) = &**expr {
let mut found_webpack_require_exprs = false;
Expand Down