Migrate from regex to AST for packaging#1006
Conversation
🦋 Changeset detectedLatest commit: aa7ac7b The changes in this PR will be included in the next version bump. This PR includes changesets to release 112 packages
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
📊 Type Coverage ReportCoverage Comparison
Files with Most Type Issues (Top 15)
This report was generated by the Type Coverage GitHub Action |
011191e to
4dce50e
Compare
| /// Rewrites asset code by replacing require() calls with resolved public IDs | ||
| /// | ||
| /// This function: | ||
| /// 1. Parses the JavaScript code to an AST |
There was a problem hiding this comment.
are we going to be able to reuse the ast at some point?
There was a problem hiding this comment.
At this stage, I don't expect that we'll re-use the AST between transform & packaging any time soon (maybe after we have end to end Rust and if/when we migrate transform to OXC).
I expect that we won't have the concept of things like separate optimiser etc plugins for packaging anymore, and we will with this AST handle all aspects of packaging:
- minification
- inline requires
- etc..
(TBD is how we handle things like Jira's "bundle wrapper" plugin which is implemented as an optimiser)
📊 Benchmark Results✅ No significant performance changes detected. 📊 Benchmark ResultsOverall Performance
🔍 Detailed Phase AnalysisThree.js Real Repository (JS)
Three.js Real Repository (V3)
💾 Unified Memory AnalysisThree.js Real Repository (JS) Memory Statistics
Sample Counts: JS: 14, Native: 237 Three.js Real Repository (V3) Memory Statistics
Sample Counts: JS: 14, Native: 244 🖥️ Environment
|
The regex based implementation for transforming assets for packaging was temporary, we always intended to move to an AST based approach.
This change introduces OXC to the native packager, and uses it in order to parse the asset, replace depenndecy requires with public asset ids, and emit the asset.
Longer term, this forms the basis for doing other operations without depending on regex and string operations, such as:
Checklist
docs/folder