app-bundler 0.2.9 → 0.2.10
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 +20 -11
- package/lib/cli.js +20 -11
- 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;
|
|
@@ -12225,6 +12229,7 @@ const res_1 = _src_utils_res;
|
|
|
12225
12229
|
const tree_1 = _src_utils_tree;
|
|
12226
12230
|
const Builder_1 = _src_builder_Builder;
|
|
12227
12231
|
const color_1 = _src_utils_color;
|
|
12232
|
+
const File_1 = _src_config_File;
|
|
12228
12233
|
class Bundler extends atma_utils_1.class_EventEmitter {
|
|
12229
12234
|
static clearCache() {
|
|
12230
12235
|
Loader_1.Loader.clearCache();
|
|
@@ -12354,7 +12359,11 @@ class Bundler extends atma_utils_1.class_EventEmitter {
|
|
|
12354
12359
|
let solution = bundler.solution;
|
|
12355
12360
|
function builderComplete(resources) {
|
|
12356
12361
|
resources.forEach(res => {
|
|
12357
|
-
|
|
12362
|
+
let content = res.content;
|
|
12363
|
+
if (typeof content !== 'string') {
|
|
12364
|
+
content = JSON.stringify(content, null, 2);
|
|
12365
|
+
}
|
|
12366
|
+
File_1.FileActions.writeFile(res.filename, content, { skipHooks: true });
|
|
12358
12367
|
});
|
|
12359
12368
|
return solution
|
|
12360
12369
|
.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;
|
|
@@ -12227,6 +12231,7 @@ const res_1 = _src_utils_res;
|
|
|
12227
12231
|
const tree_1 = _src_utils_tree;
|
|
12228
12232
|
const Builder_1 = _src_builder_Builder;
|
|
12229
12233
|
const color_1 = _src_utils_color;
|
|
12234
|
+
const File_1 = _src_config_File;
|
|
12230
12235
|
class Bundler extends atma_utils_1.class_EventEmitter {
|
|
12231
12236
|
static clearCache() {
|
|
12232
12237
|
Loader_1.Loader.clearCache();
|
|
@@ -12356,7 +12361,11 @@ class Bundler extends atma_utils_1.class_EventEmitter {
|
|
|
12356
12361
|
let solution = bundler.solution;
|
|
12357
12362
|
function builderComplete(resources) {
|
|
12358
12363
|
resources.forEach(res => {
|
|
12359
|
-
|
|
12364
|
+
let content = res.content;
|
|
12365
|
+
if (typeof content !== 'string') {
|
|
12366
|
+
content = JSON.stringify(content, null, 2);
|
|
12367
|
+
}
|
|
12368
|
+
File_1.FileActions.writeFile(res.filename, content, { skipHooks: true });
|
|
12360
12369
|
});
|
|
12361
12370
|
return solution
|
|
12362
12371
|
.assetsManager
|