-
-
Notifications
You must be signed in to change notification settings - Fork 1.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
no-unused-modules: support dynamic imports
This is still work in progress but I'd like to receive initial thoughts on this implementation before I proceed. This introduces support of dynamic imports for a rule `no-unused-modules`. So far only "await" form is implemented: ```js const a = await import("a") ``` is equivalent to default import ```js import a from "a" ``` ```js const {a,b,c} = await import("a") ``` is equivalent to named imports ```js import {a,b,c} from "a" ``` Support import('name').then(a) and import('name').then({a,b,c}) to be addded soon. TODO/Open questions - [ ] Existing code is relying on the fact that all imports/reexports happen at top level of the file while dynamic import can happen anywhere - that's why I had to implement visitor against visitor keys of the parser myself not very happy about it - but couldn't figure out quickly how to use existing visitor (if any?) supplied by a parser. I also learned that different parsers have visitor keys defined in different places so this has to be dealt with as well.
- Loading branch information
1 parent
2beec94
commit 060ea2c
Showing
7 changed files
with
146 additions
and
18 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
async function main() { | ||
const value = await import("./exports-for-dynamic") | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
async function main() { | ||
const { importMeDynamicallyA, } = await import("./exports-for-dynamic") | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
export const importMeDynamicallyA = 100; | ||
const importMeDynamicallyB = 200; | ||
export const importMeDynamicallyC = 100; | ||
export default importMeDynamicallayB; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters