3.9.98 • Published 10 months ago

@taktikorg/quia-veniam v3.9.98

Weekly downloads
-
License
MIT
Repository
github
Last release
10 months ago

@taktikorg/quia-veniam

Import attributes for acorn.

Parses to the stage3 Import Attributes ESTree extension.

Supports both the with and deprecated assert keywords. Both are parsed to the same tree structure. A property attributesKeyword is added to expose which keyword was present in the source.

Usage

npm install @taktikorg/quia-veniam
import * as acorn from 'acorn'
import importAttributes from '@taktikorg/quia-veniam'

const Parser = acorn.Parser.extend(
  importAttributes({ with: true, assert: true })
)

const source = `
import config from 'config.json' with { type: 'json' }
`.trim()
const tree = Parser.parse(source, {
  ecmaVersion: 'latest',
  sourceType: 'module'
})
{
  type: 'Program',
  body: [{
    type: 'ImportDeclaration',
    specifiers: [..],
    source: ..,
    attributesKeyword: 'with',
    attributes: [{
      type: 'ImportAttribute',
      key: { type: 'Identifier', name: 'type' },
      value: { type: 'Literal', value: 'json' }
    }]
  }]
}

API

importAttributes(options)

The default export is a factory function which produces a plugin. Pass an options object to configure which keywords to recognize.

Options

NameTypeDescriptionDefault
withbooleanRecognize with as an import attributes keyword.true
assertbooleanRecognize assert as an import attributes keyword.false

ESTree

Extensions to the Import Attributes ESTree structure. attributesKeyword is null when no attributes are present.

ImportDeclaration

extend interface ImportDeclaration {
    attributesKeyword: "with" | "assert" | null;
}

ExportNamedDeclaration

extend interface ExportNamedDeclaration {
    attributesKeyword: "with" | "assert" | null;
}

ExportAllDeclaration

extend interface ExportAllDeclaration {
    attributesKeyword: "with" | "assert" | null;
}
3.9.98

10 months ago

3.9.97

10 months ago

3.9.96

10 months ago

3.9.95

10 months ago

3.8.95

10 months ago

3.8.94

10 months ago

3.8.93

11 months ago

3.8.92

11 months ago

3.8.91

11 months ago

3.8.90

11 months ago

3.8.89

11 months ago

3.8.88

11 months ago

3.8.87

11 months ago

3.8.86

11 months ago

3.8.85

11 months ago

3.8.84

11 months ago

3.8.83

11 months ago

3.8.82

11 months ago

3.8.81

11 months ago

3.8.80

11 months ago

3.8.79

11 months ago

3.7.79

11 months ago

3.7.78

11 months ago

3.7.77

11 months ago

3.7.76

11 months ago

3.6.76

11 months ago

3.6.75

11 months ago

3.6.74

11 months ago

3.6.73

11 months ago

3.6.72

11 months ago

3.6.71

11 months ago

3.6.70

11 months ago

2.6.70

11 months ago

2.6.69

11 months ago

2.5.69

11 months ago

2.5.68

11 months ago

2.5.67

12 months ago

2.5.66

12 months ago

2.5.65

12 months ago

2.5.64

12 months ago

2.5.63

12 months ago

2.5.62

12 months ago

2.5.61

12 months ago

2.5.60

12 months ago

2.5.59

12 months ago

2.5.58

12 months ago

2.5.57

12 months ago

2.5.56

12 months ago

2.5.55

12 months ago

2.5.54

12 months ago

2.5.53

12 months ago

2.5.52

12 months ago

2.5.51

12 months ago

2.5.50

12 months ago

2.5.49

12 months ago

2.5.48

12 months ago

2.5.47

1 year ago

2.5.46

1 year ago

2.5.45

1 year ago

2.4.45

1 year ago

2.4.44

1 year ago

2.4.43

1 year ago

2.4.42

1 year ago

2.4.41

1 year ago

2.4.40

1 year ago

2.3.40

1 year ago

2.3.39

1 year ago

2.3.38

1 year ago

2.3.37

1 year ago

2.3.36

1 year ago

2.3.35

1 year ago

2.3.34

1 year ago

2.3.33

1 year ago

2.3.32

1 year ago

2.3.31

1 year ago

2.2.31

1 year ago

2.2.30

1 year ago

2.2.29

1 year ago

2.2.28

1 year ago

2.2.27

1 year ago

2.2.26

1 year ago

2.2.25

1 year ago

2.2.24

1 year ago

2.2.23

1 year ago

2.2.22

1 year ago

2.1.22

1 year ago

2.1.21

1 year ago

2.1.20

1 year ago

2.1.19

1 year ago

2.1.18

1 year ago

2.1.17

1 year ago

2.0.17

1 year ago

2.0.16

1 year ago

2.0.15

1 year ago

2.0.14

1 year ago

2.0.13

1 year ago

2.0.12

1 year ago

2.0.11

1 year ago

1.0.11

1 year ago

1.0.10

1 year ago

1.0.9

1 year ago

1.0.8

1 year ago

1.0.7

1 year ago

1.0.6

1 year ago

1.0.5

1 year ago

1.0.4

1 year ago

1.0.3

1 year ago

1.0.2

1 year ago

1.0.1

1 year ago

1.0.0

1 year ago