app-bundler 0.2.9 → 0.2.11
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/lib/bundler.js +33 -18
- package/lib/cli.js +33 -18
- package/package.json +1 -1
package/lib/bundler.js
CHANGED
|
@@ -5065,8 +5065,8 @@ const Resource_1 = _src_class_Resource;
|
|
|
5065
5065
|
const Templates_1 = _src_handlers_script_common_js_templates_Templates;
|
|
5066
5066
|
exports.CommonJsBuilderSimplified = {
|
|
5067
5067
|
wrapModule(resource, outputItem, outputItems, setts) {
|
|
5068
|
-
|
|
5069
|
-
|
|
5068
|
+
let varId = getVarId(resource);
|
|
5069
|
+
let content = resource.content;
|
|
5070
5070
|
content = replaceWithVarIds(content, resource, this.solution);
|
|
5071
5071
|
content = Templates_1.Templates
|
|
5072
5072
|
.ModuleSimplified
|
|
@@ -5074,7 +5074,7 @@ exports.CommonJsBuilderSimplified = {
|
|
|
5074
5074
|
.replace(/[_]{3}MODULE[_]{3}/g, () => content)
|
|
5075
5075
|
.replace(/[_]{3}FOOTER[_]{3}/g, () => { var _a, _b; return ((_b = (_a = setts === null || setts === void 0 ? void 0 : setts.partials) === null || _a === void 0 ? void 0 : _a.footer) !== null && _b !== void 0 ? _b : ''); });
|
|
5076
5076
|
;
|
|
5077
|
-
|
|
5077
|
+
let opts = this.solution.iteration;
|
|
5078
5078
|
if (opts.commonjs == null) {
|
|
5079
5079
|
opts.commonjs = {
|
|
5080
5080
|
addHeading: true,
|
|
@@ -5089,11 +5089,12 @@ exports.CommonJsBuilderSimplified = {
|
|
|
5089
5089
|
return content;
|
|
5090
5090
|
},
|
|
5091
5091
|
getRootContent(root) {
|
|
5092
|
-
|
|
5092
|
+
let rootInput = this.solution.outputResources.rootInput;
|
|
5093
|
+
let content = replaceWithVarIds(root.content, rootInput, this.solution);
|
|
5093
5094
|
return content;
|
|
5094
5095
|
},
|
|
5095
5096
|
getHeaderContent() {
|
|
5096
|
-
|
|
5097
|
+
let resources = this
|
|
5097
5098
|
.solution
|
|
5098
5099
|
.outputResources
|
|
5099
5100
|
.items
|
|
@@ -5103,10 +5104,13 @@ exports.CommonJsBuilderSimplified = {
|
|
|
5103
5104
|
}
|
|
5104
5105
|
};
|
|
5105
5106
|
function replaceWithVarIds(content, resource, solution) {
|
|
5106
|
-
|
|
5107
|
+
let rgx_REQUIRE = /require\s*\(\s*['"]([^'"]+)['"]\s*\)/g;
|
|
5108
|
+
if (typeof content !== 'string') {
|
|
5109
|
+
return JSON.stringify(content);
|
|
5110
|
+
}
|
|
5107
5111
|
return content.replace(rgx_REQUIRE, (full, path) => {
|
|
5108
|
-
|
|
5109
|
-
|
|
5112
|
+
let res = new Resource_1.Resource({ url: path, type: 'js' }, resource, solution);
|
|
5113
|
+
let current = resource.resources.find(x => x.url === res.url);
|
|
5110
5114
|
if (current == null) {
|
|
5111
5115
|
return full;
|
|
5112
5116
|
}
|
|
@@ -5114,11 +5118,11 @@ function replaceWithVarIds(content, resource, solution) {
|
|
|
5114
5118
|
});
|
|
5115
5119
|
}
|
|
5116
5120
|
function getVarId(resource) {
|
|
5117
|
-
|
|
5121
|
+
let str = resource.url.replace(/\.\w+$/, '');
|
|
5118
5122
|
return str.replace(/[^\w\d]/g, '_');
|
|
5119
5123
|
}
|
|
5120
5124
|
function getModuleVars(resources) {
|
|
5121
|
-
return resources.map(getVarId).sort().map(x => `
|
|
5125
|
+
return resources.map(getVarId).sort().map(x => `let ${x} = {};`).join('\n') + '\n';
|
|
5122
5126
|
}
|
|
5123
5127
|
//# sourceMappingURL=CommonJsBuilderSimplified.js.map
|
|
5124
5128
|
//# sourceMappingURL=CommonJsBuilderSimplified.ts.map;
|
|
@@ -8574,13 +8578,19 @@ class CopyJsBuilder extends BaseScriptBuilder_1.BaseScriptBuilder {
|
|
|
8574
8578
|
let result = [
|
|
8575
8579
|
createOutputItem(cloneWithExtension(resource, this.solution.opts.outputExtension))
|
|
8576
8580
|
];
|
|
8577
|
-
let extra = [
|
|
8578
|
-
|
|
8579
|
-
|
|
8580
|
-
|
|
8581
|
-
|
|
8582
|
-
|
|
8583
|
-
|
|
8581
|
+
let extra = [];
|
|
8582
|
+
if (resource.filename.endsWith('.ts')) {
|
|
8583
|
+
extra = [
|
|
8584
|
+
{
|
|
8585
|
+
ext: 'ts.map',
|
|
8586
|
+
output: 'js.map',
|
|
8587
|
+
},
|
|
8588
|
+
// {
|
|
8589
|
+
// ext: 'd.ts',
|
|
8590
|
+
// output: 'd.ts',
|
|
8591
|
+
// }
|
|
8592
|
+
];
|
|
8593
|
+
}
|
|
8584
8594
|
let readFile = Configuration_1.Configuration.Instance.get('readFile');
|
|
8585
8595
|
await (0, alot_1.default)(extra).forEachAsync(async (x) => {
|
|
8586
8596
|
let cloned = cloneWithExtension(resource, x.ext);
|
|
@@ -12225,6 +12235,7 @@ const res_1 = _src_utils_res;
|
|
|
12225
12235
|
const tree_1 = _src_utils_tree;
|
|
12226
12236
|
const Builder_1 = _src_builder_Builder;
|
|
12227
12237
|
const color_1 = _src_utils_color;
|
|
12238
|
+
const File_1 = _src_config_File;
|
|
12228
12239
|
class Bundler extends atma_utils_1.class_EventEmitter {
|
|
12229
12240
|
static clearCache() {
|
|
12230
12241
|
Loader_1.Loader.clearCache();
|
|
@@ -12354,7 +12365,11 @@ class Bundler extends atma_utils_1.class_EventEmitter {
|
|
|
12354
12365
|
let solution = bundler.solution;
|
|
12355
12366
|
function builderComplete(resources) {
|
|
12356
12367
|
resources.forEach(res => {
|
|
12357
|
-
|
|
12368
|
+
let content = res.content;
|
|
12369
|
+
if (typeof content !== 'string') {
|
|
12370
|
+
content = JSON.stringify(content, null, 2);
|
|
12371
|
+
}
|
|
12372
|
+
File_1.FileActions.writeFile(res.filename, content, { skipHooks: true });
|
|
12358
12373
|
});
|
|
12359
12374
|
return solution
|
|
12360
12375
|
.assetsManager
|
package/lib/cli.js
CHANGED
|
@@ -5067,8 +5067,8 @@ const Resource_1 = _src_class_Resource;
|
|
|
5067
5067
|
const Templates_1 = _src_handlers_script_common_js_templates_Templates;
|
|
5068
5068
|
exports.CommonJsBuilderSimplified = {
|
|
5069
5069
|
wrapModule(resource, outputItem, outputItems, setts) {
|
|
5070
|
-
|
|
5071
|
-
|
|
5070
|
+
let varId = getVarId(resource);
|
|
5071
|
+
let content = resource.content;
|
|
5072
5072
|
content = replaceWithVarIds(content, resource, this.solution);
|
|
5073
5073
|
content = Templates_1.Templates
|
|
5074
5074
|
.ModuleSimplified
|
|
@@ -5076,7 +5076,7 @@ exports.CommonJsBuilderSimplified = {
|
|
|
5076
5076
|
.replace(/[_]{3}MODULE[_]{3}/g, () => content)
|
|
5077
5077
|
.replace(/[_]{3}FOOTER[_]{3}/g, () => { var _a, _b; return ((_b = (_a = setts === null || setts === void 0 ? void 0 : setts.partials) === null || _a === void 0 ? void 0 : _a.footer) !== null && _b !== void 0 ? _b : ''); });
|
|
5078
5078
|
;
|
|
5079
|
-
|
|
5079
|
+
let opts = this.solution.iteration;
|
|
5080
5080
|
if (opts.commonjs == null) {
|
|
5081
5081
|
opts.commonjs = {
|
|
5082
5082
|
addHeading: true,
|
|
@@ -5091,11 +5091,12 @@ exports.CommonJsBuilderSimplified = {
|
|
|
5091
5091
|
return content;
|
|
5092
5092
|
},
|
|
5093
5093
|
getRootContent(root) {
|
|
5094
|
-
|
|
5094
|
+
let rootInput = this.solution.outputResources.rootInput;
|
|
5095
|
+
let content = replaceWithVarIds(root.content, rootInput, this.solution);
|
|
5095
5096
|
return content;
|
|
5096
5097
|
},
|
|
5097
5098
|
getHeaderContent() {
|
|
5098
|
-
|
|
5099
|
+
let resources = this
|
|
5099
5100
|
.solution
|
|
5100
5101
|
.outputResources
|
|
5101
5102
|
.items
|
|
@@ -5105,10 +5106,13 @@ exports.CommonJsBuilderSimplified = {
|
|
|
5105
5106
|
}
|
|
5106
5107
|
};
|
|
5107
5108
|
function replaceWithVarIds(content, resource, solution) {
|
|
5108
|
-
|
|
5109
|
+
let rgx_REQUIRE = /require\s*\(\s*['"]([^'"]+)['"]\s*\)/g;
|
|
5110
|
+
if (typeof content !== 'string') {
|
|
5111
|
+
return JSON.stringify(content);
|
|
5112
|
+
}
|
|
5109
5113
|
return content.replace(rgx_REQUIRE, (full, path) => {
|
|
5110
|
-
|
|
5111
|
-
|
|
5114
|
+
let res = new Resource_1.Resource({ url: path, type: 'js' }, resource, solution);
|
|
5115
|
+
let current = resource.resources.find(x => x.url === res.url);
|
|
5112
5116
|
if (current == null) {
|
|
5113
5117
|
return full;
|
|
5114
5118
|
}
|
|
@@ -5116,11 +5120,11 @@ function replaceWithVarIds(content, resource, solution) {
|
|
|
5116
5120
|
});
|
|
5117
5121
|
}
|
|
5118
5122
|
function getVarId(resource) {
|
|
5119
|
-
|
|
5123
|
+
let str = resource.url.replace(/\.\w+$/, '');
|
|
5120
5124
|
return str.replace(/[^\w\d]/g, '_');
|
|
5121
5125
|
}
|
|
5122
5126
|
function getModuleVars(resources) {
|
|
5123
|
-
return resources.map(getVarId).sort().map(x => `
|
|
5127
|
+
return resources.map(getVarId).sort().map(x => `let ${x} = {};`).join('\n') + '\n';
|
|
5124
5128
|
}
|
|
5125
5129
|
//# sourceMappingURL=CommonJsBuilderSimplified.js.map
|
|
5126
5130
|
//# sourceMappingURL=CommonJsBuilderSimplified.ts.map;
|
|
@@ -8576,13 +8580,19 @@ class CopyJsBuilder extends BaseScriptBuilder_1.BaseScriptBuilder {
|
|
|
8576
8580
|
let result = [
|
|
8577
8581
|
createOutputItem(cloneWithExtension(resource, this.solution.opts.outputExtension))
|
|
8578
8582
|
];
|
|
8579
|
-
let extra = [
|
|
8580
|
-
|
|
8581
|
-
|
|
8582
|
-
|
|
8583
|
-
|
|
8584
|
-
|
|
8585
|
-
|
|
8583
|
+
let extra = [];
|
|
8584
|
+
if (resource.filename.endsWith('.ts')) {
|
|
8585
|
+
extra = [
|
|
8586
|
+
{
|
|
8587
|
+
ext: 'ts.map',
|
|
8588
|
+
output: 'js.map',
|
|
8589
|
+
},
|
|
8590
|
+
// {
|
|
8591
|
+
// ext: 'd.ts',
|
|
8592
|
+
// output: 'd.ts',
|
|
8593
|
+
// }
|
|
8594
|
+
];
|
|
8595
|
+
}
|
|
8586
8596
|
let readFile = Configuration_1.Configuration.Instance.get('readFile');
|
|
8587
8597
|
await (0, alot_1.default)(extra).forEachAsync(async (x) => {
|
|
8588
8598
|
let cloned = cloneWithExtension(resource, x.ext);
|
|
@@ -12227,6 +12237,7 @@ const res_1 = _src_utils_res;
|
|
|
12227
12237
|
const tree_1 = _src_utils_tree;
|
|
12228
12238
|
const Builder_1 = _src_builder_Builder;
|
|
12229
12239
|
const color_1 = _src_utils_color;
|
|
12240
|
+
const File_1 = _src_config_File;
|
|
12230
12241
|
class Bundler extends atma_utils_1.class_EventEmitter {
|
|
12231
12242
|
static clearCache() {
|
|
12232
12243
|
Loader_1.Loader.clearCache();
|
|
@@ -12356,7 +12367,11 @@ class Bundler extends atma_utils_1.class_EventEmitter {
|
|
|
12356
12367
|
let solution = bundler.solution;
|
|
12357
12368
|
function builderComplete(resources) {
|
|
12358
12369
|
resources.forEach(res => {
|
|
12359
|
-
|
|
12370
|
+
let content = res.content;
|
|
12371
|
+
if (typeof content !== 'string') {
|
|
12372
|
+
content = JSON.stringify(content, null, 2);
|
|
12373
|
+
}
|
|
12374
|
+
File_1.FileActions.writeFile(res.filename, content, { skipHooks: true });
|
|
12360
12375
|
});
|
|
12361
12376
|
return solution
|
|
12362
12377
|
.assetsManager
|