1- /* global module, __dirname, require */
2- require . extensions [ '.css' ] = ( ) => undefined ;
3- const path = require ( 'path' ) ;
4- const glob = require ( 'glob' ) ;
5-
6- /**
7- * We require a mapper for some PF modules because the modle export names do not match their location
8- */
9- const mapper = {
10- TextVariants : 'Text' ,
11- EmptyStateVariant : 'EmptyState' ,
12- PaginationVariant : 'Pagination' ,
13- SelectVariant : 'selectConstants' ,
14- DropdownPosition : 'dropdownConstants' ,
15- TextListVariants : 'TextList' ,
16- TextListItemVariants : 'TextListItem' ,
17- ClipboardCopyVariant : 'ClipboardCopy' ,
18- TooltipPosition : 'Tooltip'
19- } ;
20-
21- const IconMapper = {
22- AnsibeTowerIcon : 'ansibeTower-icon'
23- } ;
24-
25- const FECMapper = {
26- SkeletonSize : 'Skeleton' ,
27- PageHeaderTitle : 'PageHeader' ,
28- conditionalFilterType : 'ConditionalFilter'
29- } ;
30-
31- const NotificationMapper = {
32- REMOVE_NOTIFICATION : 'actionTypes' ,
33- ADD_NOTIFICATION : 'actionTypes' ,
34- NotificationsPortal : 'NotificationPortal' ,
35- addNotification : 'actions'
36- } ;
37-
38- /**
39- * These two plugins will replace all replative imports with absolute import paths to the commonJS version of asset
40- * PF esm build is broken, it points to commonJS files internaly
41- * There fore its better to use commonJS version of the build to avoid duplicate cjs/esm variants of components
42- * After its fixed in PF we can swap to using esm build
43- */
44- const patternflyTransformImports = ( env ) => [
45- 'transform-imports' ,
46- {
47- '@patternfly/react-table' : {
48- skipDefaultConversion : true ,
49- transform : `@patternfly/react-table/dist/${ env } `
50- } ,
51- '@patternfly/react-core' : {
52- transform : ( importName ) => {
53- let res ;
54- const files = glob . sync (
55- path . resolve (
56- __dirname ,
57- `./node_modules/@patternfly/react-core/dist/${ env } /**/${ mapper [
58- importName
59- ] || importName } .js`
60- )
61- ) ;
62- if ( files . length > 0 ) {
63- res = files [ 0 ] ;
64- } else {
65- throw `File with importName ${ importName } does not exist` ;
66- }
67-
68- res = res . replace ( path . resolve ( __dirname , './node_modules/' ) , '' ) ;
69- res = res . replace ( / ^ \/ / , '' ) ;
70- return res ;
71- } ,
72- preventFullImport : true ,
73- skipDefaultConversion : true
74- } ,
75- '@patternfly/react-icons' : {
76- transform : ( importName ) =>
77- `@patternfly/react-icons/dist/${ env } /icons/${ IconMapper [ importName ] || importName
78- . split ( / (? = [ A - Z ] ) / )
79- . join ( '-' )
80- . toLowerCase ( ) } .js`,
81- preventFullImport : true
82- }
83- } ,
84- 'patternfly-react'
85- ] ;
86-
87- const fecTransformImports = ( env ) => [
88- 'transform-imports' ,
89- {
90- '@redhat-cloud-services/frontend-components' : {
91- transform : ( importName ) => `@redhat-cloud-services/frontend-components/components/${
92- env
93- } /${
94- FECMapper [ importName ] || importName
95- } .js`,
96- preventFullImport : false ,
97- skipDefaultConversion : true
98- } ,
99- '@redhat-cloud-services/frontend-components-notifications' : {
100- transform : ( importName ) =>
101- `@redhat-cloud-services/frontend-components-notifications/${
102- env
103- } /${
104- NotificationMapper [ importName ] || importName
105- } .js`,
106- preventFullImport : true
107- }
108- } ,
109- 'frontend-components'
110- ] ;
111-
1121module . exports = {
113- presets : [ '@babel/env' , '@babel/react' , '@babel/flow' ] ,
2+ presets : [
3+ '@babel/env' ,
4+ '@babel/react' ,
5+ '@babel/flow'
6+ ] ,
1147 plugins : [
1158 [ 'transform-inline-environment-variables' , {
1169 include : [
@@ -124,24 +17,6 @@ module.exports = {
12417 '@babel/plugin-proposal-class-properties'
12518 ] ,
12619 env : {
127- esm : {
128- plugins : [
129- patternflyTransformImports ( 'esm' ) ,
130- fecTransformImports ( 'esm' )
131- ]
132- } ,
133- production : {
134- plugins : [
135- patternflyTransformImports ( 'esm' ) ,
136- fecTransformImports ( 'esm' )
137- ]
138- } ,
139- development : {
140- plugins : [
141- patternflyTransformImports ( 'esm' ) ,
142- fecTransformImports ( 'esm' )
143- ]
144- } ,
14520 componentTest : {
14621 plugins : [
14722 'istanbul'
0 commit comments