Commit Graph

7139 Commits

Author SHA1 Message Date
OJ Kwon
ac5ab607c9
refactor(plugin/runner): Revise cache, module loading (#7408)
**Description:**

One of the oversight around design of `TransformExecutor` is
encapsulating plugin module logic. It has access to the cache and do its
own loading & storing. This means consumer of plugin runner have tricky
challenge to control its caching system. First, there is no way to
escape how swc_plugin_runner controls cache and cannot synchronize into
their own, also depends on the usecases cannot control the features they
want to opt in: for example, there's no way one interface uses in-memory
cache, and another uses filesystem since it is compile time configured
singleton.

PR revisits overall design of TransformExecutor: now it accepts a tratir
`PluginModuleBytes`, which abstracts any kind of bytes we are dealing
with, such as raw file slice or serialized `wasmer::Module`. Cache
instantiation and managing is now bubbled up to the application level
(`swc` in here), so if someone wants non-singleton caching or integrate
into their own caching system it can be customized.

Lastly, deprecated `memory_cache` feature and only exposes
`filesystem_cache`. Cache implementation uses in-memory is always
available, and can opt in filesystem cache where it's supported.


**BREAKING CHANGE:**

This is clearly breaking changes for the consumers of swc_core. for the
@swc/core, this PR takes care of necessary changes. I'll work on
next-swc changes later once we have new @swc/core version with this
changes.
2023-05-18 07:05:39 +00:00
SWC Bot
31d7b88555 chore: Publish crates 2023-05-18 01:21:08 +00:00
Austaras
5dbbbea2ef
fix(es/minifier): Mark all function params as potential property mutation (#7409)
**Description:**

This issue is more severe than I originally thought. It raises not in
array indexing, but in function calls and property mutation. We should
treat all function arguments as potentially be property mutated,
otherwise following example

```js
class A {
	a = 1

	toString() {
		return this.a
	}
}

const a = new A()

function foo(x) {
	x.a++
}

const b = a + 1

foo(a)

console.log(b)
```

would be error(It should log 2, but logs 3 after compress).

As the result, massive regressions is unavoidable, since some of these
optimizations may indeed cause error. Part of them can be mitigated with
following optimization -- allow inline of ident even if its original
value is mutated. Consider

```js
export function foo(x) {
   const y = x
   x.a = 1
   y.b = 2
}
```

If x is a primitive value, all mutations to its properties are ignored;
if x is a object, then y refers to the same object no matter what
mutation is performed.

And there's still room for more, currently following code
```js
export function foo(x) {
    const y = Math.floor(x);
    g(y);
}
```
But I'd rather do it in a separate PR.


**Related issue:**

 - Closes #7402.
2023-05-18 01:19:17 +00:00
SWC Bot
a2a544a0ae chore: Publish crates 2023-05-17 13:12:20 +00:00
Yunfei He
dba78a0031
fix(es/compat): Mark reserved function names private (#7298) 2023-05-17 13:10:27 +00:00
SWC Bot
c520e7469e chore: Publish crates 2023-05-17 06:17:15 +00:00
Donny/강동윤
95291f2c5d
fix(common): Disable tracing/release_max_level_info (#7401) 2023-05-17 06:15:18 +00:00
SWC Bot
8052d4dabd chore: Publish crates 2023-05-17 04:53:45 +00:00
Donny/강동윤
1d3f32056c
fix(es/parser): Fix parsing of module identifier (#7400)
**Related issue:**

 - Closes #4176.
 - Closes #7372.
2023-05-17 04:51:57 +00:00
SWC Bot
820f29ffc1 chore: Publish crates 2023-05-17 03:57:12 +00:00
Donny/강동윤
6b92eecd39
test(css/module): Add a test for a fixed issue (#7399)
**Related issue:**

 - Closes #6897.
2023-05-17 03:55:24 +00:00
SWC Bot
227c272904 chore: Publish crates 2023-05-16 12:33:08 +00:00
Donny/강동윤
eaba323581
test(es/parser): Add a test for a fixed issue (#7398)
**Related issue:**

 - Closes #6976.
2023-05-16 12:31:05 +00:00
SWC Bot
da0c612d85 chore: Publish crates 2023-05-16 05:18:57 +00:00
Donny/강동윤
3a0565f377
chore(plugin): Update rkyv to v0.7.42 (#7397) 2023-05-16 14:17:12 +09:00
SWC Bot
d3db7edd51 chore: Publish crates 2023-05-16 04:14:36 +00:00
Donny/강동윤
40ba242076
fix(es/codegen): Do not create duplicate source map entry (#7309) 2023-05-16 04:12:46 +00:00
SWC Bot
02b22f7625 chore: Publish crates 2023-05-16 03:23:16 +00:00
Donny/강동윤
f9cdd741c2
test(es/minifier): Enable more terser tests (#7396) 2023-05-16 03:21:08 +00:00
Donny/강동윤
4a53951fe3 chore: Publish crates 2023-05-15 13:18:22 +09:00
Donny/강동윤
a5e68243e2
chore: Publish v1.3.58 with swc_core v0.76.7 (#7393) 2023-05-15 13:17:25 +09:00
SWC Bot
a05e28906b chore: Publish crates 2023-05-15 04:14:42 +00:00
OJ Kwon
05b4c11497
feat(swc_core): Expose plugin proxy to the host env (#7391) 2023-05-15 13:12:33 +09:00
Donny/강동윤
8e6fea8519 chore: Publish crates 2023-05-15 12:42:54 +09:00
SWC Bot
5e3d156aca chore: Publish crates 2023-05-15 03:20:03 +00:00
OJ Kwon
bba1fad35c
feat(plugin): Add versioned wrapper struct (#7382) 2023-05-15 03:17:31 +00:00
SWC Bot
5d30437206 chore: Publish crates 2023-05-15 02:27:59 +00:00
Donny/강동윤
cad18fae4b
feat(es/compat): Implement auto accessors fully (#7370)
**Related issue:**

 - Closes #7193.
2023-05-15 02:26:07 +00:00
SWC Bot
a2577adffa chore: Publish crates 2023-05-14 06:08:33 +00:00
OJ Kwon
e3868a7e00
feat(swc_core): Allow native env plugin to use memory cache (#7390)
**Description:**

I just realized there could be some case who'll want plugin in native env, but without filesystem cache. If there's a custom cache implementation, it'll make a conflict to swc's caching mechanism since swc does not expose any interface to the its cache.

PR takes simple approach to expose another feature to opt in native env with memory cache for those case. Ideally we should make `plugin_transform_host_native` to not to opt-in any cache, and then make `swc_plugin_runner` to run without any cache implementation - but that'll be a breaking changes with few more involved changes.
2023-05-14 06:06:24 +00:00
SWC Bot
a71d5b2180 chore: Publish crates 2023-05-14 05:23:11 +00:00
Austaras
fa7a3521f5
fix(es/parser): Fix >= with type instantiate (#7388) 2023-05-14 05:21:13 +00:00
SWC Bot
e88ae37a0c chore: Publish crates 2023-05-12 00:47:49 +00:00
OJ Kwon
9b3a41c57d
refactor(common): Derive ByteCheck for ArcString (#7380) 2023-05-12 09:45:59 +09:00
SWC Bot
7655aaa42a chore: Publish crates 2023-05-11 14:02:24 +00:00
Donny/강동윤
166e77c2b3
chore(es): Enable tracing spans for release builds (#7379) 2023-05-11 13:59:53 +00:00
SWC Bot
65785bdf21 chore: Publish crates 2023-05-10 04:19:21 +00:00
Donny/강동윤
041b491466
feat(es/parser): Implement explicit resource management (#7322)
**Description:**

 - Add `UsingDecl`.
 - Add `UsingDecl` to `Decl`.
 - Rename `VarDeclOrPat` to `ForHead`.
 - Add `UsingDecl` to `ForHead`.
 - Implement parser for using declarations.

**Related issue:**

 - #7316.
2023-05-10 04:16:44 +00:00
SWC Bot
6432e1f5c5 chore: Publish crates 2023-05-10 03:33:12 +00:00
Donny/강동윤
1dced17998
fix(es/minifier): Fix remapping of vars upon inlining (#7362)
**Related issue:**

 - Closes #7331.
2023-05-10 03:31:15 +00:00
SWC Bot
e1c9182e1c chore: Publish crates 2023-05-09 05:47:00 +00:00
Donny/강동윤
97ec259144
feat(es/compat): Partially support auto accessors (#7364)
**Description:**

I'll create a follow-up PR for a full support for auto accessors.

**Related issue:**

 - #7193.
2023-05-09 05:45:16 +00:00
SWC Bot
d8a3310543 chore: Publish crates 2023-05-09 03:04:13 +00:00
Donny/강동윤
6399d450cc
chore: Publish v1.3.57 with swc_core v0.75.46 (#7368) 2023-05-09 12:02:09 +09:00
SWC Bot
7fc9b00443 chore: Publish crates 2023-05-08 03:40:27 +00:00
Donny/강동윤
9c052db796
feat(es/compat): Support export class from stage 3 decorator pass (#7363)
**Related issue:**

 - Closes #7358.
2023-05-08 03:38:43 +00:00
SWC Bot
aef5ac4812 chore: Publish crates 2023-05-06 03:56:38 +00:00
OJ Kwon
d2c1f45f5a
feat(plugin): Enable bytecheck (#7280)
**Description:**

Second attempt to enable bytecheck. This PR does not have versioned struct yet, just enabling bytecheck wherever possible. Also, it is for the ast only yet, so transform metadata and others might need this later.

PR seems to be passing all the ci, but as we've experienced before, there might be some unexpected outcomes with the release. Maybe better to hold this until clear https://github.com/swc-project/swc/issues/7238, then land as a separate release.
2023-05-06 03:54:25 +00:00
SWC Bot
b60a33001a chore: Publish crates 2023-05-05 08:22:21 +00:00
Cong-Cong Pan
b180d09e1d
fix(xml/codegen): Escape < and > in child (#7351) 2023-05-05 08:20:09 +00:00