Skip to content

Commit

Permalink
Merge branch 'main' of https://github.com/esbuild/esbuild.github.io i…
Browse files Browse the repository at this point in the history
…nto sync-b740d986
  • Loading branch information
docschina-bot committed May 27, 2024
2 parents bd4d81b + b740d98 commit 4485f81
Show file tree
Hide file tree
Showing 7 changed files with 265 additions and 217 deletions.
382 changes: 191 additions & 191 deletions package-lock.json

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"dependencies": {
"esbuild": "0.21.0",
"esbuild": "0.21.4",
"fast-watch": "1.0.0",
"highlight.js": "10.4.1",
"js-yaml": "3.14.0",
Expand Down
9 changes: 9 additions & 0 deletions src/content/api.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7888,12 +7888,18 @@ body:
<li>
**JS:**
<ul>
<li><details><summary>`assert-to-with`</summary><pre>{{ FORMAT_MESSAGES('import data from "./data.json" assert { type: "json" }', { sourcefile: 'example.js', supported: { 'import-assertions': false } }) }}</pre></details></li>
<li><details><summary>`assert-type-json`</summary><pre>{{ FORMAT_MESSAGES({ 'example.js': 'import * as data from "./data.json" assert { type: "json" }; console.log(data.value)', 'data.json': '{}' }, { bundle: true }) }}</pre></details></li>
<li><details><summary>`assign-to-constant`</summary><pre>{{ FORMAT_MESSAGES('const foo = 1; foo = 2', { sourcefile: 'example.js' }) }}</pre></details></li>
<li><details><summary>`assign-to-define`</summary><pre>{{ FORMAT_MESSAGES('DEFINE = false', { sourcefile: 'example.js', define: { DEFINE: 'true' } }) }}</pre></details></li>
<li><details><summary>`assign-to-import`</summary><pre>{{ FORMAT_MESSAGES('import foo from "foo"; foo = null', { sourcefile: 'example.js' }) }}</pre></details></li>
<li><details><summary>`call-import-namespace`</summary><pre>{{ FORMAT_MESSAGES('import * as foo from "foo"; foo()', { sourcefile: 'example.js', format: 'esm' }) }}</pre></details></li>
<li><details><summary>`class-name-will-throw`</summary><pre>{{ FORMAT_MESSAGES('class Foo { static key = "foo"; static [Foo.key] = 123 }', { sourcefile: 'example.js' }) }}</pre></details></li>
<li><details><summary>`commonjs-variable-in-esm`</summary><pre>{{ FORMAT_MESSAGES('exports.foo = 1; export let bar = 2', { sourcefile: 'example.js', format: 'esm' }) }}</pre></details></li>
<li><details><summary>`delete-super-property`</summary><pre>{{ FORMAT_MESSAGES('class Foo extends Object { foo() { delete super.foo } }', { sourcefile: 'example.js' }) }}</pre></details></li>
<li><details><summary>`direct-eval`</summary><pre>{{ FORMAT_MESSAGES('let apparentlyUnused; eval("actuallyUse(apparentlyUnused)")', { sourcefile: 'example.js', logOverride: { 'direct-eval': 'warning' } }) }}</pre></details></li>
<li><details><summary>`duplicate-case`</summary><pre>{{ FORMAT_MESSAGES('switch (foo) { case 1: return 1; case 1: return 2 }', { sourcefile: 'example.js' }) }}</pre></details></li>
<li><details><summary>`duplicate-class-member`</summary><pre>{{ FORMAT_MESSAGES('class Foo { x = 1; x = 2 }', { sourcefile: 'example.js' }) }}</pre></details></li>
<li><details><summary>`duplicate-object-key`</summary><pre>{{ FORMAT_MESSAGES('foo = { bar: 1, bar: 2 }', { sourcefile: 'example.js' }) }}</pre></details></li>
<li><details><summary>`empty-import-meta`</summary><pre>{{ FORMAT_MESSAGES('foo = import.meta', { sourcefile: 'example.js', target: 'chrome50' }) }}</pre></details></li>
<li><details><summary>`equals-nan`</summary><pre>{{ FORMAT_MESSAGES('foo = foo.filter(x => x !== NaN)', { sourcefile: 'example.js' }) }}</pre></details></li>
Expand All @@ -7905,6 +7911,9 @@ body:
<li><details><summary>`private-name-will-throw`</summary><pre>{{ FORMAT_MESSAGES('class Foo { get #foo() {} bar() { this.#foo++ } }', { sourcefile: 'example.js' }) }}</pre></details></li>
<li><details><summary>`semicolon-after-return`</summary><pre>{{ FORMAT_MESSAGES('return\nx', { sourcefile: 'example.js' }) }}</pre></details></li>
<li><details><summary>`suspicious-boolean-not`</summary><pre>{{ FORMAT_MESSAGES('if (!foo in bar) {\n}', { sourcefile: 'example.js' }) }}</pre></details></li>
<li><details><summary>`suspicious-define`</summary><pre>{{ FORMAT_MESSAGES('', { sourcefile: 'example.js', define: { 'process.env.NODE_ENV': 'production' } }) }}</pre></details></li>
<li><details><summary>`suspicious-logical-operator`</summary><pre>{{ FORMAT_MESSAGES('const isInRange = x => 0 && x <= 1', { sourcefile: 'example.js' }) }}</pre></details></li>
<li><details><summary>`suspicious-nullish-coalescing`</summary><pre>{{ FORMAT_MESSAGES('return name === user.name ?? ""', { sourcefile: 'example.js' }) }}</pre></details></li>
<li><details><summary>`this-is-undefined-in-esm`</summary><pre>{{ FORMAT_MESSAGES('this.foo = 1; export let bar = 2', { sourcefile: 'example.js', bundle: true, logOverride: { 'this-is-undefined-in-esm': 'warning' } }) }}</pre></details></li>
<li><details><summary>`unsupported-dynamic-import`</summary><pre>{{ FORMAT_MESSAGES('import(foo)', { sourcefile: 'example.js', bundle: true, logOverride: { 'unsupported-dynamic-import': 'warning' } }) }}</pre></details></li>
<li><details><summary>`unsupported-jsx-comment`</summary><pre>{{ FORMAT_MESSAGES('// @jsx 123', { sourcefile: 'example.jsx', loader: 'jsx' }) }}</pre></details></li>
Expand Down
58 changes: 33 additions & 25 deletions src/content/content-types.yml
Original file line number Diff line number Diff line change
Expand Up @@ -44,31 +44,39 @@ body:
These syntax features are conditionally transformed for older browsers depending on the configured language [target](/api/#target):
- table: |
| Syntax transform | Transformed when `--target` is below | Example |
|---------------------------------------------------------------------------------------|--------------------------------------|-----------------------------|
| [Exponentiation operator](https://github.com/tc39/proposal-exponentiation-operator) | `es2016` | `a ** b` |
| [Async functions](https://github.com/tc39/ecmascript-asyncawait) | `es2017` | `async () => {}` |
| [Asynchronous iteration](https://github.com/tc39/proposal-async-iteration) | `es2018` | `for await (let x of y) {}` |
| [Async generators](https://github.com/tc39/proposal-async-iteration) | `es2018` | `async function* foo() {}` |
| [Spread properties](https://github.com/tc39/proposal-object-rest-spread) | `es2018` | `let x = {...y}` |
| [Rest properties](https://github.com/tc39/proposal-object-rest-spread) | `es2018` | `let {...x} = y` |
| [Optional catch binding](https://github.com/tc39/proposal-optional-catch-binding) | `es2019` | `try {} catch {}` |
| [Optional chaining](https://github.com/tc39/proposal-optional-chaining) | `es2020` | `a?.b` |
| [Nullish coalescing](https://github.com/tc39/proposal-nullish-coalescing) | `es2020` | `a ?? b` |
| [`import.meta`](https://github.com/tc39/proposal-import-meta) | `es2020` | `import.meta` |
| [Logical assignment operators](https://github.com/tc39/proposal-logical-assignment) | `es2021` | `a ??= b` |
| [Class instance fields](https://github.com/tc39/proposal-class-fields) | `es2022` | `class { x }` |
| [Static class fields](https://github.com/tc39/proposal-static-class-features) | `es2022` | `class { static x }` |
| [Private instance methods](https://github.com/tc39/proposal-private-methods) | `es2022` | `class { #x() {} }` |
| [Private instance fields](https://github.com/tc39/proposal-class-fields) | `es2022` | `class { #x }` |
| [Private static methods](https://github.com/tc39/proposal-static-class-features) | `es2022` | `class { static #x() {} }` |
| [Private static fields](https://github.com/tc39/proposal-static-class-features) | `es2022` | `class { static #x }` |
| [Ergonomic brand checks](https://github.com/tc39/proposal-private-fields-in-in) | `es2022` | `#x in y` |
| [Class static blocks](https://github.com/tc39/proposal-class-static-block) | `es2022` | `class { static {} }` |
| [Import assertions](https://github.com/tc39/proposal-import-assertions) | `esnext` | `import "x" assert {}` |
| [Auto-accessors](https://github.com/tc39/proposal-decorators#class-auto-accessors) | `esnext` | `class { accessor x }` |
| [`using` declarations](https://github.com/tc39/proposal-explicit-resource-management) | `esnext` | `using x = y` |
| [Decorators](https://github.com/tc39/proposal-decorators) | `esnext` | `@foo class Bar {}` |
| Syntax transform | Transformed when `--target` is below | Example |
|---------------------------------------------------------------------------------------|--------------------------------------|------------------------------------|
| [Exponentiation operator](https://github.com/tc39/proposal-exponentiation-operator) | `es2016` | `a ** b` |
| [Async functions](https://github.com/tc39/ecmascript-asyncawait) | `es2017` | `async () => {}` |
| [Asynchronous iteration](https://github.com/tc39/proposal-async-iteration) | `es2018` | `for await (let x of y) {}` |
| [Async generators](https://github.com/tc39/proposal-async-iteration) | `es2018` | `async function* foo() {}` |
| [Spread properties](https://github.com/tc39/proposal-object-rest-spread) | `es2018` | `let x = {...y}` |
| [Rest properties](https://github.com/tc39/proposal-object-rest-spread) | `es2018` | `let {...x} = y` |
| [Optional catch binding](https://github.com/tc39/proposal-optional-catch-binding) | `es2019` | `try {} catch {}` |
| [Optional chaining](https://github.com/tc39/proposal-optional-chaining) | `es2020` | `a?.b` |
| [Nullish coalescing](https://github.com/tc39/proposal-nullish-coalescing) | `es2020` | `a ?? b` |
| [`import.meta`](https://github.com/tc39/proposal-import-meta) | `es2020` | `import.meta` |
| [Logical assignment operators](https://github.com/tc39/proposal-logical-assignment) | `es2021` | `a ??= b` |
| [Class instance fields](https://github.com/tc39/proposal-class-fields) | `es2022` | `class { x }` |
| [Static class fields](https://github.com/tc39/proposal-static-class-features) | `es2022` | `class { static x }` |
| [Private instance methods](https://github.com/tc39/proposal-private-methods) | `es2022` | `class { #x() {} }` |
| [Private instance fields](https://github.com/tc39/proposal-class-fields) | `es2022` | `class { #x }` |
| [Private static methods](https://github.com/tc39/proposal-static-class-features) | `es2022` | `class { static #x() {} }` |
| [Private static fields](https://github.com/tc39/proposal-static-class-features) | `es2022` | `class { static #x }` |
| [Ergonomic brand checks](https://github.com/tc39/proposal-private-fields-in-in) | `es2022` | `#x in y` |
| [Class static blocks](https://github.com/tc39/proposal-class-static-block) | `es2022` | `class { static {} }` |
| [Import assertions](https://github.com/tc39/proposal-import-assertions) | `esnext` | `import "x" assert {}`<sup>1</sup> |
| [Import attributes](https://github.com/tc39/proposal-import-attributes) | `esnext` | `import "x" with {}` |
| [Auto-accessors](https://github.com/tc39/proposal-decorators#class-auto-accessors) | `esnext` | `class { accessor x }` |
| [`using` declarations](https://github.com/tc39/proposal-explicit-resource-management) | `esnext` | `using x = y` |
| [Decorators](https://github.com/tc39/proposal-decorators) | `esnext` | `@foo class Bar {}` |
- p: >
<footer>
<sup>1</sup> Import assertions never made it into the JavaScript
specification. They are deprecated in favor of import attributes
and are actively being removed from JavaScript runtimes.
</footer>
- p: >
These syntax features are currently always passed through un-transformed:
Expand Down
25 changes: 25 additions & 0 deletions src/content/plugins.yml
Original file line number Diff line number Diff line change
Expand Up @@ -363,6 +363,7 @@ body:
resolveDir: string;
kind: ResolveKind;
pluginData: any;
with: Record<string, string>;
}
type ResolveKind =
Expand All @@ -384,6 +385,7 @@ body:
ResolveDir string
Kind ResolveKind
PluginData interface{}
With map[string]string
}
const (
Expand Down Expand Up @@ -458,6 +460,17 @@ body:
[on-load callback](#on-load) that loaded this file.
</p>
- >
`with`
<p>
This contains a map of the [import attributes](https://github.com/tc39/proposal-import-attributes)
that were present on the import statement used to import this module. For
example, a module imported using <code>with { <wbr>type: <wbr>'json' }</code>
will provide a `with` value of <code>{ type: <wbr>'json' }</code> to plugins.
You can use this to resolve to a different path depending on the import
attributes.
</p>
- h3: On-resolve results

- p: >
Expand Down Expand Up @@ -1602,6 +1615,7 @@ body:
namespace?: string;
resolveDir?: string;
pluginData?: any;
with?: Record<string, string>;
}
type ResolveKind =
Expand All @@ -1620,6 +1634,7 @@ body:
Namespace string
ResolveDir string
PluginData interface{}
With map[string]string
}
const (
Expand Down Expand Up @@ -1678,6 +1693,16 @@ body:
match this import path. The meaning of this data is left entirely up to you.
</p>
- >
`with`
<p>
This is the [import attributes](https://github.com/tc39/proposal-import-attributes)
assocated with the import statement for this path. For example, a `with` value of
<code>{ type: <wbr>'json' }</code> would be appropriate for a module imported using
<code>with { <wbr>type: <wbr>'json' }</code> attributes on the import statement.
This information isn't used by esbuild but may be used by [on-resolve callbacks](#on-resolve).
</p>
- h3: Resolve results

- p: >
Expand Down
1 change: 1 addition & 0 deletions src/scripts/render.js
Original file line number Diff line number Diff line change
Expand Up @@ -426,6 +426,7 @@ async function formatMessagesInText(text) {
result = '<span>' + result.replace(/\033\[([^m]*)m/g, (_, escape) => {
switch (escape) {
case '1': return '</span><span class="color-bold">'
case '4': return '</span><span class="color-underline">'
case '31': return '</span><span class="color-red">'
case '32': return '</span><span class="color-green">'
case '33': return '</span><span class="color-yellow">'
Expand Down
5 changes: 5 additions & 0 deletions src/scripts/style.css
Original file line number Diff line number Diff line change
Expand Up @@ -420,6 +420,11 @@ body[data-os2=windows] pre.windows2 {
color: var(--fg-on);
}

.color-underline {
text-decoration: underline;
color: var(--fg-on);
}

.bg-red {
background: #e24834;
}
Expand Down

0 comments on commit 4485f81

Please sign in to comment.