https://github.com/molnarmark/import-parser
📘 Parse EcmaScript 6 import statements with ease.
https://github.com/molnarmark/import-parser
Last synced: 3 months ago
JSON representation
📘 Parse EcmaScript 6 import statements with ease.
- Host: GitHub
- URL: https://github.com/molnarmark/import-parser
- Owner: molnarmark
- License: mit
- Created: 2018-08-19T19:37:46.000Z (almost 8 years ago)
- Default Branch: master
- Last Pushed: 2018-08-19T19:45:00.000Z (almost 8 years ago)
- Last Synced: 2025-10-12T19:56:01.954Z (9 months ago)
- Language: JavaScript
- Homepage:
- Size: 2.93 KB
- Stars: 2
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Import Parser
> Parse EcmaScript 6 import statements with ease.
### Getting started
Install the package by running:
```
npm install --save import-parser
```
### Example
You can find a working example in `tester.js`.
```javascript
const ImportParser = require('import-parser');
const testCode = `
import React from "react"
import { Admin, Api, BackstageApisRestClient } from "backstage-admin"
import MultiContentListView from './views/ListView'
import MultiContentAddView from './views/AddView'
import MultiContentEditView from './views/EditView'
`
const imports = ImportParser(testCode)
console.log(imports)
/* =>
[ { originalMatch: 'import React from "react"',
modulePath: 'react',
importList: [ 'React' ] },
{ originalMatch: 'import { Admin, Api, BackstageApisRestClient } from "backstage-admin"',
modulePath: 'backstage-admin',
importList: [ 'Admin', 'Api', 'BackstageApisRestClient' ] },
{ originalMatch: 'import MultiContentListView from \'./views/ListView\'',
modulePath: './views/ListView',
importList: [ 'MultiContentListView' ] },
{ originalMatch: 'import MultiContentAddView from \'./views/AddView\'',
modulePath: './views/AddView',
importList: [ 'MultiContentAddView' ] },
{ originalMatch: 'import MultiContentEditView from \'./views/EditView\'',
modulePath: './views/EditView',
importList: [ 'MultiContentEditView' ] } ]
*/
```
### License
- MIT