This is a POC of the possibility to parse and render import clauses without using AST by Nearley parser.
Size limit: 10 kB
Size: 8.74 kB with all dependencies, minified and brotlied- pnpm build - build the project into a module. The module wasn't tested on real files, due to demonstration purposes. Not recommended for production.
- pnpm test - runs tests in watch mode
- pnpm size - check bundle size
- pnpm compile - compile
Nearleygrammar into a JS file
- searching imports in file
- removing mentions of imports from the file
- sorting of import in natural order
- support
importOrderCaseInsensitive - support
importOrder - support
importOrderSideEffects - sort third-party imports according place of
<THIRD_PARTY_MODULES> - sorting specifiers
- adding new line after group
- support importOrderGroupNamespaceSpecifiers
- add with/assertion literal
- refactor code and preserve all characters in import lines
- add support importing types
- add snapshot tests for angular/svelte/typescript/flow
- ignore sorting where "sort-imports-ignore" is placed
- it doesn't move some code before imports. Because it thinks that before imports could be only shebang or directives with comments.
- add legacy
withattribute - plugins now puts new line after shebang. Should we make exception in this case?
- it doesn't handle many groups of imports within one file. e.g. multiple svelte <script> blocks, multiple module declation in typescript.