lincd-cli 0.2.47 → 0.2.49
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/defaults/app-with-backend/readme.md +6 -0
- package/defaults/app-with-backend/src/App.tsx +4 -1
- package/lib/cli-methods.js +1332 -1472
- package/lib/cli.js +102 -103
- package/lib/config-grunt.js +246 -298
- package/lib/config-webpack.js +364 -358
- package/lib/index.js +29 -67
- package/lib/interfaces.js +2 -2
- package/lib/plugins/declaration-plugin.js +233 -209
- package/lib/plugins/externalise-modules.js +166 -167
- package/lib/plugins/watch-run.js +14 -16
- package/lib/utils.js +284 -326
- package/package.json +1 -1
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
|
|
2
|
-
Object.defineProperty(exports,
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
/// <reference path="colors.d.ts" />
|
|
4
|
-
const colors = require(
|
|
4
|
+
const colors = require("colors");
|
|
5
5
|
var exportRoot = '/lib';
|
|
6
6
|
var libraryName = 'lincd';
|
|
7
7
|
var lincdModules = new Map();
|
|
@@ -13,174 +13,173 @@ var includedLincdModules = new Set();
|
|
|
13
13
|
//it basically turns every import from a lincd module into a lookup for that class/object in the global lincd object
|
|
14
14
|
//See also: https://webpack.js.org/configuration/externals/
|
|
15
15
|
var externaliseModules = function (config, es5) {
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
16
|
+
function debug(...msgs) {
|
|
17
|
+
msgs.unshift('externals: ');
|
|
18
|
+
if (config && config.debug) {
|
|
19
|
+
console.log.apply(null, msgs);
|
|
20
|
+
}
|
|
20
21
|
}
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
msgs.unshift('externals: ');
|
|
25
|
-
console.log.apply(null, msgs);
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
// let externalKeys: string[] = config.externals ? Object.keys(config.externals) : [];
|
|
29
|
-
//return the function that is handed to webpack in the 'externals' option.
|
|
30
|
-
//it determines for each request what is external and what is not
|
|
31
|
-
return function ({context, request, contextInfo}, callback) {
|
|
32
|
-
// debug('checking '+request);
|
|
33
|
-
// debug('imported by '+contextInfo.issuer);
|
|
34
|
-
if (config.externals && config.externals[request]) {
|
|
35
|
-
if (!excludedExternals.has(request)) {
|
|
36
|
-
excludedExternals.add(request);
|
|
37
|
-
// debug(colors.magenta('Excluding request as defined in Gruntfile: ' + request));
|
|
38
|
-
debug(colors.red(request) + ' is defined as external --> excluded');
|
|
39
|
-
}
|
|
40
|
-
// return callback(config.externals[request]);
|
|
41
|
-
return callback(null, 'var ' + config.externals[request]);
|
|
22
|
+
function log(...msgs) {
|
|
23
|
+
msgs.unshift('externals: ');
|
|
24
|
+
console.log.apply(null, msgs);
|
|
42
25
|
}
|
|
43
|
-
//
|
|
44
|
-
//
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
config.externals[
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
//
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
26
|
+
// let externalKeys: string[] = config.externals ? Object.keys(config.externals) : [];
|
|
27
|
+
//return the function that is handed to webpack in the 'externals' option.
|
|
28
|
+
//it determines for each request what is external and what is not
|
|
29
|
+
return function ({ context, request, contextInfo }, callback) {
|
|
30
|
+
// debug('checking '+request);
|
|
31
|
+
// debug('imported by '+contextInfo.issuer);
|
|
32
|
+
if (config.externals && config.externals[request]) {
|
|
33
|
+
if (!excludedExternals.has(request)) {
|
|
34
|
+
excludedExternals.add(request);
|
|
35
|
+
// debug(colors.magenta('Excluding request as defined in Gruntfile: ' + request));
|
|
36
|
+
debug(colors.red(request) + ' is defined as external --> excluded');
|
|
37
|
+
}
|
|
38
|
+
// return callback(config.externals[request]);
|
|
39
|
+
return callback(null, 'var ' + config.externals[request]);
|
|
40
|
+
}
|
|
41
|
+
//solution to a problem that turned out not to need a solution.
|
|
42
|
+
// But if sub requests of externalized modules go wrong at some point, use this!
|
|
43
|
+
/*let rootRequest = request.substring(0, request.indexOf('/'));
|
|
44
|
+
if (externalKeys.indexOf(rootRequest) !== -1) {
|
|
45
|
+
let key = rootRequest;
|
|
46
|
+
let rest = request.substring(key.length).replace(/\//g, '.');
|
|
47
|
+
// return callback(config.externals[request]);
|
|
48
|
+
debug(
|
|
49
|
+
colors.magenta(
|
|
50
|
+
'Excluding sub request as defined in Gruntfile: ' +
|
|
51
|
+
request +
|
|
52
|
+
' -> ' +
|
|
53
|
+
config.externals[key] +
|
|
54
|
+
rest,
|
|
55
|
+
),
|
|
56
|
+
);
|
|
57
|
+
return callback(null, 'var ' + config.externals[request] + rest);
|
|
58
|
+
}*/
|
|
59
|
+
//log(colors.gray(request));
|
|
60
|
+
//"@dacore/core/foo" => "daCore.core.foo"
|
|
61
|
+
// if (/^\@dacore\//.test(request)) {
|
|
62
|
+
//remove @dacore/
|
|
63
|
+
// if (request.indexOf('@dacore') !== 0) {
|
|
64
|
+
// console.warn(
|
|
65
|
+
// colors.red('this plugin currently works with @dacore modules only'),
|
|
66
|
+
// );
|
|
67
|
+
// return;
|
|
68
|
+
// }
|
|
69
|
+
// debug(colors.green('request: ' + request));
|
|
70
|
+
if (request.substr(0, 1) == '.' || request.substr(0, 1) == '/') {
|
|
71
|
+
// debug('skipping local');
|
|
72
|
+
callback();
|
|
73
|
+
return;
|
|
74
|
+
}
|
|
75
|
+
if (request.indexOf('lincd/') === 0 && es5) {
|
|
76
|
+
// var result = request.replace("@dacore/core/","@dacore/core-es5/");
|
|
77
|
+
// debug('Requested ES6 for ES5 target: '+colors.yellow(request) + ' => ' + colors.cyan(result));
|
|
78
|
+
debug('Requested ES6 for ES5 target: ' + colors.yellow(request));
|
|
79
|
+
// return callback(null, 'commonjs '+result);
|
|
80
|
+
}
|
|
81
|
+
//get module name without @dacore
|
|
82
|
+
// var transformed = request.substr(8);
|
|
83
|
+
//find @scope and the next part between 2 slashes after
|
|
84
|
+
//so @dacore/some-mod/lib/file.js
|
|
85
|
+
// --> match[0] = @dacore/some-mod
|
|
86
|
+
// --> match[1] = @dacore
|
|
87
|
+
// --> match[2] = some-mod
|
|
88
|
+
let [packageName, scope, cleanPackageName] = request.match(/(@[\w\-]+\/)?([\w\-]+)/);
|
|
89
|
+
//if this module is listed as internal module in the config (or if we internalize all modules with '*')
|
|
90
|
+
if (config &&
|
|
91
|
+
config.internals &&
|
|
92
|
+
(config.internals.indexOf(packageName) !== -1 || config.internals === '*')) {
|
|
93
|
+
//then don't exclude and don't continue this function
|
|
94
|
+
//only log once
|
|
95
|
+
if (!includedInternals.has(packageName)) {
|
|
96
|
+
includedInternals.add(packageName);
|
|
97
|
+
debug(colors.blue(request) + ' marked internal --> included');
|
|
98
|
+
}
|
|
99
|
+
return callback();
|
|
100
|
+
}
|
|
101
|
+
//check if this module is a lincd module
|
|
102
|
+
let isLincd = isLincdModule(debug, packageName);
|
|
103
|
+
if (isLincd) {
|
|
104
|
+
if (!includedLincdModules.has(packageName)) {
|
|
105
|
+
includedLincdModules.add(packageName);
|
|
106
|
+
debug(colors.magenta(packageName +
|
|
107
|
+
' is a lincd module, imports will be excluded from this bundle and refer to a global variable instead'));
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
else {
|
|
111
|
+
//avoid duplicate messages
|
|
112
|
+
if (!excluded.has(packageName)) {
|
|
113
|
+
excluded.add(packageName);
|
|
114
|
+
debug(colors.green(packageName) + ' --> included');
|
|
115
|
+
}
|
|
116
|
+
return callback();
|
|
117
|
+
}
|
|
118
|
+
//remove export root path (for example with lincd/lib/models: the module has lib/ as root, so to get to the exported path lincd.models we need to remove it)
|
|
119
|
+
let cleanRequest = request.replace(exportRoot, '');
|
|
120
|
+
let targetVariable;
|
|
121
|
+
//expects a flat export / global tree with all the modules classes
|
|
122
|
+
//replace - by _ and remove es5, because both es6 and es5 modules will be listed under the bare module name in the global treemap
|
|
123
|
+
let firstSlash = cleanRequest.indexOf('/');
|
|
124
|
+
//if importing {x} from "lincd" (so directly from library without any paths)
|
|
125
|
+
if (firstSlash === -1 && cleanRequest == libraryName) {
|
|
126
|
+
//then we refer straight to the global object
|
|
127
|
+
targetVariable = libraryName;
|
|
128
|
+
}
|
|
129
|
+
else {
|
|
130
|
+
//for all other cases, there is slash, so lets split module before the first slash and classname after the last slash
|
|
131
|
+
// let module = cleanRequest
|
|
132
|
+
// .substr(0, firstSlash)
|
|
133
|
+
// .replace(/-/g, '_')
|
|
134
|
+
// .replace('_es5', '');
|
|
135
|
+
if (packageName == libraryName) {
|
|
136
|
+
//the library itself should directly expose the main class of each file for clean variable names
|
|
137
|
+
targetVariable = libraryName;
|
|
138
|
+
//targetVariable = libraryName + '.' + className;
|
|
139
|
+
}
|
|
140
|
+
else {
|
|
141
|
+
//reading this back I'm not sure why module would be empty?
|
|
142
|
+
//Note: we don't include className here anymore, since all linked Components/Utils register themselves as libraryName._modules.moduleName.ComponentName
|
|
143
|
+
//and we don't do default exports, so the import would be `import {ComponentName} from 'foo'` OR `import {ComponentName} from 'foo/lib/components/ComponentName'`
|
|
144
|
+
//Typescript then translates `ComponentName` to `ComponentName_1.ComponentName` in the javascript output
|
|
145
|
+
//And when we build the tree, we put each individual exports of linked components directly under `lincd._modules.moduleName`
|
|
146
|
+
//so here we return the entire module as the result of such imports
|
|
147
|
+
//and ComponentName_1 will contain all things linked/exported by the module
|
|
148
|
+
//and ComponentName_1.ComponentName resolves to the desired class/function
|
|
149
|
+
targetVariable =
|
|
150
|
+
libraryName + "._modules['" + packageName.replace(/\-/g, '_') + "']";
|
|
151
|
+
//import {PersonView} from 'lincd-test/lib/PersonView';
|
|
152
|
+
//lincd._modules.lincd_test
|
|
153
|
+
//PersonView_1
|
|
154
|
+
//PersonView_1.PersonView --> lincd._modules.lincd_test.PersonView
|
|
155
|
+
// targetVariable =
|
|
156
|
+
// libraryName +
|
|
157
|
+
// '.' +
|
|
158
|
+
// (module ? '_modules.' + module + '.' : '') +
|
|
159
|
+
// className;
|
|
160
|
+
}
|
|
161
|
+
}
|
|
162
|
+
debug(colors.yellow(request) + ' => ' + colors.cyan(targetVariable));
|
|
163
|
+
//See also: https://webpack.js.org/configuration/externals/
|
|
164
|
+
return callback(null, 'var ' + targetVariable);
|
|
165
|
+
// }
|
|
166
|
+
};
|
|
167
167
|
};
|
|
168
|
-
|
|
169
168
|
function isLincdModule(debug, packageName) {
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
169
|
+
if (!lincdModules.has(packageName)) {
|
|
170
|
+
// debug(colors.green('checking ' + moduleName + '/package.json'));
|
|
171
|
+
let isLincdModule;
|
|
172
|
+
let modulePackage;
|
|
173
|
+
try {
|
|
174
|
+
modulePackage = require(packageName + '/package.json');
|
|
175
|
+
}
|
|
176
|
+
catch (e) {
|
|
177
|
+
debug(colors.red(packageName + '/package.json' + ' does not exist'));
|
|
178
|
+
// return callback();
|
|
179
|
+
}
|
|
180
|
+
isLincdModule = modulePackage && modulePackage.lincd && true;
|
|
181
|
+
lincdModules.set(packageName, isLincdModule);
|
|
179
182
|
}
|
|
180
|
-
|
|
181
|
-
lincdModules.set(packageName, isLincdModule);
|
|
182
|
-
}
|
|
183
|
-
return lincdModules.get(packageName);
|
|
183
|
+
return lincdModules.get(packageName);
|
|
184
184
|
}
|
|
185
|
-
|
|
186
185
|
exports.default = externaliseModules;
|
package/lib/plugins/watch-run.js
CHANGED
|
@@ -4,24 +4,22 @@
|
|
|
4
4
|
* triggered webpack re-compilation/re-build
|
|
5
5
|
*/
|
|
6
6
|
'use strict';
|
|
7
|
-
Object.defineProperty(exports,
|
|
8
|
-
|
|
7
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
9
8
|
class WatchRunPlugin {
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
9
|
+
apply(compiler) {
|
|
10
|
+
compiler.hooks.watchRun.tap('WatchRun', (comp) => {
|
|
11
|
+
const changedTimes = comp.watchFileSystem.watcher.mtimes;
|
|
12
|
+
const changedFiles = Object.keys(changedTimes)
|
|
13
|
+
.map((file) => `\n ${file}`)
|
|
14
|
+
.join('');
|
|
15
|
+
if (changedFiles.length) {
|
|
16
|
+
console.log('====================================');
|
|
17
|
+
console.log('NEW BUILD FILES CHANGED:', changedFiles);
|
|
18
|
+
console.log('====================================');
|
|
19
|
+
}
|
|
20
|
+
});
|
|
21
|
+
}
|
|
23
22
|
}
|
|
24
|
-
|
|
25
23
|
/*class WebpackWatchRunPlugin {
|
|
26
24
|
constructor(options?) {
|
|
27
25
|
if (typeof options !== "object") options = {};
|