@startupjs/babel-plugin-startupjs 0.39.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +20 -0
- package/index.js +77 -0
- package/moduleMap.json +80 -0
- package/package.json +35 -0
package/README.md
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
# @startupjs/babel-plugin-startupjs
|
|
2
|
+
|
|
3
|
+
Unwrap imports for tree shaking.
|
|
4
|
+
|
|
5
|
+
## Example
|
|
6
|
+
|
|
7
|
+
```jsx
|
|
8
|
+
export { Button, Span } from '@startupjs/ui'
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
↓ ↓ ↓ ↓ ↓ ↓
|
|
12
|
+
|
|
13
|
+
```jsx
|
|
14
|
+
import Button from '@startupjs/ui/components/Button'
|
|
15
|
+
import Span from '@startupjs/ui/components/typography/Span'
|
|
16
|
+
```
|
|
17
|
+
|
|
18
|
+
## Licence
|
|
19
|
+
|
|
20
|
+
MIT
|
package/index.js
ADDED
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
const moduleMap = require('./moduleMap.json')
|
|
2
|
+
|
|
3
|
+
function getDistLocation (moduleName, importName) {
|
|
4
|
+
if (!(moduleMap[moduleName] && moduleMap[moduleName][importName])) {
|
|
5
|
+
console.warn('>>>>>>\n>>>>>\n>>>>>>\n>>>>>> NO MODULE FOUND', moduleName, importName)
|
|
6
|
+
return
|
|
7
|
+
}
|
|
8
|
+
return moduleName + moduleMap[moduleName][importName]
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
const canProcess = ({ source, specifiers }) =>
|
|
12
|
+
source && moduleMap[source.value] && specifiers.length
|
|
13
|
+
|
|
14
|
+
module.exports = function ({ types: t }) {
|
|
15
|
+
return {
|
|
16
|
+
name: 'Unwrap imports for tree shaking.',
|
|
17
|
+
visitor: {
|
|
18
|
+
ImportDeclaration (path, state) {
|
|
19
|
+
const { specifiers } = path.node
|
|
20
|
+
if (canProcess(path.node)) {
|
|
21
|
+
const moduleName = path.node.source.value
|
|
22
|
+
const transformed = specifiers
|
|
23
|
+
.map(specifier => {
|
|
24
|
+
if (t.isImportSpecifier(specifier)) {
|
|
25
|
+
const importName = specifier.imported.name
|
|
26
|
+
const distLocation = getDistLocation(moduleName, importName)
|
|
27
|
+
|
|
28
|
+
if (distLocation) {
|
|
29
|
+
return t.importDeclaration(
|
|
30
|
+
[t.importDefaultSpecifier(t.identifier(specifier.local.name))],
|
|
31
|
+
t.stringLiteral(distLocation)
|
|
32
|
+
)
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
return t.importDeclaration(
|
|
36
|
+
[specifier],
|
|
37
|
+
t.stringLiteral(moduleName + '/index')
|
|
38
|
+
)
|
|
39
|
+
})
|
|
40
|
+
.filter(Boolean)
|
|
41
|
+
|
|
42
|
+
path.replaceWithMultiple(transformed)
|
|
43
|
+
}
|
|
44
|
+
},
|
|
45
|
+
ExportNamedDeclaration (path, state) {
|
|
46
|
+
const { specifiers } = path.node
|
|
47
|
+
if (canProcess(path.node)) {
|
|
48
|
+
const moduleName = path.node.source.value
|
|
49
|
+
const transformed = specifiers
|
|
50
|
+
.map(specifier => {
|
|
51
|
+
if (t.isExportSpecifier(specifier)) {
|
|
52
|
+
const exportName = specifier.exported.name
|
|
53
|
+
const localName = specifier.local.name
|
|
54
|
+
const distLocation = getDistLocation(moduleName, localName)
|
|
55
|
+
|
|
56
|
+
if (distLocation) {
|
|
57
|
+
return t.exportNamedDeclaration(
|
|
58
|
+
null,
|
|
59
|
+
[t.exportSpecifier(t.identifier('default'), t.identifier(exportName))],
|
|
60
|
+
t.stringLiteral(distLocation)
|
|
61
|
+
)
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
return t.exportNamedDeclaration(
|
|
65
|
+
null,
|
|
66
|
+
[specifier],
|
|
67
|
+
t.stringLiteral(moduleName + '/index')
|
|
68
|
+
)
|
|
69
|
+
})
|
|
70
|
+
.filter(Boolean)
|
|
71
|
+
|
|
72
|
+
path.replaceWithMultiple(transformed)
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
}
|
package/moduleMap.json
ADDED
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
{
|
|
2
|
+
"// THIS FILE IS AUTOMATICALLY GENERATED. DO NOT EDIT.": 0,
|
|
3
|
+
"@startupjs/ui": {
|
|
4
|
+
"AbstractPopover": "/components/AbstractPopover",
|
|
5
|
+
"Alert": "/components/Alert",
|
|
6
|
+
"AutoSuggest": "/components/AutoSuggest",
|
|
7
|
+
"Avatar": "/components/Avatar",
|
|
8
|
+
"Badge": "/components/Badge",
|
|
9
|
+
"Br": "/components/Br",
|
|
10
|
+
"Breadcrumbs": "/components/Breadcrumbs",
|
|
11
|
+
"Button": "/components/Button",
|
|
12
|
+
"Card": "/components/Card",
|
|
13
|
+
"Carousel": "/components/Carousel",
|
|
14
|
+
"Collapse": "/components/Collapse",
|
|
15
|
+
"Content": "/components/Content",
|
|
16
|
+
"Dialog": "/components/Dialog",
|
|
17
|
+
"Div": "/components/Div",
|
|
18
|
+
"Divider": "/components/Divider",
|
|
19
|
+
"DrawerSidebar": "/components/DrawerSidebar",
|
|
20
|
+
"Icon": "/components/Icon",
|
|
21
|
+
"Layout": "/components/Layout",
|
|
22
|
+
"Link": "/components/Link",
|
|
23
|
+
"Loader": "/components/Loader",
|
|
24
|
+
"Menu": "/components/Menu",
|
|
25
|
+
"Modal": "/components/Modal",
|
|
26
|
+
"Pagination": "/components/Pagination",
|
|
27
|
+
"Portal": "/components/Portal",
|
|
28
|
+
"Progress": "/components/Progress",
|
|
29
|
+
"Rating": "/components/Rating",
|
|
30
|
+
"Row": "/components/Row",
|
|
31
|
+
"Sidebar": "/components/Sidebar",
|
|
32
|
+
"SmartSidebar": "/components/SmartSidebar",
|
|
33
|
+
"Tabs": "/components/Tabs",
|
|
34
|
+
"Tag": "/components/Tag",
|
|
35
|
+
"Tooltip": "/components/Tooltip",
|
|
36
|
+
"User": "/components/User",
|
|
37
|
+
"ArrayInput": "/components/forms/ArrayInput",
|
|
38
|
+
"Checkbox": "/components/forms/Checkbox",
|
|
39
|
+
"ColorPicker": "/components/forms/ColorPicker",
|
|
40
|
+
"DateTimePicker": "/components/forms/DateTimePicker",
|
|
41
|
+
"Input": "/components/forms/Input",
|
|
42
|
+
"Multiselect": "/components/forms/Multiselect",
|
|
43
|
+
"NumberInput": "/components/forms/NumberInput",
|
|
44
|
+
"ObjectInput": "/components/forms/ObjectInput",
|
|
45
|
+
"PasswordInput": "/components/forms/PasswordInput",
|
|
46
|
+
"Radio": "/components/forms/Radio",
|
|
47
|
+
"Select": "/components/forms/Select",
|
|
48
|
+
"TextInput": "/components/forms/TextInput",
|
|
49
|
+
"Drawer": "/components/popups/Drawer",
|
|
50
|
+
"Dropdown": "/components/popups/Dropdown",
|
|
51
|
+
"Popover": "/components/popups/Popover",
|
|
52
|
+
"Table": "/components/table/Table",
|
|
53
|
+
"Tbody": "/components/table/Tbody",
|
|
54
|
+
"Td": "/components/table/Td",
|
|
55
|
+
"Th": "/components/table/Th",
|
|
56
|
+
"Thead": "/components/table/Thead",
|
|
57
|
+
"Tr": "/components/table/Tr",
|
|
58
|
+
"Span": "/components/typography/Span",
|
|
59
|
+
"H1": "/components/typography/headers/H1",
|
|
60
|
+
"H2": "/components/typography/headers/H2",
|
|
61
|
+
"H3": "/components/typography/headers/H3",
|
|
62
|
+
"H4": "/components/typography/headers/H4",
|
|
63
|
+
"H5": "/components/typography/headers/H5",
|
|
64
|
+
"H6": "/components/typography/headers/H6",
|
|
65
|
+
"ToastComponent": "/components/toast/ToastComponent.js",
|
|
66
|
+
"ToastProvider": "/components/toast/ToastProvider.js",
|
|
67
|
+
"toast": "/components/toast/toast.js",
|
|
68
|
+
"useDrawerDismiss": "/hooks/useDrawerDismiss.js",
|
|
69
|
+
"useLayout": "/hooks/useLayout.js",
|
|
70
|
+
"useMedia": "/hooks/useMedia.js",
|
|
71
|
+
"ThemeContext": "/theming/ThemeContext.js",
|
|
72
|
+
"ThemeProvider": "/theming/ThemeProvider.js",
|
|
73
|
+
"themed": "/theming/themed.js",
|
|
74
|
+
"uiAppPlugin": "/uiAppPlugin.js",
|
|
75
|
+
"alert": "/dialogs/alert.js",
|
|
76
|
+
"confirm": "/dialogs/confirm.js",
|
|
77
|
+
"helpers": "/dialogs/helpers.js",
|
|
78
|
+
"prompt": "/dialogs/prompt.js"
|
|
79
|
+
}
|
|
80
|
+
}
|
package/package.json
ADDED
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@startupjs/babel-plugin-startupjs",
|
|
3
|
+
"version": "0.39.0",
|
|
4
|
+
"publishConfig": {
|
|
5
|
+
"access": "public"
|
|
6
|
+
},
|
|
7
|
+
"description": "Unwrap imports for tree shaking",
|
|
8
|
+
"keywords": [
|
|
9
|
+
"babel",
|
|
10
|
+
"babel-plugin",
|
|
11
|
+
"tree-shaking",
|
|
12
|
+
"import",
|
|
13
|
+
"startupjs"
|
|
14
|
+
],
|
|
15
|
+
"main": "index.js",
|
|
16
|
+
"scripts": {
|
|
17
|
+
"test": "jest"
|
|
18
|
+
},
|
|
19
|
+
"author": "Pavel Zhukov",
|
|
20
|
+
"license": "MIT",
|
|
21
|
+
"repository": {
|
|
22
|
+
"type": "git",
|
|
23
|
+
"url": "https://github.com/startupjs/startupjs"
|
|
24
|
+
},
|
|
25
|
+
"files": [
|
|
26
|
+
"index.js",
|
|
27
|
+
"moduleMap.json",
|
|
28
|
+
"README.md"
|
|
29
|
+
],
|
|
30
|
+
"devDependencies": {
|
|
31
|
+
"babel-plugin-tester": "^9.1.0",
|
|
32
|
+
"jest": "^26.0.1"
|
|
33
|
+
},
|
|
34
|
+
"gitHead": "822c063a2d5835437841e5d18051cfcb28a7165c"
|
|
35
|
+
}
|