Skip to content

Commit

Permalink
Merge pull request #22 from tc39/granular-exports
Browse files Browse the repository at this point in the history
Granular exports analysis
  • Loading branch information
guybedford authored Oct 8, 2024
2 parents b8ab07a + c2eddf6 commit e68f931
Show file tree
Hide file tree
Showing 3 changed files with 281 additions and 118 deletions.
46 changes: 39 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -195,20 +195,48 @@ interface Import {
}
```
### `AbstractModuleSource.prototype.namedExports()`
### `AbstractModuleSource.prototype.exports()`
Returns a list of the explicit named exports of the module of the form `String[]`.
Returns a list of the explicit exports of the module of the form `Export[]` defined by
`DirectExport | Reexport | ReexportAll`:
### `AbstractModuleSource.prototype.wildcardExports()`
```ts
interface DirectExport {
type: 'direct',
names: string[]
}

Returns the list of imported modules exporting all their exports (`export * from '...'`), of the form `WildcardExport[]` defined by:
interface Reexport {
type: 'reexport',
name: string,
import: string | null, // null used to indicate a namespace reexport
from: string,
}

```ts
interface WildcardExport {
specifier: string
interface ReexportAll {
type: 'reexport-all',
from: string,
}
```
`DirectExport` provides multiple names to reflect that a single local binding may be exported under
multiple aliases.
Note that reexports are reported equivalently for both:
```js
export { a as b } from 'c';
```
and:
```js
import { a as z } from 'c';
export { z as b }
```
being represented as `Export { type: 'reexport', name: 'b', import: 'a', from: 'c' }`.
### `AbstractModuleSource.prototype.hasImportMeta`
A boolean getter property indicating if the module accesses the module `import.meta`.
Expand Down Expand Up @@ -276,6 +304,10 @@ The module objects defined by the [Module Expressions][] and
[Module Declarations][] proposals, should align with whatever SourceTextModule
phase object foundations are specified in this proposal.
Analysis metadata for module declaration imports and exports may exposed through an extension of
the existing source analysis. These possible analysis extensions are discussed in
https://github.com/tc39/proposal-esm-phase-imports/issues/19.
### Compartment Loaders
The [Compartments Proposal][] provides a way to dynamically create module
Expand Down
Loading

0 comments on commit e68f931

Please sign in to comment.