Skip to content

Commit e09ddea

Browse files
ascariandreafahad19
authored andcommitted
frint-config: exports (#346)
* granular exports for frint-config externals * Added 'Externals' suffix to exported memebers of frint-config * Fixed typo due to my rush
1 parent 974768e commit e09ddea

File tree

2 files changed

+121
-51
lines changed

2 files changed

+121
-51
lines changed

packages/frint-config/src/externals.js

Lines changed: 111 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -3,59 +3,120 @@
33
* Webpack's `externals` equivalent object,
44
* listing dependencies that Frint packages use.
55
*/
6-
import webpackRxjsExternals from 'webpack-rxjs-externals';
6+
import webpackRxJsExternals from 'webpack-rxjs-externals';
7+
8+
export const rxJs = webpackRxJsExternals();
9+
10+
export const lodash = function (context, request, callback) {
11+
if (request.startsWith('lodash/')) {
12+
const subModule = request.split('/')[1];
13+
14+
return callback(null, {
15+
root: ['_', subModule],
16+
commonjs: request,
17+
commonjs2: request,
18+
amd: request,
19+
});
20+
}
21+
22+
return callback();
23+
};
24+
25+
// full imports
26+
export const thirdParties = [{
27+
'lodash': {
28+
root: '_',
29+
commonjs: 'lodash',
30+
commonjs2: 'lodash',
31+
amd: 'lodash',
32+
},
33+
}, {
34+
'rxjs': {
35+
root: 'Rx',
36+
commonjs: 'rxjs',
37+
commonjs2: 'rxjs',
38+
amd: 'rxjs',
39+
},
40+
}, {
41+
'react': {
42+
root: 'React',
43+
commonjs: 'react',
44+
commonjs2: 'react',
45+
amd: 'react',
46+
},
47+
}, {
48+
'react-dom': {
49+
root: 'ReactDOM',
50+
commonjs: 'react-dom',
51+
commonjs2: 'react-dom',
52+
amd: 'react-dom'
53+
}
54+
}, {
55+
'prop-types': {
56+
root: 'PropTypes',
57+
commonjs: 'prop-types',
58+
commonjs2: 'prop-types',
59+
amd: 'prop-types',
60+
}
61+
}];
62+
63+
export const frint = [{
64+
'frint': {
65+
root: 'Frint',
66+
commonjs: 'frint',
67+
commonjs2: 'frint',
68+
amd: 'frint'
69+
},
70+
}, {
71+
'frint-store': {
72+
root: 'FrintStore',
73+
commonjs: 'frint-store',
74+
commonjs2: 'frint-store',
75+
amd: 'frint-store'
76+
},
77+
}, {
78+
'frint-model': {
79+
root: 'FrintModel',
80+
commonjs: 'frint-model',
81+
commonjs2: 'frint-model',
82+
amd: 'frint-model'
83+
},
84+
}, {
85+
'frint-data': {
86+
root: 'FrintData',
87+
commonjs: 'frint-data',
88+
commonjs2: 'frint-data',
89+
amd: 'frint-data'
90+
},
91+
}, {
92+
'frint-react': {
93+
root: 'FrintReact',
94+
commonjs: 'frint-react',
95+
commonjs2: 'frint-react',
96+
amd: 'frint-react'
97+
},
98+
}, {
99+
'frint-router': {
100+
root: 'FrintRouter',
101+
commonjs: 'frint-router',
102+
commonjs2: 'frint-router',
103+
amd: 'frint-router'
104+
},
105+
}, {
106+
'frint-router-react': {
107+
root: 'FrintRouterReact',
108+
commonjs: 'frint-router-react',
109+
commonjs2: 'frint-router-react',
110+
amd: 'frint-router-react'
111+
}
112+
}];
7113

8114
export default [
9115
// rxjs/*
10-
webpackRxjsExternals(),
116+
rxJs,
11117

12118
// lodash/*
13-
function (context, request, callback) {
14-
if (request.startsWith('lodash/')) {
15-
const subModule = request.split('/')[1];
16-
17-
return callback(null, {
18-
root: ['_', subModule],
19-
commonjs: request,
20-
commonjs2: request,
21-
amd: request,
22-
});
23-
}
24-
25-
return callback();
26-
},
27-
28-
// full imports
29-
{
30-
'lodash': {
31-
root: '_',
32-
commonjs: 'lodash',
33-
commonjs2: 'lodash',
34-
amd: 'lodash',
35-
},
36-
'rxjs': {
37-
root: 'Rx',
38-
commonjs: 'rxjs',
39-
commonjs2: 'rxjs',
40-
amd: 'rxjs',
41-
},
42-
'react': {
43-
root: 'React',
44-
commonjs: 'react',
45-
commonjs2: 'react',
46-
amd: 'react',
47-
},
48-
'react-dom': {
49-
root: 'ReactDOM',
50-
commonjs: 'react-dom',
51-
commonjs2: 'react-dom',
52-
amd: 'react-dom',
53-
},
54-
'prop-types': {
55-
root: 'PropTypes',
56-
commonjs: 'prop-types',
57-
commonjs2: 'prop-types',
58-
amd: 'prop-types',
59-
},
60-
},
119+
lodash,
120+
121+
...thirdParties
61122
];

packages/frint-config/src/index.js

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,14 @@
1-
import externals from './externals';
1+
import externals, {
2+
frint,
3+
lodash,
4+
thirdParties,
5+
rxJs
6+
} from './externals';
27

38
export default {
49
externals,
10+
frintExternals: frint,
11+
lodashExternals: lodash,
12+
thirdPartiesExternals: thirdParties,
13+
rxJsExternals: rxJs
514
};

0 commit comments

Comments
 (0)