Skip to content

Commit

Permalink
Add loose mode warning (#233)
Browse files Browse the repository at this point in the history
  • Loading branch information
BaffinLee authored Dec 16, 2023
1 parent 418ee1e commit 010b513
Showing 1 changed file with 22 additions and 1 deletion.
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import { Callout } from 'nextra-theme-docs'

# Compilation

Compilation works out of the box with SWC and does not require customization. Optionally, you can override the configuration. Here are the defaults:
Expand Down Expand Up @@ -104,7 +106,7 @@ Type: Bool
Optional.
Type: Bool

Enable loose mode.
Enable loose mode. See [jsc.loose](#jscloose) also.

### `env.skip`

Expand Down Expand Up @@ -257,6 +259,25 @@ Starting from `@swc/core` v1.0.27, you can specify the target environment by usi

Starting from `@swc/core` v1.1.4, you can enable "loose" transformations by enabling `jsc.loose` which works like `babel-preset-env` [loose mode](https://2ality.com/2015/12/babel6-loose-mode.html).

<Callout emoji="⚠️">
These [assumptions](https://babeljs.io/docs/assumptions) are made in loose mode by default, you might get unexpected reault if your code doesn't meet these assumptions.
- [privateFieldsAsProperties](https://babeljs.io/docs/assumptions#privatefieldsasproperties)
- [setPublicClassFields](https://babeljs.io/docs/assumptions#setpublicclassfields)
- [constantSuper](https://babeljs.io/docs/assumptions#constantsuper)
- [noDocumentAll](https://babeljs.io/docs/assumptions#nodocumentall)
- [pureGetters](https://babeljs.io/docs/assumptions#puregetters)
- [objectRestNoSymbols](https://babeljs.io/docs/assumptions#objectrestnosymbols)
- [setSpreadProperties](https://babeljs.io/docs/assumptions#setspreadproperties)
- ignoreFunctionName
- [ignoreFunctionLength](https://babeljs.io/docs/assumptions#ignorefunctionlength)
- [ignoreToPrimitiveHint](https://babeljs.io/docs/assumptions#ignoretoprimitivehint)
- [mutableTemplateObject](https://babeljs.io/docs/assumptions#mutabletemplateobject)
- [noClassCalls](https://babeljs.io/docs/assumptions#noclasscalls)
- [setClassMethods](https://babeljs.io/docs/assumptions#setclassmethods)
- [superIsCallableConstructor](https://babeljs.io/docs/assumptions#superiscallableconstructor)
- [iterableIsArray](https://babeljs.io/docs/assumptions#iterableisarray)
</Callout>

```json filename=".swcrc" copy
{
"jsc": {
Expand Down

1 comment on commit 010b513

@vercel
Copy link

@vercel vercel bot commented on 010b513 Dec 16, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.