Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit b2b3ae3

Browse files
Docs for importAssertions removal
1 parent eccff2f commit b2b3ae3

3 files changed

Lines changed: 128 additions & 89 deletions

File tree

docs/parser.md

Lines changed: 80 additions & 77 deletions
Original file line numberDiff line numberDiff line change
@@ -32,15 +32,16 @@ mind. When in doubt, use `.parse()`.
3232
<details>
3333
<summary>History</summary>
3434

35-
| Version | Changes |
36-
| --- | --- |
37-
| `v7.23.0` | Added `createImportExpressions` |
35+
| Version | Changes |
36+
| --------- | -------------------------------------------------- |
37+
| `v7.23.0` | Added `createImportExpressions` |
3838
| `v7.21.0` | Added `allowNewTargetOutsideFunction` and `annexb` |
39-
| `v7.16.0` | Added `startColumn` |
40-
| `v7.15.0` | Added `attachComment` |
41-
| `v7.7.0` | Added `errorRecovery` |
42-
| `v7.5.0` | Added `allowUndeclaredExports` |
43-
| `v7.2.0` | Added `createParenthesizedExpressions` |
39+
| `v7.16.0` | Added `startColumn` |
40+
| `v7.15.0` | Added `attachComment` |
41+
| `v7.7.0` | Added `errorRecovery` |
42+
| `v7.5.0` | Added `allowUndeclaredExports` |
43+
| `v7.2.0` | Added `createParenthesizedExpressions` |
44+
4445
</details>
4546

4647
- **allowImportExportEverywhere**: By default, `import` and `export`
@@ -194,70 +195,69 @@ require("@babel/parser").parse("code", {
194195

195196
#### Language extensions
196197

197-
198198
<details>
199199
<summary>History</summary>
200200

201-
| Version | Changes |
202-
| --- | --- |
201+
| Version | Changes |
202+
| -------- | ------------------- |
203203
| `v7.6.0` | Added `v8intrinsic` |
204-
</details>
205-
206-
| Name | Code Example |
207-
|------|--------------|
208-
| `flow` ([repo](https://github.com/facebook/flow)) | `var a: string = "";` |
209-
| `flowComments` ([docs](https://flow.org/en/docs/types/comments/)) | <code>/&ast;:: type Foo = \{...}; &ast;/</code> |
210-
| `jsx` ([repo](https://facebook.github.io/jsx/)) | `<a attr="b">{s}</a>` |
211-
| `typescript` ([repo](https://github.com/Microsoft/TypeScript)) | `var a: string = "";` |
212-
| `v8intrinsic` | `%DebugPrint(foo);` |
213204

205+
</details>
214206

207+
| Name | Code Example |
208+
| ----------------------------------------------------------------- | ----------------------------------------- |
209+
| `flow` ([repo](https://github.com/facebook/flow)) | `var a: string = "";` |
210+
| `flowComments` ([docs](https://flow.org/en/docs/types/comments/)) | <code>/\*:: type Foo = \{...}; \*/</code> |
211+
| `jsx` ([repo](https://facebook.github.io/jsx/)) | `<a attr="b">{s}</a>` |
212+
| `typescript` ([repo](https://github.com/Microsoft/TypeScript)) | `var a: string = "";` |
213+
| `v8intrinsic` | `%DebugPrint(foo);` |
215214

216215
#### ECMAScript [proposals](https://github.com/babel/proposals)
217216

218217
<details>
219218
<summary>History</summary>
220219

221-
| Version | Changes |
222-
| --- | --- |
223-
| `v7.23.0` | Added `sourcePhaseImports`, `deferredImportEvaluation`, `optionalChainingAssign` |
224-
| `v7.22.0` | Enabled `regexpUnicodeSets` by default, added `importAttributes` |
225-
| `v7.20.0` | Added `explicitResourceManagement`, `importReflection` |
226-
| `v7.17.0` | Added `regexpUnicodeSets`, `destructuringPrivate`, `decoratorAutoAccessors` |
227-
| `v7.15.0` | Added `hack` to the `proposal` option of `pipelineOperator`. Moved `topLevelAwait`, `privateIn` to Latest ECMAScript features |
220+
| Version | Changes |
221+
| --------- | ------------------------------------------------------------------------------------------------------------------------------------------------------- |
222+
| `v7.23.0` | Added `sourcePhaseImports`, `deferredImportEvaluation`, `optionalChainingAssign` |
223+
| `v7.22.0` | Enabled `regexpUnicodeSets` by default, added `importAttributes` |
224+
| `v7.20.0` | Added `explicitResourceManagement`, `importReflection` |
225+
| `v7.17.0` | Added `regexpUnicodeSets`, `destructuringPrivate`, `decoratorAutoAccessors` |
226+
| `v7.15.0` | Added `hack` to the `proposal` option of `pipelineOperator`. Moved `topLevelAwait`, `privateIn` to Latest ECMAScript features |
228227
| `v7.14.0` | Added `asyncDoExpressions`. Moved `classProperties`, `classPrivateProperties`, `classPrivateMethods`, `moduleStringNames` to Latest ECMAScript features |
229-
| `v7.13.0` | Added `moduleBlocks` |
230-
| `v7.12.0` | Added `classStaticBlock`, `moduleStringNames` |
231-
| `v7.11.0` | Added `decimal` |
232-
| `v7.10.0` | Added `privateIn` |
233-
| `v7.9.0` | Added `recordAndTuple` |
234-
| `v7.7.0` | Added `topLevelAwait` |
235-
| `v7.4.0` | Added `partialApplication` |
236-
| `v7.2.0` | Added `classPrivateMethods` |
228+
| `v7.13.0` | Added `moduleBlocks` |
229+
| `v7.12.0` | Added `classStaticBlock`, `moduleStringNames` |
230+
| `v7.11.0` | Added `decimal` |
231+
| `v7.10.0` | Added `privateIn` |
232+
| `v7.9.0` | Added `recordAndTuple` |
233+
| `v7.7.0` | Added `topLevelAwait` |
234+
| `v7.4.0` | Added `partialApplication` |
235+
| `v7.2.0` | Added `classPrivateMethods` |
236+
237237
</details>
238238

239-
| Name | Code Example |
240-
| -------------------------------------------------------------------------------------------------------- | ---------------------------------------------------------------- |
241-
| `asyncDoExpressions` ([proposal](https://github.com/tc39/proposal-async-do-expressions)) | `async do { await requestAPI().json() }` |
242-
| `decimal` ([proposal](https://github.com/tc39/proposal-decimal)) | `0.3m` |
243-
| `decorators` ([proposal](https://github.com/tc39/proposal-decorators)) <br/> `decorators-legacy` | `@a class A {}` |
244-
| `decoratorAutoAccessors` ([proposal](https://github.com/tc39/proposal-decorators)) | `class Example { @reactive accessor myBool = false; }` |
245-
| `deferredImportEvaluation` ([proposal](https://github.com/tc39/proposal-defer-import-eval)) | `import defer * as ns from "dep";` |
246-
| `destructuringPrivate` ([proposal](https://github.com/tc39/proposal-destructuring-private)) | `class Example { #x = 1; method() { const { #x: x } = this; } }` |
247-
| `doExpressions` ([proposal](https://github.com/tc39/proposal-do-expressions)) | `var a = do { if (true) { 'hi'; } };` |
248-
| `explicitResourceManagement` ([proposal](https://github.com/tc39/proposal-explicit-resource-management)) | `using reader = getReader()` |
249-
| `exportDefaultFrom` ([proposal](https://github.com/tc39/ecmascript-export-default-from)) | `export v from "mod"` |
250-
| `functionBind` ([proposal](https://github.com/zenparsing/es-function-bind)) | `a::b`, `::console.log` |
251-
| `functionSent` ([proposal](https://github.com/tc39/proposal-function.sent)) | `function.sent` |
252-
| `importAttributes` ([proposal](https://github.com/tc39/proposal-import-attributes)) <br/> `importAssertions` (⚠️ deprecated) | `import json from "./foo.json" with { type: "json" };` |
253-
| `importReflection` ([proposal](https://github.com/tc39/proposal-import-reflection)) | `import module foo from "./foo.wasm";` |
254-
| `moduleBlocks` ([proposal](https://github.com/tc39/proposal-js-module-blocks)) | `let m = module { export let y = 1; };` |
255-
| `optionalChainingAssign` ([proposal](https://github.com/tc39/proposal-optional-chaining-assignment)) | `x?.prop = 2` |
256-
| `partialApplication` ([proposal](https://github.com/babel/proposals/issues/32)) | `f(?, a)` |
257-
| `pipelineOperator` ([proposal](https://github.com/babel/proposals/issues/29)) | <code>a &#124;> b</code> |
258-
| `recordAndTuple` ([proposal](https://github.com/tc39/proposal-record-tuple)) | `#{x: 1}`, `#[1, 2]` |
259-
| `sourcePhaseImports` ([proposal](https://github.com/tc39/proposal-source-phase-imports)) | `import source x from "./x"` |
260-
| `throwExpressions` ([proposal](https://github.com/babel/proposals/issues/23)) | `() => throw new Error("")` |
239+
| Name | Code Example |
240+
| ----------------------------------------------------------------------------------------------------------------------------------------- | ---------------------------------------------------------------- |
241+
| `asyncDoExpressions` ([proposal](https://github.com/tc39/proposal-async-do-expressions)) | `async do { await requestAPI().json() }` |
242+
| `decimal` ([proposal](https://github.com/tc39/proposal-decimal)) | `0.3m` |
243+
| `decorators` ([proposal](https://github.com/tc39/proposal-decorators)) <br/> `decorators-legacy` | `@a class A {}` |
244+
| `decoratorAutoAccessors` ([proposal](https://github.com/tc39/proposal-decorators)) | `class Example { @reactive accessor myBool = false; }` |
245+
| `deferredImportEvaluation` ([proposal](https://github.com/tc39/proposal-defer-import-eval)) | `import defer * as ns from "dep";` |
246+
| `destructuringPrivate` ([proposal](https://github.com/tc39/proposal-destructuring-private)) | `class Example { #x = 1; method() { const { #x: x } = this; } }` |
247+
| `doExpressions` ([proposal](https://github.com/tc39/proposal-do-expressions)) | `var a = do { if (true) { 'hi'; } };` |
248+
| `explicitResourceManagement` ([proposal](https://github.com/tc39/proposal-explicit-resource-management)) | `using reader = getReader()` |
249+
| `exportDefaultFrom` ([proposal](https://github.com/tc39/ecmascript-export-default-from)) | `export v from "mod"` |
250+
| `functionBind` ([proposal](https://github.com/zenparsing/es-function-bind)) | `a::b`, `::console.log` |
251+
| `functionSent` ([proposal](https://github.com/tc39/proposal-function.sent)) | `function.sent` |
252+
| `importAttributes` ([proposal](https://github.com/tc39/proposal-import-attributes)) [<br/> `importAssertions` (⚠️ deprecated)](:::babel7) | `import json from "./foo.json" with { type: "json" };` |
253+
| `importReflection` ([proposal](https://github.com/tc39/proposal-import-reflection)) | `import module foo from "./foo.wasm";` |
254+
| `moduleBlocks` ([proposal](https://github.com/tc39/proposal-js-module-blocks)) | `let m = module { export let y = 1; };` |
255+
| `optionalChainingAssign` ([proposal](https://github.com/tc39/proposal-optional-chaining-assignment)) | `x?.prop = 2` |
256+
| `partialApplication` ([proposal](https://github.com/babel/proposals/issues/32)) | `f(?, a)` |
257+
| `pipelineOperator` ([proposal](https://github.com/babel/proposals/issues/29)) | <code>a &#124;> b</code> |
258+
| `recordAndTuple` ([proposal](https://github.com/tc39/proposal-record-tuple)) | `#{x: 1}`, `#[1, 2]` |
259+
| `sourcePhaseImports` ([proposal](https://github.com/tc39/proposal-source-phase-imports)) | `import source x from "./x"` |
260+
| `throwExpressions` ([proposal](https://github.com/babel/proposals/issues/23)) | `() => throw new Error("")` |
261261

262262
#### Latest ECMAScript features
263263

@@ -277,7 +277,7 @@ You should enable these features only if you are using an older version.
277277
| `logicalAssignment` ([proposal](https://github.com/tc39/proposal-logical-assignment)) | `a &&= b` |
278278
| `moduleStringNames` ([proposal](https://github.com/tc39/ecma262/pull/2154)) | `import { "😄" as smile } from "emoji";` |
279279
| `nullishCoalescingOperator` ([proposal](https://github.com/babel/proposals/issues/14)) | `a ?? b` |
280-
| `numericSeparator` ([proposal](https://github.com/tc39/proposal-numeric-separator)) | `1_000_000` |
280+
| `numericSeparator` ([proposal](https://github.com/tc39/proposal-numeric-separator)) | `1_000_000` |
281281
| `objectRestSpread` ([proposal](https://github.com/tc39/proposal-object-rest-spread)) | `var a = { b, ...c };` |
282282
| `optionalCatchBinding` ([proposal](https://github.com/babel/proposals/issues/7)) | `try {throw 0;} catch{do();}` |
283283
| `optionalChaining` ([proposal](https://github.com/tc39/proposal-optional-chaining)) | `a?.b` |
@@ -290,13 +290,14 @@ You should enable these features only if you are using an older version.
290290
<details>
291291
<summary>History</summary>
292292

293-
| Version | Changes |
294-
| --- | --- |
293+
| Version | Changes |
294+
| -------- | --------------------------------------------------------------------------------------------------------------------------------------------- |
295295
| `7.21.0` | The default behavior of the `decorators`' `decoratorsBeforeExport` option is to allow decorators either before or after the `export` keyword. |
296296
| `7.19.0` | The `syntaxType` option of the `recordAndTuple` plugin defaults to `hash`; added `allowCallParenthesized` option for the `decorators` plugin. |
297-
| `7.17.0` | Added `@@` and `^^` to the `topicToken` option of the `hack` pipeline operator |
298-
| `7.16.0` | Added `disallowAmbiguousJSXLike` for `typescript` plugin. Added `^` to the `topicToken` option of the `hack` pipeline operators |
299-
| `7.14.0` | Added `dts` for `typescript` plugin |
297+
| `7.17.0` | Added `@@` and `^^` to the `topicToken` option of the `hack` pipeline operator |
298+
| `7.16.0` | Added `disallowAmbiguousJSXLike` for `typescript` plugin. Added `^` to the `topicToken` option of the `hack` pipeline operators |
299+
| `7.14.0` | Added `dts` for `typescript` plugin |
300+
300301
</details>
301302

302303
<!-- TODO: Is this note still true? Don't we raise an exception? -->
@@ -309,7 +310,7 @@ When a plugin is specified multiple times, only the first options are considered
309310

310311
- `deprecatedAssertSyntax` (`boolean`, defaults to `false`)
311312

312-
When `true`, allow parsing import attributes using the [deprecated](https://tc39.es/proposal-import-attributes/#sec-deprecated-assert-keyword-for-import-attributes) `assert` keyword. This matches the syntax originally supported by the `importAssertions` parser plugin.
313+
When `true`, allow parsing an old version of the import attributes, which used the `assert` keyword instead of `with`. [This matches the syntax originally supported by the `importAssertions` parser plugin.](:::babel7)
313314

314315
- `decorators`:
315316

@@ -319,20 +320,21 @@ When a plugin is specified multiple times, only the first options are considered
319320

320321
- `decoratorsBeforeExport` (`boolean`)
321322

322-
By default decorators on exported classes can be placed either before or after the `export` keyword. When this option is set, decorators will only be allowed in the specified position.
323+
By default decorators on exported classes can be placed either before or after the `export` keyword. When this option is set, decorators will only be allowed in the specified position.
323324

324-
```js title="JavaScript"
325-
// decoratorsBeforeExport: true
326-
@dec
327-
export class C {}
325+
```js title="JavaScript"
326+
// decoratorsBeforeExport: true
327+
@dec
328+
export class C {}
328329

329-
// decoratorsBeforeExport: false
330-
export @dec class C {}
331-
```
330+
// decoratorsBeforeExport: false
331+
export @dec class C {}
332+
```
332333

333-
:::caution
334-
This option is deprecated and will be removed in a future version. Code that is valid when this option is explicitly set to `true` or `false` is also valid when this option is not set.
335-
:::
334+
:::caution
335+
336+
This option is deprecated and will be removed in a future version. Code that is valid when this option is explicitly set to `true` or `false` is also valid when this option is not set.
337+
:::
336338

337339
- `optionalChainingAssign`:
338340

@@ -384,9 +386,10 @@ This option is deprecated and will be removed in a future version. Code that is
384386
<details>
385387
<summary>History</summary>
386388

387-
| Version | Changes |
388-
| --- | --- |
389+
| Version | Changes |
390+
| --------- | ----------------- |
389391
| `v7.14.0` | Added error codes |
392+
390393
</details>
391394

392395
Error codes are useful for handling the errors thrown by `@babel/parser`.

0 commit comments

Comments
 (0)