lincd-cli 0.1.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/LICENSE +373 -0
- package/README.md +60 -0
- package/cli.js +1238 -0
- package/config-generator.js +531 -0
- package/defaults/.npmignore +11 -0
- package/defaults/Gruntfile.js +16 -0
- package/defaults/create_migration.js +155 -0
- package/defaults/create_migration.ts +7 -0
- package/defaults/defaultModule/Index.js +30 -0
- package/defaults/defaultModule/Index.scss +19 -0
- package/defaults/defaultModule/Index.tsx +25 -0
- package/defaults/defaultModule/data.json +56 -0
- package/defaults/defaultModule/defaultOntology.json +23 -0
- package/defaults/defaultModule/index.ts +12 -0
- package/defaults/defaultModule/ontology.js +21 -0
- package/defaults/defaultModule/ontology.ts +16 -0
- package/defaults/gitignorefile +4 -0
- package/defaults/index.ts +13 -0
- package/defaults/ontology.ts +16 -0
- package/defaults/package.json +24 -0
- package/defaults/providers.ts +1 -0
- package/defaults/tsconfig-es5.json +19 -0
- package/defaults/tsconfig.json +21 -0
- package/index.js +18 -0
- package/package.json +68 -0
- package/plugins/declaration-plugin.js +248 -0
- package/plugins/externalise-modules.js +159 -0
- package/plugins/watch-run.js +47 -0
|
@@ -0,0 +1,248 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
exports.__esModule = true;
|
|
3
|
+
/// <reference path="colors.d.ts" />
|
|
4
|
+
var colors = require("colors");
|
|
5
|
+
var path = require("path");
|
|
6
|
+
var DeclarationPlugin = /** @class */ (function () {
|
|
7
|
+
function DeclarationPlugin(options) {
|
|
8
|
+
if (options === void 0) { options = {}; }
|
|
9
|
+
this.logMessages = true;
|
|
10
|
+
this.exportRoot = '/lib';
|
|
11
|
+
this.options = options;
|
|
12
|
+
this.options['out'] = options.out
|
|
13
|
+
? options.out
|
|
14
|
+
: './builds/declarations.d.ts';
|
|
15
|
+
this.options['config'] = options.config
|
|
16
|
+
? options.config
|
|
17
|
+
: process.cwd() + '/daconfig.js';
|
|
18
|
+
//var moduleConfig = this.getModuleConfig();
|
|
19
|
+
this.options['root'] = options.root || this.exportRoot; //'/lib'
|
|
20
|
+
this.logMessages = options.debug ? options.debug : false;
|
|
21
|
+
this.modulePackageInfo = require(process.cwd() + '/package.json');
|
|
22
|
+
// this.debug('found package name: '+this.modulePackageInfo.name);
|
|
23
|
+
}
|
|
24
|
+
DeclarationPlugin.prototype.apply = function (compiler) {
|
|
25
|
+
var _this = this;
|
|
26
|
+
this.debug('applying');
|
|
27
|
+
//when the compiler is ready to emit files
|
|
28
|
+
// compiler.plugin('emit', (compilation,callback) =>
|
|
29
|
+
compiler.hooks.emit.tapAsync('DeclarationPlugin', function (compilation, callback) {
|
|
30
|
+
// this.debug('emitted');
|
|
31
|
+
// this.debug(Object.keys(compilation.assets));
|
|
32
|
+
//collect all generated declaration files
|
|
33
|
+
//and remove them from the assets that will be emitted
|
|
34
|
+
//NOTE: at some point we decided to overwrite declaration files between emits because sometimes only one new declaration file is emitted
|
|
35
|
+
//this may cause issues when you remove a file during the continuous building process, but better than the other way around for now
|
|
36
|
+
if (!_this.declarationFiles) {
|
|
37
|
+
_this.declarationFiles = {};
|
|
38
|
+
}
|
|
39
|
+
for (var filename in compilation.assets) {
|
|
40
|
+
if (filename.indexOf('.d.ts') !== -1) {
|
|
41
|
+
if (_this.declarationFiles[filename]) {
|
|
42
|
+
_this.debug('overwriting ' + filename);
|
|
43
|
+
}
|
|
44
|
+
_this.declarationFiles[filename] = compilation.assets[filename];
|
|
45
|
+
// this.debug('not using: '+filename);
|
|
46
|
+
delete compilation.assets[filename];
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
if (Object.keys(_this.declarationFiles).length == 0) {
|
|
50
|
+
_this.log('Cannot build .d.ts file because no declarations where found.'.red);
|
|
51
|
+
_this.log('Make sure to add '.yellow +
|
|
52
|
+
'"declaration":true'.blue.bold['underline'] +
|
|
53
|
+
' to tsconfig.json'.yellow);
|
|
54
|
+
_this.log('Make sure to run '.yellow +
|
|
55
|
+
'tsc'.blue +
|
|
56
|
+
' before running webpack'.yellow);
|
|
57
|
+
_this.log('Make sure to test for '.yellow +
|
|
58
|
+
'/(?!.*.d.ts).ts(x?)$/'.blue.bold['underline'] +
|
|
59
|
+
' in the ts-loader in webpack.config.json'.yellow);
|
|
60
|
+
_this.log(('Assets: ' + Object.keys(compilation.assets).toString()).yellow);
|
|
61
|
+
callback();
|
|
62
|
+
return;
|
|
63
|
+
}
|
|
64
|
+
//var moduleConfig = this.getModuleConfig();
|
|
65
|
+
//this.debug(moduleConfig);
|
|
66
|
+
//if (moduleConfig)
|
|
67
|
+
//{
|
|
68
|
+
//combine them into one declaration file
|
|
69
|
+
var combinedDeclaration = _this.generateCombinedDeclaration(_this.declarationFiles); //moduleConfig
|
|
70
|
+
//and insert that back into the assets
|
|
71
|
+
compilation.assets[_this.options.out] = {
|
|
72
|
+
source: function () {
|
|
73
|
+
return combinedDeclaration;
|
|
74
|
+
},
|
|
75
|
+
size: function () {
|
|
76
|
+
return combinedDeclaration.length;
|
|
77
|
+
}
|
|
78
|
+
};
|
|
79
|
+
//get meta data from module exports
|
|
80
|
+
/*var metaRdfJson = this.generateMetaRdfJson(compilation,moduleConfig);
|
|
81
|
+
//and insert that back into the assets as [module_name].meta.json
|
|
82
|
+
compilation.assets[this.options.out.replace(".d.ts",".meta.rdf.json")] = {
|
|
83
|
+
source: function() {
|
|
84
|
+
return metaRdfJson;
|
|
85
|
+
},
|
|
86
|
+
size: function() {
|
|
87
|
+
return metaRdfJson.length;
|
|
88
|
+
}
|
|
89
|
+
};*/
|
|
90
|
+
//}
|
|
91
|
+
//webpack may continue now
|
|
92
|
+
callback();
|
|
93
|
+
});
|
|
94
|
+
};
|
|
95
|
+
DeclarationPlugin.prototype.debug = function () {
|
|
96
|
+
var msgs = [];
|
|
97
|
+
for (var _i = 0; _i < arguments.length; _i++) {
|
|
98
|
+
msgs[_i] = arguments[_i];
|
|
99
|
+
}
|
|
100
|
+
msgs.unshift('declarations:');
|
|
101
|
+
if (this.logMessages) {
|
|
102
|
+
console.log.apply(null, msgs);
|
|
103
|
+
}
|
|
104
|
+
};
|
|
105
|
+
DeclarationPlugin.prototype.log = function () {
|
|
106
|
+
var msgs = [];
|
|
107
|
+
for (var _i = 0; _i < arguments.length; _i++) {
|
|
108
|
+
msgs[_i] = arguments[_i];
|
|
109
|
+
}
|
|
110
|
+
msgs.unshift('declarations:');
|
|
111
|
+
console.log.apply(null, msgs);
|
|
112
|
+
};
|
|
113
|
+
DeclarationPlugin.prototype.generateCombinedDeclaration = function (declarationFiles) {
|
|
114
|
+
this.debug('generating combined declaration');
|
|
115
|
+
var declarations = '';
|
|
116
|
+
//this.debug("daCore: using config ",moduleConfig);
|
|
117
|
+
//this.debug("Combining these files:"+Object.keys(declarationFiles).toString());
|
|
118
|
+
//get current directory that webpack is run from (base of project), and replace backward slashes by forward ones to compare
|
|
119
|
+
var basePath = process.cwd().replace(/\\/g, '/') + '/';
|
|
120
|
+
this.debug('Base path:', colors.blue(basePath));
|
|
121
|
+
var npmModuleName = this.modulePackageInfo.name;
|
|
122
|
+
var moduleName = npmModuleName.replace(/\@\w+\//, '');
|
|
123
|
+
var importMap = {};
|
|
124
|
+
for (var declarationFileName in declarationFiles) {
|
|
125
|
+
//this.debug("Parsing "+declarationFileName);
|
|
126
|
+
var declarationFile = declarationFiles[declarationFileName];
|
|
127
|
+
//var data = declarationFile._value;
|
|
128
|
+
var data = declarationFile.source();
|
|
129
|
+
if (!data.split) {
|
|
130
|
+
console.warn(typeof data, declarationFileName +
|
|
131
|
+
' - cannot split declaration contents. Not a string?');
|
|
132
|
+
continue;
|
|
133
|
+
}
|
|
134
|
+
var lines = data.split('\n');
|
|
135
|
+
var i = lines.length;
|
|
136
|
+
while (i--) {
|
|
137
|
+
var line = lines[i];
|
|
138
|
+
//exclude empty lines
|
|
139
|
+
var excludeLine = line == '';
|
|
140
|
+
//if importing something, or re-exporting something
|
|
141
|
+
if (/import ([a-z0-9A-Z_\-\*\{\}\s,]+)/.test(line) ||
|
|
142
|
+
/export ([a-z0-9A-Z_-\{\}\s,\*]+) from/.test(line)) {
|
|
143
|
+
var fileImports = line.indexOf('"') !== -1
|
|
144
|
+
? line.match(/\"([^\"]+)\"/)
|
|
145
|
+
: line.match(/\'([^\']+)\'/);
|
|
146
|
+
if (fileImports && fileImports.length > 1) {
|
|
147
|
+
var importPath = fileImports[1];
|
|
148
|
+
//if it is importing a relative path and it is a new one
|
|
149
|
+
if ((importPath.substr(0, 2) == './' ||
|
|
150
|
+
importPath.substr(0, 3) == '../') &&
|
|
151
|
+
!importMap[importPath]) {
|
|
152
|
+
//we will replace it with the local npm module later, calc and save the absolute path for now
|
|
153
|
+
//we parse from builds, because now TS-LOADER gives paths relative to its output folder
|
|
154
|
+
var parsed = path.parse('./builds/' + declarationFileName);
|
|
155
|
+
var fileDirectory = parsed.dir;
|
|
156
|
+
var absoluteImportPath = path.resolve(fileDirectory, importPath);
|
|
157
|
+
// this.debug('declarationfilename '+declarationFileName);
|
|
158
|
+
// this.debug('filedir '+fileDirectory);
|
|
159
|
+
this.debug('import ' + colors.blue(importPath), ' -> ' + colors.green(absoluteImportPath));
|
|
160
|
+
importMap[importPath] = absoluteImportPath;
|
|
161
|
+
}
|
|
162
|
+
}
|
|
163
|
+
}
|
|
164
|
+
//exclude re-exports
|
|
165
|
+
//excludeLine = excludeLine || (/export ([a-z0-9A-Z_-\{\}\s,\*]+) from/).test(line);
|
|
166
|
+
//exclude local scss imports like: import "./some.scss"
|
|
167
|
+
excludeLine =
|
|
168
|
+
excludeLine || /import ["'][a-z0-9A-Z_\-.\/\\]+.scss["']/.test(line);
|
|
169
|
+
//if defined, check for excluded references
|
|
170
|
+
if (!excludeLine &&
|
|
171
|
+
this.excludedReferences &&
|
|
172
|
+
line.indexOf('<reference') !== -1) {
|
|
173
|
+
excludeLine = this.excludedReferences.some(function (reference) { return line.indexOf(reference) !== -1; });
|
|
174
|
+
}
|
|
175
|
+
if (excludeLine) {
|
|
176
|
+
//this.debug("Excluding line "+i+': '+line);
|
|
177
|
+
lines.splice(i, 1);
|
|
178
|
+
}
|
|
179
|
+
else {
|
|
180
|
+
if (line.indexOf('declare ') !== -1) {
|
|
181
|
+
lines[i] = line.replace('declare ', '');
|
|
182
|
+
}
|
|
183
|
+
//add tab
|
|
184
|
+
lines[i] = lines[i];
|
|
185
|
+
}
|
|
186
|
+
}
|
|
187
|
+
//declare module '@dacore/dacore-es6/lib/sub/File' {
|
|
188
|
+
//@dacore/core/F:/wamp-new/www/dacore/modules/core/lib/ontologies/xsd
|
|
189
|
+
//F:/wamp-new/www/dacore/modules/core/lib/ontologies/xsd.d.ts
|
|
190
|
+
// var declarationFileNameWithoutBase = declarationFileName.substr(0,basePath.length) == basePath ? declarationFileName.substr(basePath.length) : declarationFileName;
|
|
191
|
+
//TS Loader now uses paths relative to output dir. so here we remove a single ../ from the path (which is in there because /builds is the output dir and /lib is the relative path of the file)
|
|
192
|
+
var fixedDeclarationPath = declarationFileName
|
|
193
|
+
.replace(/\\/g, '/')
|
|
194
|
+
.replace('../', '')
|
|
195
|
+
.replace('.d.ts', '');
|
|
196
|
+
var moduleDeclaration = npmModuleName + '/' + fixedDeclarationPath;
|
|
197
|
+
//var moduleDeclaration = npmModuleName+'/'+declarationFileName.replace(/\\/g,"/").replace(".d.ts","");
|
|
198
|
+
//this.debug('basePath:'+basePath);
|
|
199
|
+
declarations +=
|
|
200
|
+
"declare module '" +
|
|
201
|
+
moduleDeclaration +
|
|
202
|
+
"' {\n\t" +
|
|
203
|
+
lines.join('\n\t') +
|
|
204
|
+
'\n}\n\n';
|
|
205
|
+
// this.debug('fixed:'+declarationFileName+' -> '+fixedDeclarationPath);
|
|
206
|
+
this.debug('Defining module ' +
|
|
207
|
+
colors.yellow(moduleDeclaration) +
|
|
208
|
+
' from ' +
|
|
209
|
+
colors.blue(declarationFileName));
|
|
210
|
+
}
|
|
211
|
+
for (var relativeImportPath in importMap) {
|
|
212
|
+
var absoluteImportPath_1 = importMap[relativeImportPath];
|
|
213
|
+
var npmImportModule = npmModuleName +
|
|
214
|
+
'/' +
|
|
215
|
+
absoluteImportPath_1
|
|
216
|
+
.substr(basePath.length)
|
|
217
|
+
.replace('.d.ts', '')
|
|
218
|
+
.replace(/\\/g, '/');
|
|
219
|
+
//this.debug("From: "+absoluteImportPath+" to npm: "+npmImportModule);
|
|
220
|
+
this.debug('Replacing ' +
|
|
221
|
+
colors.blue(relativeImportPath) +
|
|
222
|
+
' with ' +
|
|
223
|
+
colors.yellow(npmImportModule));
|
|
224
|
+
//wrap in quotes to omit problems with replacing partials and having to fix order of replacements
|
|
225
|
+
declarations = declarations.replace(new RegExp('(\'|")' + relativeImportPath + '(\'|")', 'g'), '"' + npmImportModule + '"');
|
|
226
|
+
}
|
|
227
|
+
var indexModulePath = this.modulePackageInfo.name + this.exportRoot + '/index';
|
|
228
|
+
this.debug('Replacing index ' +
|
|
229
|
+
colors.yellow(indexModulePath) +
|
|
230
|
+
' with ' +
|
|
231
|
+
colors.yellow(this.modulePackageInfo.name));
|
|
232
|
+
declarations = declarations.replace("'" + indexModulePath + "'", "'" + this.modulePackageInfo.name + "'");
|
|
233
|
+
//replace alias
|
|
234
|
+
if (this.options.alias) {
|
|
235
|
+
for (var aliasKey in this.options.alias) {
|
|
236
|
+
//declarations = declarations.replace(aliasKey,this.options.alias[aliasKey]);
|
|
237
|
+
this.debug('Replacing alias ' +
|
|
238
|
+
aliasKey +
|
|
239
|
+
' with ' +
|
|
240
|
+
this.options.alias[aliasKey]);
|
|
241
|
+
declarations = declarations.replace(new RegExp(aliasKey, 'g'), this.options.alias[aliasKey]);
|
|
242
|
+
}
|
|
243
|
+
}
|
|
244
|
+
return declarations;
|
|
245
|
+
};
|
|
246
|
+
return DeclarationPlugin;
|
|
247
|
+
}());
|
|
248
|
+
exports["default"] = DeclarationPlugin;
|
|
@@ -0,0 +1,159 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
exports.__esModule = true;
|
|
3
|
+
/// <reference path="colors.d.ts" />
|
|
4
|
+
var colors = require("colors");
|
|
5
|
+
var included = [];
|
|
6
|
+
var exportRoot = '/lib';
|
|
7
|
+
var libraryName = 'lincd';
|
|
8
|
+
var lincdModules = new Map();
|
|
9
|
+
//This function determines which modules that are requested by the module being built are external
|
|
10
|
+
//it basically turns every import from @dacore/[something] request into a lookup for that class/object in the global daCore object (which BrowserCore maintains when modules register themselves)
|
|
11
|
+
//See also: https://webpack.js.org/configuration/externals/
|
|
12
|
+
var externaliseModules = function (config, es5) {
|
|
13
|
+
function debug() {
|
|
14
|
+
var msgs = [];
|
|
15
|
+
for (var _i = 0; _i < arguments.length; _i++) {
|
|
16
|
+
msgs[_i] = arguments[_i];
|
|
17
|
+
}
|
|
18
|
+
msgs.unshift('externals: ');
|
|
19
|
+
if (config && config.debug) {
|
|
20
|
+
console.log.apply(null, msgs);
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
function log() {
|
|
24
|
+
var msgs = [];
|
|
25
|
+
for (var _i = 0; _i < arguments.length; _i++) {
|
|
26
|
+
msgs[_i] = arguments[_i];
|
|
27
|
+
}
|
|
28
|
+
msgs.unshift('externals: ');
|
|
29
|
+
console.log.apply(null, msgs);
|
|
30
|
+
}
|
|
31
|
+
//return the function that is handed to webpack in the 'externals' option.
|
|
32
|
+
//it determines for each request what is external and what is not
|
|
33
|
+
return function (context, request, callback) {
|
|
34
|
+
if (config.externals && config.externals[request]) {
|
|
35
|
+
debug(colors.magenta('Excluding request as defined in Gruntfile: ' + request));
|
|
36
|
+
// return callback(config.externals[request]);
|
|
37
|
+
return callback(null, 'var ' + config.externals[request]);
|
|
38
|
+
}
|
|
39
|
+
if (config.externals && config.externals[request]) {
|
|
40
|
+
debug(colors.magenta('Excluding request as defined in Gruntfile: ' + request));
|
|
41
|
+
// return callback(config.externals[request]);
|
|
42
|
+
return callback(null, 'var ' + config.externals[request]);
|
|
43
|
+
}
|
|
44
|
+
//log(colors.gray(request));
|
|
45
|
+
//"@dacore/core/foo" => "daCore.core.foo"
|
|
46
|
+
// if (/^\@dacore\//.test(request)) {
|
|
47
|
+
//remove @dacore/
|
|
48
|
+
// if (request.indexOf('@dacore') !== 0) {
|
|
49
|
+
// console.warn(
|
|
50
|
+
// colors.red('this plugin currently works with @dacore modules only'),
|
|
51
|
+
// );
|
|
52
|
+
// return;
|
|
53
|
+
// }
|
|
54
|
+
// debug(colors.green('request: ' + request));
|
|
55
|
+
if (request.substr(0, 1) == '.' || request.substr(0, 1) == '/') {
|
|
56
|
+
// debug('skipping local');
|
|
57
|
+
callback();
|
|
58
|
+
return;
|
|
59
|
+
}
|
|
60
|
+
if (request.indexOf('lincd/') === 0 && es5) {
|
|
61
|
+
// var result = request.replace("@dacore/core/","@dacore/core-es5/");
|
|
62
|
+
// debug('Requested ES6 for ES5 target: '+colors.yellow(request) + ' => ' + colors.cyan(result));
|
|
63
|
+
debug('Requested ES6 for ES5 target: ' + colors.yellow(request));
|
|
64
|
+
// return callback(null, 'commonjs '+result);
|
|
65
|
+
}
|
|
66
|
+
//get module name without @dacore
|
|
67
|
+
// var transformed = request.substr(8);
|
|
68
|
+
var moduleName = request.indexOf('/') !== -1
|
|
69
|
+
? request.substr(0, request.indexOf('/'))
|
|
70
|
+
: request;
|
|
71
|
+
//if this module is listed as internal module in the config
|
|
72
|
+
if (config &&
|
|
73
|
+
config.internals &&
|
|
74
|
+
config.internals.indexOf(moduleName) !== -1) {
|
|
75
|
+
//then don't exclude and don't continue this function
|
|
76
|
+
//only log once
|
|
77
|
+
if (included.indexOf(moduleName) !== -1) {
|
|
78
|
+
included.push(moduleName);
|
|
79
|
+
}
|
|
80
|
+
debug(colors.blue('marked internal & will be included: ' + request));
|
|
81
|
+
return callback();
|
|
82
|
+
}
|
|
83
|
+
//check if this module is a lincd module
|
|
84
|
+
if (!lincdModules.has(moduleName)) {
|
|
85
|
+
// debug(colors.green('checking ' + moduleName + '/package.json'));
|
|
86
|
+
var isLincdModule = void 0;
|
|
87
|
+
var modulePackage = void 0;
|
|
88
|
+
try {
|
|
89
|
+
modulePackage = require(moduleName + '/package.json');
|
|
90
|
+
}
|
|
91
|
+
catch (e) {
|
|
92
|
+
debug(colors.red(moduleName + '/package.json' + ' does not exist'));
|
|
93
|
+
return callback();
|
|
94
|
+
}
|
|
95
|
+
isLincdModule = modulePackage.lincd && true;
|
|
96
|
+
if (isLincdModule) {
|
|
97
|
+
debug(colors.magenta(modulePackage.name +
|
|
98
|
+
' is a lincd module, imports will be excluded from this bundle and refer to a global variable instead'));
|
|
99
|
+
}
|
|
100
|
+
else {
|
|
101
|
+
debug(modulePackage.name +
|
|
102
|
+
' is NOT a linked module, it will be included in the bundle');
|
|
103
|
+
}
|
|
104
|
+
lincdModules.set(moduleName, isLincdModule && true);
|
|
105
|
+
}
|
|
106
|
+
if (lincdModules.get(moduleName) !== true) {
|
|
107
|
+
return callback();
|
|
108
|
+
}
|
|
109
|
+
//remove export root path (for example with @dacore/core/lib/models/UriResource: the core module has lib/ as root, so to get to the exported path dacore.core.UriResource we need to remove it)
|
|
110
|
+
var cleanRequest = request.replace(exportRoot, '');
|
|
111
|
+
var targetVariable;
|
|
112
|
+
//expects a flat export / global tree with all the modules classes
|
|
113
|
+
//replace - by _ and remove es5, because both es6 and es5 modules will be listed under the bare module name in the global treemap
|
|
114
|
+
var firstSlash = cleanRequest.indexOf('/');
|
|
115
|
+
//if importing {x} from "lincd" (so directly from library without any paths)
|
|
116
|
+
if (firstSlash === -1 && cleanRequest == libraryName) {
|
|
117
|
+
//then we refer straight to the global object
|
|
118
|
+
targetVariable = libraryName;
|
|
119
|
+
}
|
|
120
|
+
else {
|
|
121
|
+
//for all other cases, there is slash, so lets split module before the first slash and classname after the last slash
|
|
122
|
+
var module_1 = cleanRequest
|
|
123
|
+
.substr(0, firstSlash)
|
|
124
|
+
.replace(/-/g, '_')
|
|
125
|
+
.replace('_es5', '');
|
|
126
|
+
var className = cleanRequest
|
|
127
|
+
.substr(cleanRequest.lastIndexOf('/') + 1)
|
|
128
|
+
.replace(/-/g, '_');
|
|
129
|
+
if (module_1 == libraryName) {
|
|
130
|
+
//the library itself should directly expose the main class of each file for clean variable names
|
|
131
|
+
targetVariable = libraryName;
|
|
132
|
+
//targetVariable = libraryName + '.' + className;
|
|
133
|
+
}
|
|
134
|
+
else {
|
|
135
|
+
//reading this back I'm not sure why module would be empty?
|
|
136
|
+
//this does NO LONGER include className, since Components register themselves as libraryName._modules.foo.ComponentName
|
|
137
|
+
//but we don't do default exports, so the import would be import {ComponentName} from 'foo' or 'foo/lib/components/ComponentName'
|
|
138
|
+
//which we DID rewrite to libraryName._modules.foo.ComponentName
|
|
139
|
+
//BUT TYPESCRIPT then translates var Component to ComponentName_1.ComponentName, which does not exist
|
|
140
|
+
//so NOW we point that import to the whole module, and requesting Foo_1.ComponentName will then work
|
|
141
|
+
targetVariable = libraryName + '._modules.' + module_1;
|
|
142
|
+
//import {PersonView} from 'lincd-test/lib/PersonView';
|
|
143
|
+
//lincd._modules.lincd_test
|
|
144
|
+
//PersonView_1
|
|
145
|
+
//PersonView_1.PersonView --> lincd._modules.lincd_test.PersonView
|
|
146
|
+
// targetVariable =
|
|
147
|
+
// libraryName +
|
|
148
|
+
// '.' +
|
|
149
|
+
// (module ? '_modules.' + module + '.' : '') +
|
|
150
|
+
// className;
|
|
151
|
+
}
|
|
152
|
+
}
|
|
153
|
+
debug(colors.yellow(request) + ' => ' + colors.cyan(targetVariable));
|
|
154
|
+
//See also: https://webpack.js.org/configuration/externals/
|
|
155
|
+
return callback(null, 'var ' + targetVariable);
|
|
156
|
+
// }
|
|
157
|
+
};
|
|
158
|
+
};
|
|
159
|
+
exports["default"] = externaliseModules;
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
// WebpackWatchRunPlugin.js
|
|
2
|
+
/*
|
|
3
|
+
* This simple webpack plugin helps to identify the list of file changes, that
|
|
4
|
+
* triggered webpack re-compilation/re-build
|
|
5
|
+
*/
|
|
6
|
+
'use strict';
|
|
7
|
+
exports.__esModule = true;
|
|
8
|
+
var WatchRunPlugin = /** @class */ (function () {
|
|
9
|
+
function WatchRunPlugin() {
|
|
10
|
+
}
|
|
11
|
+
WatchRunPlugin.prototype.apply = function (compiler) {
|
|
12
|
+
compiler.hooks.watchRun.tap('WatchRun', function (comp) {
|
|
13
|
+
var changedTimes = comp.watchFileSystem.watcher.mtimes;
|
|
14
|
+
var changedFiles = Object.keys(changedTimes)
|
|
15
|
+
.map(function (file) { return "\n ".concat(file); })
|
|
16
|
+
.join('');
|
|
17
|
+
if (changedFiles.length) {
|
|
18
|
+
console.log('====================================');
|
|
19
|
+
console.log('NEW BUILD FILES CHANGED:', changedFiles);
|
|
20
|
+
console.log('====================================');
|
|
21
|
+
}
|
|
22
|
+
});
|
|
23
|
+
};
|
|
24
|
+
return WatchRunPlugin;
|
|
25
|
+
}());
|
|
26
|
+
/*class WebpackWatchRunPlugin {
|
|
27
|
+
constructor(options?) {
|
|
28
|
+
if (typeof options !== "object") options = {};
|
|
29
|
+
this['options'] = options;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
apply(compiler) {
|
|
33
|
+
const options = this['options'];
|
|
34
|
+
compiler.plugin("watch-run",
|
|
35
|
+
function (watching, done) {
|
|
36
|
+
const changedTimes = watching.compiler.watchFileSystem.watcher.mtimes;
|
|
37
|
+
const changedFiles = Object.keys(changedTimes)
|
|
38
|
+
.map(file => `\n ${file}`)
|
|
39
|
+
.join("");
|
|
40
|
+
if (changedFiles.length) {
|
|
41
|
+
console.log("Files modified:", changedFiles);
|
|
42
|
+
}
|
|
43
|
+
done();
|
|
44
|
+
});
|
|
45
|
+
}
|
|
46
|
+
}*/
|
|
47
|
+
exports["default"] = WatchRunPlugin;
|