-
Notifications
You must be signed in to change notification settings - Fork 53
feat(cli): bundle jssg codemods pre-publish #1639
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
Conversation
- Introduced a new `Bundle` command in the JSSG CLI for bundling JavaScript/TypeScript files and their dependencies. - Enhanced the `validate_package_structure` function to return JS files to be bundled. - Implemented a bundler utility that processes and bundles JS files, integrating with existing module resolution. - Updated the `Cargo.toml` to include the `regex` dependency and added new utility modules for bundling. - Refactored existing commands to accommodate the new bundling functionality.
The latest updates on your projects. Learn more about Vercel for Git ↗︎ 1 Skipped Deployment
|
commit: |
/// CommonJS-style module system | ||
CommonJS, | ||
/// Custom runtime with require/module.exports | ||
Custom, | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
CJS is actually require
/module.exports
and esm is import
/export
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It just means that the code in the module factory turns into CJS style code i.e. import {X} from 'module'
is converted to const {X} = __codemod_require('module')
and export { X }
is converted to exports.X = X
.
Under the hood, no import or export actually happens as the modules are stored in an object record.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
make sens maybe rephrase little bit the comment
maybe during bundling process. You can check if import is |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR introduces bundling functionality for JSSG codemods to improve distribution and dependency management. The key enhancement is automatic bundling of JavaScript/TypeScript codemods and their dependencies during the publish process.
Key Changes:
- Added a comprehensive JavaScript/TypeScript bundler system that transforms ES6 modules to CommonJS format
- Implemented a new
bundle
command in the JSSG CLI for standalone bundling operations - Integrated automatic bundling into the publish workflow for JS AST grep steps
Reviewed Changes
Copilot reviewed 11 out of 12 changed files in this pull request and generated 5 comments.
Show a summary per file
File | Description |
---|---|
crates/codemod-sandbox/src/utils/bundler/mod.rs | Core bundler implementation with dependency resolution and module transformation |
crates/codemod-sandbox/src/utils/bundler/module_transformer.rs | SWC-based ES6 to CommonJS module transformer |
crates/codemod-sandbox/src/utils/bundler/module_analyzer.rs | AST visitor for analyzing module imports and exports |
crates/codemod-sandbox/src/utils/bundler/runtime_*.tpl | Runtime templates for CommonJS and custom module systems |
crates/cli/src/commands/jssg/bundle.rs | New CLI command for manual bundling operations |
crates/cli/src/commands/publish.rs | Enhanced publish command with automatic JS bundling |
Ah good point to account for |
Verify if |
… transformer and add tests
It just works. LLRT already comes with aliases for |
📚 Description
bundle
command in the JSSG CLI for bundling JSSG codemods and their dependencies.🔗 Linked Issue
🧪 Test Plan
📄 Documentation to Update