overlookmotel
ac6b3091ab
refactor(ast_tools): remove repeated code in Output methods ( #6953 )
...
`generator_path.replace('\\', "/")` was repeated in each module for that generates outputs. Move it, to reduce repetition.
2024-10-28 00:23:33 +00:00
overlookmotel
2b10e5cd52
refactor(ast_tools): move logger into separate module ( #6952 )
...
Reduce the amount of code in `main.rs` by moving logger functionality to a separate module.
2024-10-28 00:23:33 +00:00
overlookmotel
06f05659c5
refactor(ast_tools): refactor writing outputs ( #6951 )
...
`write_all_to` no longer needs to be public. Remove it, and compact the code for writing files.
2024-10-27 23:56:22 +00:00
overlookmotel
6b88798253
refactor(ast_tools): generate JSON schema as Output::Raw ( #6950 )
...
Add `Output::Raw`, and use it for the JSON schema file.
2024-10-27 23:56:21 +00:00
overlookmotel
2fc6ca374f
refactor(ast_tools): hardcode schema output path ( #6949 )
...
Hard-code the output file path for JSON schema file. This will allow generating it as an `Output`, same as all other generated files.
2024-10-27 23:40:57 +00:00
overlookmotel
ef2f73ebed
refactor(ast_tools): rename Output::into_raw method ( #6948 )
...
Rename `Output::output` to `Output::into_raw` - more descriptive name.
2024-10-27 23:40:56 +00:00
overlookmotel
524d9c069f
refactor(ast_tools): generate CI filter as Output::Yaml ( #6947 )
...
Add `Output::Yaml` and use it for generating CI filter file.
2024-10-27 19:18:10 +00:00
overlookmotel
11539e61fd
refactor(ast_tools): add CI filter file to outputs ( #6946 )
...
Generate CI filter file as a `RawOutput`, same as the rest, rather than
specific code to write it to a file.
2024-10-27 19:09:42 +00:00
overlookmotel
87db9eeeed
refactor(ast_tools): simplify logging ( #6945 )
...
* Replace `logln!` macro with `log_result!` to log result of an action.
* Move logging for writing files into one place.
2024-10-27 18:53:24 +00:00
overlookmotel
dde095c7e1
refactor(ast_tools): combine derives into generators ( #6944 )
...
`Generator`s and `Derive`s now work the same. Combine them into a single `Vec`.
2024-10-27 15:37:25 +00:00
overlookmotel
80a163e691
refactor(ast_tools): reduce repeated code ( #6943 )
...
Use one function to process all passes.
2024-10-27 15:37:24 +00:00
overlookmotel
e1b747ddd6
refactor(ast_tools): all runners produce Vec<Output> ( #6942 )
...
Standardize all the different `Runner`s to produce `Vec<Output>`.
2024-10-27 15:29:17 +00:00
overlookmotel
c83b758507
refactor(ast_tools): simplify Pass ( #6941 )
...
Pure refactor. Remove dead code and structure like the other `Runner`s.
2024-10-27 14:38:18 +00:00
overlookmotel
c4c0865cb3
refactor(ast_tools): clarify code ( #6940 )
...
Small refactor.
2024-10-27 14:30:36 +00:00
Boshen
6d97af46c7
feat(rust): use oxc-miette ( #6938 )
2024-10-27 13:30:20 +00:00
Dunqing
5f153aca0c
refactor(transformer/react-refresh): use VarDeclarations to insert declarators ( #6884 )
2024-10-27 07:05:24 +00:00
overlookmotel
fc07458280
refactor(ast): move custom types .d.ts file ( #6931 )
...
We have a few manually-defined TS types in `oxc_ast` crate. Move that `.d.ts` file out of `src` folder, and name it more descriptively.
2024-10-26 17:10:34 +00:00
overlookmotel
992699012f
refactor(napi): move custom types to bottom of file ( #6930 )
...
Pure refactor. Doesn't matter much but I think it's preferable for the file not to start with the most random weird types.
2024-10-26 17:10:33 +00:00
overlookmotel
23157bde6f
refactor(napi): types file in root of types package ( #6929 )
...
Move `types.d.ts` file to root of `@oxc-project/types` package. I think this is cleaner.
2024-10-26 17:10:31 +00:00
overlookmotel
345b0a6eb0
refactor(ast_tools): shorten code in Visit generator ( #6928 )
...
Remove double line-break which formatting removes anyway.
2024-10-26 14:05:23 +00:00
overlookmotel
ad40ab7874
refactor(ast_tools): remove const params for Visit generator ( #6927 )
...
This function is large, so const param here was probably making the code slower, certainly slower compile time. Use a runtime value instead.
2024-10-26 14:05:20 +00:00
overlookmotel
4cf008573e
refactor(ast_tools): reorder imports in generated code ( #6926 )
...
Pure refactor.
2024-10-26 14:05:18 +00:00
overlookmotel
8101d1b2c4
refactor(ast_tools): handle paths as strings ( #6925 )
...
We were converting back and forwards between strings and `Path`s for no purpose. Just use strings.
2024-10-26 14:05:16 +00:00
overlookmotel
e4a59368f0
refactor(ast_tools): shorten code ( #6924 )
...
Pure refactor.
2024-10-26 14:05:14 +00:00
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
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
c7f44c439d
chore(tasks/minsize): enable idempotency test
2024-10-26 10:35:01 +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
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
Boshen
4618aa22d9
refactor(transformer)!: rename TransformerOptions::react to jsx ( #6888 )
2024-10-25 12:04:33 +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
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
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
Boshen
423d54cb74
refactor(rust): remove the annoying clippy::wildcard_imports ( #6860 )
2024-10-24 13:57:19 +00:00
ottomated
67a7bde4c6
feat(napi/parser)!: add typings to napi/parser ( #6796 )
...
- Added TypeScript annotation for `ParseResult.program`
- Modified the entrypoint for `oxc-parser` to allow wrapping the napi functions
- Updated `index.js` to parse the `program` string into a JSON object
- Updated tests
- Added a dependency on `@oxc/types`
2024-10-24 13:08:59 +00:00
ottomated
1145341a92
feat(ast_tools): output typescript to a separate package ( #6755 )
...
Part of #6347 .
Moves typescript logic from derive_estree into a new ast_tools generator.
2024-10-24 13:08:57 +00:00
Boshen
a47c70e425
fix(minifier): fix remaining runtime bugs ( #6855 )
2024-10-24 12:22:18 +00:00
Boshen
686727fc96
fix(minifier): reference read has side effect ( #6851 )
2024-10-24 08:32:38 +00:00
Dunqing
076f5c39f4
fix(transformer/typescript): retain ExportNamedDeclaration without specifiers and declaration ( #6848 )
...
close : #6825
2024-10-24 07:59:07 +00:00