rzvxa
8e8fcd0584
refactor(ast_tools): rename oxc_ast_codegen to oxc_ast_tools. ( #4846 )
...
This PR renames the `oxc_ast_codegen` crate to `oxc_ast_tools`, It improves the readability and organization of the codebase by giving the crate a name that better reflects its purpose and contents.
It also improves the error message in CI.
2024-08-12 14:33:58 +00:00
Boshen
955a4b4479
docs(oxlint): improve cli doc regarding fix and -D all
...
closes #3944
2024-08-12 14:58:12 +08:00
renovate[bot]
7027cc7849
chore(deps): update pnpm to v9.7.0 ( #4836 )
...
[](https://renovatebot.com )
This PR contains the following updates:
| Package | Change | Age | Adoption | Passing | Confidence |
|---|---|---|---|---|---|
| [pnpm](https://pnpm.io ) ([source](https://togithub.com/pnpm/pnpm )) |
[`9.6.0` -> `9.7.0`](https://renovatebot.com/diffs/npm/pnpm/9.6.0/9.7.0 )
|
[](https://docs.renovatebot.com/merge-confidence/ )
|
[](https://docs.renovatebot.com/merge-confidence/ )
|
[](https://docs.renovatebot.com/merge-confidence/ )
|
[](https://docs.renovatebot.com/merge-confidence/ )
|
---
### Release Notes
<details>
<summary>pnpm/pnpm (pnpm)</summary>
### [`v9.7.0`](https://togithub.com/pnpm/pnpm/releases/tag/v9.7.0 ): pnpm
9.7
[Compare Source](https://togithub.com/pnpm/pnpm/compare/v9.6.0...v9.7.0 )
#### Minor Changes
- Added pnpm version management. If the
`manage-package-manager-versions` setting is set to `true`, pnpm will
switch to the version specified in the `packageManager` field of
`package.json` [#​8363](https://togithub.com/pnpm/pnpm/pull/8363 ).
This is the same field used by Corepack. Example:
```json
{
"packageManager": "pnpm@9.3.0"
}
```
- Added the ability to apply patch to all versions
[#​8337](https://togithub.com/pnpm/pnpm/pull/8337 ).
If the key of `pnpm.patchedDependencies` is a package name without a
version (e.g. `pkg`), pnpm will attempt to apply the patch to all
versions of the package. Failures will be skipped. If there's only one
version of `pkg` installed, `pnpm patch pkg` and subsequent `pnpm
patch-commit $edit_dir` will create an entry named `pkg` in
`pnpm.patchedDependencies`. And pnpm will attempt to apply this patch to
other versions of `pkg` in the future.
- Change the default edit dir location when running `pnpm patch` from a
temporary directory to `node_modules/.pnpm_patches/pkg[@​version]`
to allow the code editor to open the edit dir in the same file tree as
the main project
[#​8379](https://togithub.com/pnpm/pnpm/issues/8379 ).
- Substitute environment variables in config keys
[#​6679](https://togithub.com/pnpm/pnpm/issues/6679 ).
#### Patch Changes
- `pnpm install` should run `node-gyp rebuild` if the project has a
`binding.gyp` file even if the project doesn't have an install script
[#​8293](https://togithub.com/pnpm/pnpm/issues/8293 ).
- Print warnings to stderr
[#​8342](https://togithub.com/pnpm/pnpm/pull/8342 ).
- Peer dependencies of optional peer dependencies should be
automatically installed
[#​8323](https://togithub.com/pnpm/pnpm/issues/8323 ).
#### Platinum Sponsors
<table>
<tbody>
<tr>
<td align="center" valign="middle">
<a href="https://bit.dev/?utm_source=pnpm&utm_medium=release_notes "
target="_blank"><img src="https://pnpm.io/img/users/bit.svg "
width="80"></a>
</td>
<td align="center" valign="middle">
<a href="https://figma.com/?utm_source=pnpm&utm_medium=release_notes "
target="_blank"><img src="https://pnpm.io/img/users/figma.svg "
width="80"></a>
</td>
</tr>
</tbody>
</table>
#### Gold Sponsors
<table>
<tbody>
<tr>
<td align="center" valign="middle">
<a href="https://discord.com/?utm_source=pnpm&utm_medium=release_notes "
target="_blank">
<picture>
<source media="(prefers-color-scheme: light)"
srcset="https://pnpm.io/img/users/discord.svg " />
<source media="(prefers-color-scheme: dark)"
srcset="https://pnpm.io/img/users/discord_light.svg " />
<img src="https://pnpm.io/img/users/discord.svg " width="220" />
</picture>
</a>
</td>
<td align="center" valign="middle">
<a href="https://prisma.io/?utm_source=pnpm&utm_medium=release_notes "
target="_blank">
<picture>
<source media="(prefers-color-scheme: light)"
srcset="https://pnpm.io/img/users/prisma.svg " />
<source media="(prefers-color-scheme: dark)"
srcset="https://pnpm.io/img/users/prisma_light.svg " />
<img src="https://pnpm.io/img/users/prisma.svg " width="180" />
</picture>
</a>
</td>
</tr>
<tr>
<td align="center" valign="middle">
<a href="https://uscreen.de/?utm_source=pnpm&utm_medium=release_notes "
target="_blank">
<picture>
<source media="(prefers-color-scheme: light)"
srcset="https://pnpm.io/img/users/uscreen.svg " />
<source media="(prefers-color-scheme: dark)"
srcset="https://pnpm.io/img/users/uscreen_light.svg " />
<img src="https://pnpm.io/img/users/uscreen.svg " width="180" />
</picture>
</a>
</td>
<td align="center" valign="middle">
<a
href="https://www.jetbrains.com/?utm_source=pnpm&utm_medium=release_notes "
target="_blank">
<picture>
<source media="(prefers-color-scheme: light)"
srcset="https://pnpm.io/img/users/jetbrains.svg " />
<source media="(prefers-color-scheme: dark)"
srcset="https://pnpm.io/img/users/jetbrains.svg " />
<img src="https://pnpm.io/img/users/jetbrains.svg " width="180" />
</picture>
</a>
</td>
</tr>
<tr>
<td align="center" valign="middle">
<a href="https://nx.dev/?utm_source=pnpm&utm_medium=release_notes "
target="_blank">
<picture>
<source media="(prefers-color-scheme: light)"
srcset="https://pnpm.io/img/users/nx.svg " />
<source media="(prefers-color-scheme: dark)"
srcset="https://pnpm.io/img/users/nx_light.svg " />
<img src="https://pnpm.io/img/users/nx.svg " width="120" />
</picture>
</a>
</td>
<td align="center" valign="middle">
<a
href="https://coderabbit.ai/?utm_source=pnpm&utm_medium=release_notes "
target="_blank">
<picture>
<source media="(prefers-color-scheme: light)"
srcset="https://pnpm.io/img/users/coderabbit.svg " />
<source media="(prefers-color-scheme: dark)"
srcset="https://pnpm.io/img/users/coderabbit_light.svg " />
<img src="https://pnpm.io/img/users/coderabbit.svg " width="220" />
</picture>
</a>
</td>
</tr>
</tbody>
</table>
#### Our Silver Sponsors
<table>
<tbody>
<tr>
<td align="center" valign="middle">
<a
href="https://leniolabs.com/?utm_source=pnpm&utm_medium=release_notes "
target="_blank">
<img src="https://pnpm.io/img/users/leniolabs.jpg " width="80">
</a>
</td>
<td align="center" valign="middle">
<a href="https://vercel.com/?utm_source=pnpm&utm_medium=release_notes "
target="_blank">
<picture>
<source media="(prefers-color-scheme: light)"
srcset="https://pnpm.io/img/users/vercel.svg " />
<source media="(prefers-color-scheme: dark)"
srcset="https://pnpm.io/img/users/vercel_light.svg " />
<img src="https://pnpm.io/img/users/vercel.svg " width="180" />
</picture>
</a>
</td>
</tr>
<tr>
<td align="center" valign="middle">
<a href="https://depot.dev/?utm_source=pnpm&utm_medium=release_notes "
target="_blank">
<picture>
<source media="(prefers-color-scheme: light)"
srcset="https://pnpm.io/img/users/depot.svg " />
<source media="(prefers-color-scheme: dark)"
srcset="https://pnpm.io/img/users/depot_light.svg " />
<img src="https://pnpm.io/img/users/depot.svg " width="200" />
</picture>
</a>
</td>
<td align="center" valign="middle">
<a href="https://moonrepo.dev/?utm_source=pnpm&utm_medium=release_notes "
target="_blank">
<picture>
<source media="(prefers-color-scheme: light)"
srcset="https://pnpm.io/img/users/moonrepo.svg " />
<source media="(prefers-color-scheme: dark)"
srcset="https://pnpm.io/img/users/moonrepo_light.svg " />
<img src="https://pnpm.io/img/users/moonrepo.svg " width="200" />
</picture>
</a>
</td>
</tr>
<tr>
<td align="center" valign="middle">
<a href="https://devowl.io/?utm_source=pnpm&utm_medium=release_notes "
target="_blank">
<picture>
<source media="(prefers-color-scheme: light)"
srcset="https://pnpm.io/img/users/devowlio.svg " />
<source media="(prefers-color-scheme: dark)"
srcset="https://pnpm.io/img/users/devowlio.svg " />
<img src="https://pnpm.io/img/users/devowlio.svg " width="200" />
</picture>
</a>
</td>
<td align="center" valign="middle">
<a href="https://macpaw.com/?utm_source=pnpm&utm_medium=release_notes "
target="_blank">
<picture>
<source media="(prefers-color-scheme: light)"
srcset="https://pnpm.io/img/users/macpaw.svg " />
<source media="(prefers-color-scheme: dark)"
srcset="https://pnpm.io/img/users/macpaw_light.svg " />
<img src="https://pnpm.io/img/users/macpaw.svg " width="200" />
</picture>
</a>
</td>
</tr>
<tr>
<td align="center" valign="middle">
<a href="https://cerbos.dev/?utm_source=pnpm&utm_medium=release_notes "
target="_blank">
<picture>
<source media="(prefers-color-scheme: light)"
srcset="https://pnpm.io/img/users/cerbos.svg " />
<source media="(prefers-color-scheme: dark)"
srcset="https://pnpm.io/img/users/cerbos_light.svg " />
<img src="https://pnpm.io/img/users/cerbos.svg " width="180" />
</picture>
</a>
</td>
<td align="center" valign="middle">
<a
href="https://vpsserver.com/en-us/?utm_source=pnpm&utm_medium=release_notes "
target="_blank">
<img src="https://pnpm.io/img/users/vpsserver.svg " width="180" />
</a>
</td>
</tr>
</tbody>
</table>
</details>
---
### Configuration
📅 **Schedule**: Branch creation - "before 10am on monday" in timezone
Asia/Shanghai, Automerge - At any time (no schedule defined).
🚦 **Automerge**: Enabled.
♻ **Rebasing**: Whenever PR becomes conflicted, or you tick the
rebase/retry checkbox.
🔕 **Ignore**: Close this PR and you won't be reminded about this update
again.
---
- [ ] <!-- rebase-check -->If you want to rebase/retry this PR, check
this box
---
This PR was generated by [Mend
Renovate](https://www.mend.io/free-developer-tools/renovate/ ). View the
[repository job log](https://developer.mend.io/github/oxc-project/oxc ).
<!--renovate-debug:eyJjcmVhdGVkSW5WZXIiOiIzOC4yMC4xIiwidXBkYXRlZEluVmVyIjoiMzguMjAuMSIsInRhcmdldEJyYW5jaCI6Im1haW4iLCJsYWJlbHMiOltdfQ==-->
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2024-08-12 03:22:28 +00:00
Boshen
505d39ba0a
chore: bump deps
2024-08-12 10:12:34 +08:00
Don Isaac
cc922f4c89
feat(vscode): provide config's schema to oxlint config files ( #4826 )
...
Updates the VSCode plugin client to automatically provide our
auto-generated
JSON schema to `\.?oxlint(rc)?(\.json)?` files.
2024-08-12 09:15:47 +08:00
overlookmotel
ecfa1247b7
refactor(ast_codegen): add line break to generated code ( #4829 )
...
Follow-on after #4819 . Style nit. Add a line break after `#![allow(...)]`.
2024-08-11 19:36:24 +00:00
rzvxa
0ea697b4e9
refactor(ast, ast_codegen): CloneIn implementations now initialize semantic related cells with Default value. ( #4819 )
...
closes #4809
2024-08-11 19:10:56 +00:00
rzvxa
74af8e230a
refactor(ast_codegen): Simplify InnerMarkers. ( #4812 )
2024-08-11 18:42:54 +00:00
DonIsaac
3d40528588
feat(linter): add fix emoji to rules table and doc pages ( #4715 )
...
Rules table:
<img width="898" alt="image" src="https://github.com/user-attachments/assets/353052aa-0af3-4c09-8441-ff79f4561ca0 ">
Doc pages:
<img width="918" alt="image" src="https://github.com/user-attachments/assets/cb43cb2d-15ff-41e6-8523-145cfbc3f484 ">
2024-08-10 22:50:47 +00:00
Don Isaac
a266b45167
feat(rulegen): improve examples in documentation ( #4815 )
2024-08-10 18:48:59 -04:00
Dunqing
62f759c1f2
fix(transformer/typescript): generated assignment for constructor arguments with access modifiers should be injected to the top of the constructor ( #4808 )
...
fix : #4789
2024-08-10 11:21:45 +00:00
DonIsaac
8f2a566f9f
test(linter): ensure rule docs have valid syntax ( #4644 )
...
Adds tests for rule documentation by
1. Compiling doc markdown into HTML, which ensures docs use valid markdown syntax
2. Converts the generated HTML into JSX and parses the results with the parser, ensuring the generated HTML is valid
Has the added benefit of adding a lot of JSX test cases to the parser. I've also fixed all violations for these tests in this PR.
2024-08-10 05:03:09 +00:00
DonIsaac
f62951411d
feat(website): auto-generate rule docs pages ( #4640 )
...
> AI-generated description because I'm lazy
### TL;DR
This PR introduces the ability to generate documentation for linter rules and adds new methods and metadata for rule fix capabilities.
To see what this looks like, please check out https://github.com/oxc-project/oxc-project.github.io/pull/165 .
## Screenshots
Hyperlinks to rule doc pages in auto-generated rules table
<img width="809" alt="image" src="https://github.com/user-attachments/assets/e09eb47d-e86a-4ed1-b1f9-5034f33c71a2 ">
Example of a docs page
<img width="1273" alt="image" src="https://github.com/user-attachments/assets/78f7e9e6-f4dd-4cc9-aebc-1cdd64b024ec ">
### What changed?
- Added `RuleFixMeta` to indicate rule fix capabilities
- Introduced methods `is_none` and `is_pending` in `RuleFixMeta`
- Modified `render_markdown_table` in `RuleTableSection` to accept an optional link prefix
- Created new modules for rule documentation and HTML rendering
- Updated `print_rules` function to generate markdown for rules and detailed documentation pages
### How to test?
Run the `linter-rules` task with appropriate arguments to generate the markdown table and documentation pages.
Verify the generated files for correctness and that all metadata is correctly displayed.
### Why make this change?
To enhance the project documentation and provide clear rule fix capabilities, thereby improving the developer experience and easing the integration process.
---
2024-08-10 00:13:06 +00:00
overlookmotel
92777d0aae
refactor(ast_codegen): replace ///@@ with ///@@line_break ( #4786 )
...
Follow-on after #4778 . `///@@line_break` is more verbose, but it's clearer what it does.
2024-08-09 10:52:22 +00:00
overlookmotel
ec82a79ebe
refactor(ast_codegen): trim r# from start of field names ( #4785 )
...
Some struct fields are reserved names e.g. `type`. They are written in source as `r#type`. Trim off the `r#` prefix in `FieldDef::name` and add it back when generating output.
Main motivation is to have the unescaped field names in JSON schema.
2024-08-09 10:52:21 +00:00
overlookmotel
31311877f1
refactor(ast_codegen): alter JSON schema format ( #4784 )
...
Change the format of schema JSON by altering `serde` attrs.
2024-08-09 10:52:20 +00:00
overlookmotel
c79ca40b77
refactor(ast_codegen): remove excess space from start of doc comments ( #4782 )
...
I noticed that in JSON schema the `docs` property contains e.g. `" The name of the identifier being referenced."` (with an excess space on the start). Trim that off.
2024-08-09 10:25:28 +00:00
overlookmotel
d4a3be86ed
refactor(ast_codegen): line breaks between types in layout assertions ( #4781 )
...
Small style nit. Add line breaks between types in generated layout assertions, to make the file easier to read.
2024-08-09 10:17:21 +00:00
overlookmotel
966fcc925a
refactor(ast_codegen): re-order code in fmt module ( #4779 )
...
Pure refactor. Just move code which is most used to top of `fmt` module. And rename `pprint` to `pretty_print` to be a little clearer.
2024-08-09 10:01:14 +00:00
overlookmotel
2c1c7050ea
refactor(ast_codegen): use doc comments instead of endl! ( #4778 )
...
Similar to #4777 .
Use `///@@` instead of `endl!();` in AST codegen to create line breaks.
NB: `///@@` needs to be before an item, not after it.
2024-08-09 08:57:18 +00:00
overlookmotel
f418f62e7b
refactor(ast_codegen): use doc comments instead of insert! ( #4777 )
...
Avoid the `insert!` macro in AST codegen. Use doc comments starting with special symbol `@` instead.
* Before: `insert!("// plain comment");`
* After: `///@ plain comment`
* Or: `//!@ plain comment`
Either `///@` or `//!@` is converted to plain `//` in output.
`//!@` is legal in top-of-file position, which allows us to inline `#![allow(...)]` attributes, which in my opinion makes the generators a bit easier to read.
2024-08-09 08:19:15 +00:00
overlookmotel
c15c931a3f
refactor(ast_codegen): move formatting regex definitions ( #4775 )
...
Pure refactor. Move the regex definitions used in formatting to next to the `Replacer`s for those regexes.
2024-08-09 07:48:13 +00:00
overlookmotel
dbb5f4c75e
refactor(ast_codegen): remove unnecessary imports from generated files ( #4774 )
...
#4773 makes types like `Span` importable from `oxc_ast::ast`, so remove the imports from other crates in generated code.
I'm not sure why clippy's `wildcard_imports` rule was not being triggered for `use crate::ast::*;`, but add `#[allow(clippy::wildcard_imports)]` on these statements just to make sure.
2024-08-09 07:48:09 +00:00
rzvxa
fff9da319d
fix(ast, ast_codegen): use generate_derive instead of visitable for generating span derives. ( #4747 )
...
follow-up to #4735
I was accidentally using the old code to filter the viable target types to derive. It means before this PR we were still using the `#[ast(visit)]` for this purpose.
2024-08-08 17:06:48 +00:00
rzvxa
abe8202ba8
refactor(ast_codegen): declutter the main file. ( #4744 )
...
same as #4741
2024-08-08 16:38:13 +00:00
overlookmotel
7345f68d9e
refactor(ast_codegen): remove Generator::name and Pass::name methods ( #4764 )
...
Remove `Generator::name` and `Pass::name` methods. All impls for these methods return a string identical to the struct name, so can set return value of `Runner::name` in `define_generator!` and `define_pass!` macros instead.
2024-08-08 15:39:10 +00:00
overlookmotel
d32fb6f5c5
refactor(ast_codegen): re-order imports ( #4763 )
...
Move imports to top of file in `generators/mod.rs`, just for consistency.
2024-08-08 15:39:09 +00:00
overlookmotel
80046d1144
refactor(ast_codegen): consistent endl! position ( #4762 )
...
Pure refactor (style nit). Place `endl!()` macro calls in consistent position throughout codegen.
2024-08-08 15:39:08 +00:00
overlookmotel
2dea0caae0
refactor(ast_codegen): consistent import order ( #4761 )
...
Pure refactor. Alter import order in generated code to consistent order - `std`, external crates, `crate`, `super`.
2024-08-08 15:24:45 +00:00
overlookmotel
790c551c5e
refactor(ast_codegen): simplify derive_get_span generator ( #4757 )
...
Simplify `derive_get_span` generator that was introduced in #4735 . No change to functionality, just aiming for greater readability.
In particular:
* Move defining idents/tokens which are specific to `GetSpan` / `GetSpanMut` into those specific generators, rather than branching on `MUT` later on.
* Remove `const MUT` param.
* Remove the confusing pairs of closures and functions both called `derive_enum` / `derive_struct`.
* Inline function which generates the impls - prioritizing readability over DRY code.
2024-08-08 10:47:37 +00:00
heygsc
bd56b6b56b
chore(tasks): change comment fix-dangerous to fix_dangerous ( #4756 )
2024-08-08 18:42:29 +08:00
dalaoshu
6cf38cb776
chore(tasks): support init vitest lint rule ( #4752 )
...
Related to #4656
2024-08-08 16:27:50 +08:00
Boshen
fbfd852cf8
refactor(minifier): add NodeUtil trait for accessing symbols on ast nodes ( #4734 )
2024-08-08 02:48:25 +00:00
overlookmotel
f36500a2bd
refactor(ast_codegen): flatten code ( #4743 )
...
A bit of code style simplification after #4731 . Remove unnecessary nesting and rename some vars for consistency.
2024-08-07 22:32:07 +00:00
rzvxa
aeed29f248
chore(ci): generate .generated_ast_watch_list.yml ( #4737 )
...
closes #4699
I also did some reordering to the code so it is easier to follow.
2024-08-07 22:11:34 +00:00
rzvxa
2218340f2b
refactor(ast, ast_codegen): use generate_derive for implementing GetSpan and GetSpanMut traits. ( #4735 )
2024-08-07 22:07:33 +00:00
rzvxa
579b797cc5
refactor(ast): use type identifier instead of CloneIn::Cloned GAT. ( #4738 )
...
After https://github.com/oxc-project/oxc/pull/4731#discussion_r1707526289 , I realized that I'm using `Self::Cloned` for enum derives. It was from my earlier attempts to resolve lifetime issues.
2024-08-07 21:23:23 +00:00
rzvxa
ec0b4cbdaa
feat(ast_codegen): add derive_clone_in generator. ( #4731 )
...
Follow-on after #4276 , related to #4284 .
2024-08-07 20:29:06 +00:00
rzvxa
2e91ad6c4e
feat(ast_codegen): support for generate_derive marker. ( #4728 )
...
Follow-on after #4276 , related to #4284 .
2024-08-07 17:38:13 +00:00
Boshen
94d3c31933
fix(minifier): avoid removing function declaration from KeepVar ( #4722 )
2024-08-07 05:09:32 +00:00
overlookmotel
06efae6e4c
refactor(ast_codegen): reorder imports ( #4709 )
...
Pure refactor. Reorder imports to clarify what's an external crate and what's a local module.
2024-08-06 20:38:42 +00:00
overlookmotel
654a6e67fa
refactor(ast_codegen): list input files explicitly ( #4708 )
...
List inputs to the codegen explicitly. This is less DRY, but I think it has the advantage of being more obvious - for #4704 .
2024-08-06 19:14:05 +00:00
overlookmotel
07607d3e94
feat(ast_codegen, span): process Span through ast_codegen ( #4703 )
...
Add `#[ast]` attr to `Span`.
Due to how AST codegen works, this necessitates putting the type def in a separate file. https://github.com/oxc-project/oxc/pull/4696#issuecomment-2271781995
2024-08-06 18:22:22 +00:00
rzvxa
125c5fd8ed
feat(ast_codegen, span): process SourceType through ast_codegen. ( #4696 )
2024-08-06 17:42:12 +00:00
rzvxa
82e2f6b924
feat(ast_codegen): process AST-related syntax types. ( #4694 )
2024-08-06 17:14:35 +00:00
rzvxa
b04dc3d026
refactor(ast_codegen): disallow implicit enum discriminants on #[ast] types. ( #4690 )
2024-08-06 17:14:33 +00:00
rzvxa
1690a57ed3
refactor(ast_codegen): move away from RType in generators. ( #4682 )
...
This PR introduces `EarlyCtx` and `LateCtx` in place of the old `CodegenCtx`, Early passes operate at the AST level while generators and other late passes operate on the schema.
It will also replace the confusing `RType` name with something more idiomatic ~~(open for suggestions, I haven't found a good name yet)~~ I've named it `AstType` and dropped the `R` prefix for `REnum` and `RStruct`.
There are some qualities of life improvements too, Things like `to_type_elide` can be used to simplify the code.
Related to #4442 (and can potentially mark it "close as fixed").
2024-08-06 17:14:31 +00:00
overlookmotel
4797eaaab6
fix(transformer): strip TS statements from for in/of statement bodies ( #4686 )
...
Remove TS statements in body of `for of` and `for in` statements, as well as plain `for`.
2024-08-06 13:03:02 +00:00
Boshen
bf48c7f02a
fix(minifier): fix keep_var keeping vars from arrow functions ( #4680 )
2024-08-06 07:04:25 +00:00
overlookmotel
e42ac3a2a0
feat(sourcemap): add ConcatSourceMapBuilder::from_sourcemaps ( #4639 )
...
Introduce new method `ConcatSourceMapBuilder::from_sourcemaps`.
Where all the sourcemaps being concatenated exist at time that you
create `ConcatSourceMapBuilder`, it's faster to use `from_sourcemaps`,
because it pre-allocates enough space for the data it will hold and so
avoids memory copying.
Before:
```rs
let mut builder = ConcatSourceMapBuilder::default();
builder.add_sourcemap(&sourcemap1, 0);
builder.add_sourcemap(&sourcemap2, 100);
builder.add_sourcemap(&sourcemap3, 100);
let combined = builder.into_sourcemap();
```
After:
```rs
let builder = ConcatSourceMapBuilder::from_sourcemaps(&[
(&sourcemap1, 0),
(&sourcemap2, 100),
(&sourcemap3, 200),
]);
let combined = builder.into_sourcemap();
```
2024-08-06 14:08:17 +08:00