overlookmotel
73ab6fb13c
refactor(ast_tools): remove temporary vec ( #6923 )
2024-10-26 13:14:39 +00:00
Dunqing
142da1d2ff
chore(transform_conformance): reorganize react-refresh related tests ( #6918 )
...
Move all tests that are copied from [react-refresh](https://github.com/facebook/react/blob/main/packages/react-refresh/src/__tests__/ReactFreshBabelPlugin-test.js ) to the `react-refresh` directory, and add a README to describe the source of these tests. This way we can better stay in sync with upstream.
related: https://github.com/oxc-project/oxc/pull/6884#discussion_r1816888813
2024-10-26 13:07:10 +00:00
overlookmotel
c41c013b4d
refactor(ast): rename lifetime ( #6922 )
...
Rename lifetime to make clear it's for a temporary borrow, and not lifetime of the arena (which is what we conventionally use `'a` for).
2024-10-26 12:57:41 +00:00
overlookmotel
6ca01b9c35
perf(ast): reduce size of Comment ( #6921 )
...
Reduce `Comment` from 20 bytes to 16. Because `Comment` has `#[ast]` attr, it's `#[repr(C)]` which means the fields don't get re-ordered by the compiler, so it contains excess padding. Moving `attached_to: u32` field removes the padding.
I am in favour of using `oxc_ast_tools` to re-order fields the same way the compiler does, which will solve this problem for all AST types. But may as well fix this one in meantime. Unlike most AST types, field order doesn't matter for `Comment` - it is not visited, so the field order has no semantic meaning.
2024-10-26 12:40:08 +00:00
Boshen
eba417aa24
fix(npm): check in npm/parser-wasm ( #6917 )
...
closes #6914
2024-10-26 18:03:31 +08:00
oxc-bot
1ea0be1b6a
release(oxlint): v0.10.3 ( #6911 )
...
## [0.10.3] - 2024-10-26
- 90c786c regular_expression: [**BREAKING**] Support ES2025 Duplicated
named capture groups (#6847 ) (leaysgur)
- 8032813 regular_expression: [**BREAKING**] Migrate to new regexp
parser API (#6741 ) (leaysgur)
### Features
- a73c5af linter: Add fixer for `jsx-a11y/no-access-key` rule (#6781 )
(Tapan Prakash)
- 2aa763c linter: Warn unmatched rule names (#6782 ) (Tapan Prakash)
- 0acca58 linter: Support `--print-config all` to print config file for
project (#6579 ) (mysteryven)
### Bug Fixes
- f49b3e2 linter: `react/iframe-missing-sandbox` ignores vanilla JS APIs
(#6872 ) (DonIsaac)
- 54a5032 linter: Correct false positive in `no-duplicates` (#6748 )
(dalaoshu)
- a47c70e minifier: Fix remaining runtime bugs (#6855 ) (Boshen)
### Documentation
- 3923e63 linter: Add schema to config examples (#6838 ) (Dmitry
Zakharov)
### Refactor
- a148023 linter: Dereference IDs as soon as possible (#6821 )
(overlookmotel)
- 423d54c rust: Remove the annoying `clippy::wildcard_imports` (#6860 )
(Boshen)
---------
Co-authored-by: Boshen <1430279+Boshen@users.noreply.github.com>
Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
2024-10-26 17:13:06 +08:00
Boshen
cb5cb6287e
fix(linter): eprintln unmatched rules warning ( #6916 )
...
We can make this a hard error and bail early once stable.
2024-10-26 08:59:12 +00:00
ottomated
ce5b609514
feat(ast): remove explicit untagged marker on enums ( #6915 )
...
This assumes that any enums with exactly one field in each variant are untagged, and they're tagged otherwise.
2024-10-26 08:21:40 +00:00
Boshen
2c7ac29ece
refactor(minifier): remove Tri, use Option<bool> instead ( #6912 )
2024-10-26 04:28:34 +00:00
Boshen
d3c5c78cba
ci: fix wasm check ( #6910 )
2024-10-26 11:10:04 +08:00
Boshen
c7f44c439d
chore(tasks/minsize): enable idempotency test
2024-10-26 10:35:01 +08:00
Boshen
f672ca0c29
ci: fix release wasm
2024-10-26 10:28:12 +08:00
ottomated
7d12669d68
fix(types): move @oxc-project/types to dependencies ( #6909 )
...
Hotfix. NPM doesn't install devDependencies automatically, so types were
missing.
2024-10-26 10:26:54 +08:00
oxc-bot
238e0866cb
release(crates): v0.34.0 ( #6908 )
...
## [0.34.0] - 2024-10-26
- 4618aa2 transformer: [**BREAKING**] Rename `TransformerOptions::react`
to `jsx` (#6888 ) (Boshen)
- 90c786c regular_expression: [**BREAKING**] Support ES2025 Duplicated
named capture groups (#6847 ) (leaysgur)
- 67a7bde napi/parser: [**BREAKING**] Add typings to napi/parser (#6796 )
(ottomated)
### Features
- 1145341 ast_tools: Output typescript to a separate package (#6755 )
(ottomated)
- 4429754 ecmascript: Constant eval `null` to number (#6879 ) (Boshen)
- fd57e00 ecmascript: Add abstract_relational_comparison to dce (#6846 )
(Boshen)
- 8bcaf59 minifier: Late peeophole optimization (#6882 ) (Boshen)
- 860cbca minifier: Implement folding simple arrow fns (#6875 ) (camc314)
- c26020e minifier: Implement folding String.prototype.replaceAll
(#6871 ) (camc314)
- 50744f3 minifier: Implement folding String.prototype.replace (#6870 )
(camc314)
- fccf82e minifier: Implement folding `substring` string fns (#6869 )
(camc314)
- e6a5a1b minifier: Implement folding `charCodeAt` string fns (#6475 )
(camc314)
- 0d0bb17 transformer: Complete the async-to-generator plugin (#6658 )
(Dunqing)
- 419343b traverse: Implement `GetAddress` for `Ancestor` (#6877 )
(overlookmotel)
### Bug Fixes
- a47c70e minifier: Fix remaining runtime bugs (#6855 ) (Boshen)
- 686727f minifier: Reference read has side effect (#6851 ) (Boshen)
- c658d93 minifier: Keep template literals with expressions (#6849 )
(Boshen)
- 4dc5e51 transformer: Only run typescript plugin for typescript source
(#6889 ) (Boshen)
- 076f5c3 transformer/typescript: Retain ExportNamedDeclaration without
specifiers and declaration (#6848 ) (Dunqing)
- b075982 types: Change @oxc/types package name (#6874 ) (ottomated)
### Documentation
- 6eeb0e6 ast: Mention typescript-eslint, field ordering and shape
(#6863 ) (Boshen)
- 99e3b32 napi: Remove JSON.parse from example (#6836 ) (ottomated)
### Refactor
- adb5039 allocator: Add `impl GetAddress for Address` (#6891 )
(overlookmotel)
- 3e7507f ast_tools: Reduce macro usage (#6895 ) (overlookmotel)
- 423d54c rust: Remove the annoying `clippy::wildcard_imports` (#6860 )
(Boshen)
- 2d95009 transformer: Implement `Debug` on `StatementInjector` internal
types (#6886 ) (overlookmotel)
- c383c34 transformer: Make `StatementInjectorStore` methods generic
over `GetAddress` (#6885 ) (overlookmotel)
- 1f29523 transformer: Rename ReactJsx to Jsx (#6883 ) (Boshen)
- 333b758 transformer: `StatementInjectorStore` methods take
`&Statement` as target (#6858 ) (overlookmotel)
- c19996c transformer: Add `StatementInjectorStore::insert_many_before`
method (#6857 ) (overlookmotel)
- 7339dde transformer: `StatementInjectorStore::insert_many_after` take
an iterator (#6856 ) (overlookmotel)
- 4348eae transformer/typescript: Re-order visitor methods (#6864 )
(overlookmotel)
- 3a56d59 transformer/typescript: Insert assignments after super by
`StatementInjector` (#6654 ) (Dunqing)
- a366fae traverse: Rename
`TraverseScoping::generate_binding_in_current_scope` (#6832 )
(overlookmotel)
- 3b99fe6 traverse: Move `generate_binding` to `TraverseScoping` (#6831 )
(overlookmotel)
- 60f487a traverse: `TraverseCtx::generate_binding` take an `Atom`
(#6830 ) (overlookmotel)
### Styling
- 262b2ed ast: Move crate doc comment to top of file (#6890 )
(overlookmotel)
---------
Co-authored-by: Boshen <1430279+Boshen@users.noreply.github.com>
Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
2024-10-26 09:39:53 +08:00
Boshen
741571f645
refactor(minifier): remove extra compress options ( #6893 )
...
Closure Compiler and ESBuild does not have these kind of granularity.
2024-10-26 01:30:13 +00:00
overlookmotel
6e68c9398b
style(ast_tools): reorder imports ( #6904 )
...
Pure refactor. Re-order imports for clarity.
2024-10-25 21:23:28 +00:00
overlookmotel
45333bc8d2
refactor(ast_tools): shorten code by hoisting imports ( #6903 )
...
Pure refactor.
2024-10-25 21:23:28 +00:00
overlookmotel
07dcc0cae3
refactor(ast_tools): move file_path method to Runner ( #6902 )
...
Centralize this common method, to move responsibility from individual derives/generators.
2024-10-25 21:16:34 +00:00
overlookmotel
5f44d84744
refactor(ast_tools): centralize logic for outputting files ( #6900 )
...
Move all logic related to formatting and outputting files into one
place.
2024-10-25 22:08:58 +01:00
overlookmotel
26de0de326
refactor(ast_tools): simplify define_pass! macro ( #6901 )
2024-10-25 21:04:03 +00:00
overlookmotel
1d981bfa53
refactor(ast_tools): run rustfmt only on generated files ( #6898 )
...
Run `rustfmt` only on individual files which codegen generates, rather than on the whole repo. This speeds up local development of `ast_tools` when you're on a slower machine.
2024-10-25 18:53:05 +00:00
overlookmotel
5c299bc10c
refactor(ast_tools): move JS file header creation ( #6897 )
...
Move creation of generated JS/TS file headers out of individual generators.
2024-10-25 18:09:50 +00:00
overlookmotel
3e7507f9d0
refactor(ast_tools): reduce macro usage ( #6895 )
...
1. Reduce the amount of code in `define_derive!` and `define_generator!` macros. This makes the code easier to read, and gives type hints in IDE.
2. Remove `generated_header!` macro and insert header as a blanket action, instead of repeated code in every generator.
2024-10-25 17:42:09 +00:00
overlookmotel
5b21eb5455
refactor(ast_tools): remove dead code ( #6894 )
2024-10-25 17:10:41 +00:00
Boshen
8bcaf59cf9
feat(minifier): late peeophole optimization ( #6882 )
2024-10-25 16:12:29 +00:00
overlookmotel
adb50398b8
refactor(allocator): add impl GetAddress for Address ( #6891 )
...
This allows passing an `Address` to methods like `StatementInjectorStore::insert_before` if you want to.
2024-10-25 15:20:21 +00:00
overlookmotel
262b2ed1ce
style(ast): move crate doc comment to top of file ( #6890 )
...
Docs are more important than clippy, so docs go first!
2024-10-25 14:31:35 +00:00
Boshen
6eeb0e6385
docs(ast): mention typescript-eslint, field ordering and shape ( #6863 )
...
closes #6453
2024-10-25 14:31:34 +00:00
Boshen
4dc5e51cb1
fix(transformer): only run typescript plugin for typescript source ( #6889 )
...
closes #6865
TypeScript plugin changes import / export statements so it needs to be turned off for non-typescript files. This should also give a little performance boost for non-typescript files.
2024-10-25 13:59:31 +00:00
overlookmotel
2d95009bca
refactor(transformer): implement Debug on StatementInjector internal types ( #6886 )
2024-10-25 12:58:28 +00:00
overlookmotel
c383c34a61
refactor(transformer): make StatementInjectorStore methods generic over GetAddress ( #6885 )
...
`StatementInjectorStore::insert_before` etc take any `GetAddress`. This allows using them with an `Ancestor` as well as a `Statement`.
Split the implementation of each function into 2 parts - generic outer wrapper and non-generic inner function to allow compiler to make better inlining decisions, and reduced compile time.
2024-10-25 12:50:58 +00:00
Boshen
4618aa22d9
refactor(transformer)!: rename TransformerOptions::react to jsx ( #6888 )
2024-10-25 12:04:33 +00:00
overlookmotel
419343bdd5
feat(traverse): implement GetAddress for Ancestor ( #6877 )
...
Closes #6803 . Allow getting `Address` of an `Ancestor`.
2024-10-25 10:52:01 +00:00
Boshen
1f29523fed
refactor(transformer): rename ReactJsx to Jsx ( #6883 )
...
This plugin is no longer about React.
The next PR will move out the React refresh plugin, which can be turned
on in isolation.
2024-10-25 10:37:28 +00:00
camc314
860cbca446
feat(minifier): implement folding simple arrow fns ( #6875 )
...
basically
```ts
const foo = () => {
return baz
}
```
becomes
```ts
const foo = () => baz
```
2024-10-25 10:26:33 +00:00
Tapan Prakash
a73c5af0f5
feat(linter): Add fixer for jsx-a11y/no-access-key rule ( #6781 )
2024-10-25 02:48:12 -04:00
Boshen
442975408b
feat(ecmascript): constant eval null to number ( #6879 )
2024-10-25 04:23:24 +00:00
Dunqing
0d0bb17ad9
feat(transformer): complete the async-to-generator plugin ( #6658 )
...
In this PR, most of the async functions have transformed correctly. But the async arrow functions don't fully transform correctly yet, it is related to we need to transform the arrow function to the generator function. For example:
Input:
```js
function declaration() {
const asy = async () => {
console.log(this.name)
}
}
```
Output:
```js
function declaration() {
const asy = babelHelpers.asyncToGenerator(function* () {
console.log(this.name);
});
}
```
Expected Output:
```js
function declaration() {
var _this = this;
const asy = /*#__PURE__*/function () {
var _ref = babelHelpers.asyncToGenerator(function* () {
console.log(_this.name);
});
return function asy() {
return _ref.apply(this, arguments);
};
}();
}
```
From the expected output, we haven't handled `this` correctly, which means even if the `arrow-function` plugin doesn't enable, we still need to handle this correctly as the `arrow-function` plugin does, and further question if `arrow-function` plugin is enabled, how to avoid these making conflict?
I thought we may move out the implementation of `arrow-function` and as a common helper, this way every plugin can handle this well
2024-10-25 03:23:31 +00:00
Boshen
fcc6221aa9
chore(oxc_release.toml): add npm/oxc-types/package.json
2024-10-25 11:22:29 +08:00
Boshen
d49716bc3b
ci(release_types): changes for ready to publish
2024-10-25 11:16:03 +08:00
Boshen
fe28bae1e0
chore: remove unnecessary packageManager from package.json
2024-10-25 10:38:02 +08:00
leaysgur
90c786c420
feat(regular_expression)!: Support ES2025 Duplicated named capture groups ( #6847 )
...
Closes #6358
@preyneyv I know you've been working on this problem.
This is an implementation that has been dormant on my local for a while.
- All tests are passing
- However, the approach is simple but not general, so there might be some edge cases that were missed
- There's also room for improvement in terms of performance
For these reasons, it was marked as WIP for me.
I believe the test cases and other parts are usable, so feel free to fork and replace them with your implementation if you'd like.
2024-10-25 02:13:57 +00:00
DonIsaac
f49b3e2088
fix(linter): react/iframe-missing-sandbox ignores vanilla JS APIs ( #6872 )
...
> Closes #6750
Fixes a false positive in `react/iframe-missing-sandbox` on `document.createElement`, which is not react and has no way of passing a sandbox prop/attribute on creation.
2024-10-25 01:43:55 +00:00
camc314
c26020e553
feat(minifier): implement folding String.prototype.replaceAll ( #6871 )
2024-10-25 01:29:57 +00:00
camc314
50744f341b
feat(minifier): implement folding String.prototype.replace ( #6870 )
2024-10-25 01:29:57 +00:00
camc314
fccf82e4df
feat(minifier): implement folding substring string fns ( #6869 )
2024-10-25 01:29:56 +00:00
ottomated
b075982eaa
fix(types): Change @oxc/types package name ( #6874 )
...
Closes #6862 .
Possible options:
- `oxc-types`
- `@oxc-project/types`
- `@oxc-ast/types`
- `oxc-ast-types`
2024-10-24 20:04:09 +00:00
camc314
322f9d44b7
chore(minifier): remove planned minification for String.substr as its deprecated ( #6868 )
...
According to mdn, `String.prototype.substr()` has been deprecated, hence i do not think it makes sense to attempt to optimize this code.
This pull request removes the test cases along with the placeholder code for minification of this method
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/substr
2024-10-24 14:53:22 +00:00
camc314
e6a5a1b11c
feat(minifier): implement folding charCodeAt string fns ( #6475 )
2024-10-24 14:37:50 +00:00
overlookmotel
4348eae157
refactor(transformer/typescript): re-order visitor methods ( #6864 )
...
It makes more sense for `exit_statement` to be after `enter_statement`.
2024-10-24 14:14:25 +00:00