Skip to content

fix(cli): keep lazy-smoke-load's .ts literals out of packem's rewrite - #1497

Closed
prisis wants to merge 1 commit into
alphafrom
fix/cli-lazy-smoke-ts-extension
Closed

prisis wants to merge 1 commit into
alphafrom
fix/cli-lazy-smoke-ts-extension

Conversation

@prisis

@prisis prisis commented Nov 5, 2026

Copy link
Copy Markdown
Member

Summary

The production build of @lunora/cli shipped a broken lazy smoke check. packem's fix-dynamic-import-extension plugin rewrites every ".ts") literal that follows an import( on the minified line, and visulima/packem#450 fixes that at the source. As a result:

  • read("workflows.ts") and read("agents.ts") read workflows.mjs and agents.mjs, which don't exist, so deferred workflow and agent modules were never smoke-loaded.
  • readdirSync(_generated).filter(name => name.endsWith(".ts")) became .endsWith(".mjs"), so no generated loader imports were checked.

This PR builds the extension from one constant (TS_SOURCE_EXTENSION). The minifier keeps it as a variable (X=".ts",), which the regex can't match. The same change covers entry.ts and functions.ts, which only survived by chance.

A dev-vs-prod scan of every package's built string literals found no other rewritten .ts literal on alpha. The @lunora/nuxt occurrence is fixed in #1487.

Test plan

  • build:prod of @lunora/cli: the shipped chunk has n("workflows"), n("agents"), endsWith(X), entry${X} and functions${X}, and no agents.mjs/workflows.mjs
  • lazy-smoke-load.test.ts: 65/65
  • eslint and tsc clean

🤖 Generated with Claude Code

packem's fix-dynamic-import-extension plugin rewrote every `".ts")` literal
that followed an `import(` on the minified line, so the production CLI read
`workflows.mjs` and `agents.mjs` and filtered `_generated/` for `.mjs` files:
the lazy smoke check never found the deferred workflow and agent modules or
the generated loaders. Build the extension from one constant, which the
minifier keeps as a variable, until the plugin fix (visulima/packem#450)
ships.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@qodo-code-review

Copy link
Copy Markdown

Qodo reviews are paused for this user.

Troubleshooting steps vary by plan Learn more →

On a Teams plan?
Reviews resume once this user has a paid seat and their Git account is linked in Qodo.
Link Git account →

Using GitHub Enterprise Server, GitLab Self-Managed, or Bitbucket Data Center?
These require an Enterprise plan - Contact us
Contact us →

@netlify

netlify Bot commented Nov 5, 2026 •

Copy link
Copy Markdown

✅ Deploy Preview for lunorash ready!

Name Link
🔨 Latest commit b794dcb
🔍 Latest deploy log https://app.netlify.com/projects/lunorash/deploys/6aec42367eb7d57e5f7558ba
😎 Deploy Preview https://deploy-preview-1497--lunorash.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.
🤖 Make changes Run an agent on this branch

To edit notification comments on pull requests, go to your Netlify project configuration.

@coderabbitai

coderabbitai Bot commented Nov 5, 2026

Copy link
Copy Markdown

Warning

Review limit reached

You've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository.

Next included review available in 46 minutes.

Check out review usage here.

View limit details

Limit details: You’ve used all 2 included reviews currently available.

Learn how review limits work.

Review configuration:

Run configuration

Commits

Reviewing files that changed from the base of the PR and between dcce96e and b794dcb.

Files selected for processing: 1

  • packages/cli/src/util/lazy-smoke-load.ts
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

Share

@github-actions

github-actions Bot commented Nov 5, 2026

Copy link
Copy Markdown
Contributor

Thank you for following the naming conventions! 🙏

@github-actions github-actions Bot added size:S Size of the change, tests and generated files excluded. vouch:trusted PR author is a collaborator, a bot or on the VOUCHED list. labels Nov 5, 2026
@qodo-free-for-open-source-projects

Copy link
Copy Markdown
Contributor

PR Summary by Qodo

Preserve TypeScript paths in the production CLI smoke check

🐞 Bug fix 🕐 10-20 Minutes

Grey Divider

AI Description

• Prevent packem from rewriting TypeScript file references used by the production CLI smoke check.
• Restore discovery of deferred workflow, agent, and generated loader modules before deploy.
Diagram

graph TD
    A["TS extension constant"] --> B["Packem build"] --> C["Smoke scanner"] --> E["Smoke Worker"] --> F["Lazy modules"]
    D["Generated TS files"] --> C
Loading
High-Level Assessment

The following are alternative approaches to this PR:

1. Fix packem's rewrite
  • ➕ Addresses the underlying rewrite behavior for all affected consumers.
  • ➕ Removes reliance on how minification represents the constant.
  • ➖ Depends on an upstream fix and release before the CLI can benefit.

Recommendation: Keep the local constant-based workaround to restore the production smoke check now, then remove it when the upstream packem fix is available. A production-bundle regression test would help guard the workaround until then.

Files changed (1) +15 / -8

Bug fix (1) +15 / -8
lazy-smoke-load.tsConstruct smoke-check TypeScript paths from a shared extension +15/-8

Construct smoke-check TypeScript paths from a shared extension

• Adds a shared '.ts' extension constant and uses it when reading generated workflow, agent, and app files; filtering generated loaders; and naming the smoke entry and function manifest. This keeps those path references out of the literal pattern that packem incorrectly rewrites in the minified CLI.

packages/cli/src/util/lazy-smoke-load.ts

@qodo-free-for-open-source-projects

Copy link
Copy Markdown
Contributor

Code Review by Qodo

🐞 Bugs (0) 📘 Rule violations (0) 📎 Requirement gaps (0)

Grey Divider

Great, no issues found!

Qodo reviewed your code and found no material issues that require review

Grey Divider

Tip of the day
💡 Did you know, you can turn these tips off under Display > Comment parts

More tips ↗ | Customize Qodo ↗ | Qodo docs ↗

Grey Divider

Qodo Logo

@codspeed

codspeed Bot commented Nov 5, 2026

Copy link
Copy Markdown

Merging this PR will not alter performance

1 warning

⚠️ 3 benchmarks are dominated by system calls

System calls cannot be simulated consistently and are left out of the measure. The reported value understates the real cost. Switch to the Walltime instrument to measure them.

Learn more about system calls

See affected benchmarks

✅ 3 untouched benchmarks
⏩ 396 skipped benchmarks1


Comparing fix/cli-lazy-smoke-ts-extension (b794dcb) with alpha (dcce96e)

Open in CodSpeed

Footnotes

  1. 396 benchmarks were skipped, so the baseline results were used instead. If they were deleted from the codebase, click here and archive them to remove them from the performance reports. ↩

@codecov-commenter

codecov-commenter commented Nov 5, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 88.40%. Comparing base (2d7eb96) to head (b794dcb).
⚠️ Report is 9 commits behind head on alpha.

Additional details and impacted files
@@             Coverage Diff             @@
##            alpha    #1497       +/-   ##
===========================================
+ Coverage   83.97%   88.40%    +4.43%     
===========================================
  Files        2089      249     -1840     
  Lines      126052    15969   -110083     
  Branches    32259     4505    -27754     
===========================================
- Hits       105855    14118    -91737     
+ Misses      19447     1721    -17726     
+ Partials      750      130      -620     
Files with missing lines Coverage Δ
packages/cli/src/util/lazy-smoke-load.ts 94.68% <100.00%> (+0.01%) ⬆️

... and 1841 files with indirect coverage changes

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@prisis prisis mentioned this pull request Nov 5, 2026
2 of 3 tasks
@prisis

prisis commented Nov 5, 2026

Copy link
Copy Markdown
Member Author

Superseded by #1498: @visulima/packem 4.0.4 ships the regex fix (visulima/packem#450), so the source workaround isn't needed.

@prisis prisis closed this Nov 5, 2026
@prisis
prisis deleted the fix/cli-lazy-smoke-ts-extension branch November 5, 2026 12:12

This branch was previously deployed

1 inactive deployment
benchmarks — b794dcb8 Deployed Nov 5, 2026 by prisis via Benchmarks #7103
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

🟠 Medium blast radius package: cli size:S Size of the change, tests and generated files excluded. vouch:trusted PR author is a collaborator, a bot or on the VOUCHED list.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants