jsgui3-server 0.0.98 → 0.0.100
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/examples/box/{square_box_client.js → 1) square box/client.js } +40 -5
- package/examples/box/{square_box.js → 1) square box/server.js } +10 -3
- package/examples/box/2) twenty square boxes/css flex wrap/client.js +248 -0
- package/examples/box/2) twenty square boxes/css flex wrap/server.js +113 -0
- package/examples/controls/1) window/client.js +184 -0
- package/examples/controls/1) window/server.js +114 -0
- package/examples/controls/{_html-server-color-palette.js → __old/_html-server-color-palette.js} +2 -2
- package/examples/controls/{scs-month-view.js → __old/scs-month-view.js} +0 -1
- package/http/responders/HTTP_Responder.js +16 -0
- package/http/responders/static/Static_Route_HTTP_Responder.js +106 -0
- package/package.json +9 -8
- package/page-context.js +15 -0
- package/publishers/helpers/assigners/Assigner.js +11 -0
- package/publishers/helpers/assigners/static-compressed-response-buffers/Single_Control_Webpage_Server_Static_Compressed_Response_Buffers_Assigner.js +150 -0
- package/publishers/helpers/assigners/static-headers/Single_Control_Webpage_Server_Static_Headers_Assigner.js +110 -0
- package/publishers/helpers/assigners/static-routes/Single_Control_Webpage_Server_Static_Routes_Assigner.js +92 -0
- package/publishers/helpers/assigners/static-uncompressed-response-buffers/Single_Control_Webpage_Server_Static_Uncompressed_Response_Buffers_Assigner.js +104 -0
- package/publishers/helpers/preparers/static/bundle/Ready_To_Serve_Preparer.js +19 -0
- package/publishers/helpers/preparers/static/bundle/Static_Routes_Responses_Webpage_Bundle_Preparer.js +45 -0
- package/publishers/http-webpage-publisher.js +483 -3
- package/publishers/http-webpageorsite-publisher.js +343 -0
- package/publishers/http-website-publisher.js +51 -2
- package/resources/compile/server-resource-compilation.js +2 -0
- package/resources/jsbuilder/JS_AST/JS_AST_Node_0-Core.js +26 -0
- package/resources/processors/bundlers/css-bundler.js +24 -1
- package/resources/processors/bundlers/js/JS_Bundler.js +52 -0
- package/resources/processors/bundlers/js/esbuild/Advanced_JS_Bundler_Using_ESBuild.js +389 -0
- package/resources/processors/bundlers/js/esbuild/Bundler_Using_ESBuild.js +9 -0
- package/resources/processors/bundlers/js/esbuild/Core_JS_Non_Minifying_Bundler_Using_ESBuild.js +186 -0
- package/resources/processors/bundlers/js/esbuild/Core_JS_Single_File_Minifying_Bundler_Using_ESBuild.js +191 -0
- package/resources/processors/bundlers/js/esbuild/_Old_CSS_Extractor.js +240 -0
- package/resources/processors/bundlers/js-bundler.js +201 -193
- package/resources/processors/bundlers/webpage-bundler.js +15 -0
- package/resources/processors/extractors/Extractor.js +10 -0
- package/resources/processors/extractors/js/css_and_js/AST_Node/CSS_And_JS_From_JS_String_Using_AST_Node_Extractor.js +239 -0
- package/resources/processors/extractors/js/css_and_js/CSS_And_JS_From_JS_String_Extractor.js +4 -0
- package/resources/processors/extractors/string/Pos_Span_String_Extractor.js +94 -0
- package/server.js +188 -5
- package/static-page-context.js +14 -0
- package/examples/box/box.css +0 -8
- package/examples/box/out_square_box_client.js +0 -48
- /package/examples/controls/{html-server-combo-box.js → __old/html-server-combo-box.js} +0 -0
- /package/examples/controls/{html-server-list.js → __old/html-server-list.js} +0 -0
- /package/examples/controls/{html-server-popup-menu-button.js → __old/html-server-popup-menu-button.js} +0 -0
- /package/examples/controls/{html-server-start-stop-toggle-button.js → __old/html-server-start-stop-toggle-button.js} +0 -0
- /package/examples/controls/{scs-arrow-button.js → __old/scs-arrow-button.js} +0 -0
- /package/examples/controls/{scs-date-picker.js → __old/scs-date-picker.js} +0 -0
- /package/examples/controls/{scs-file-browser.js → __old/scs-file-browser.js} +0 -0
- /package/examples/controls/{scs-item.js → __old/scs-item.js} +0 -0
- /package/examples/controls/{scs-month-arrow-selector.js → __old/scs-month-arrow-selector.js} +0 -0
- /package/examples/controls/{scs-start-stop-toggle-button.js → __old/scs-start-stop-toggle-button.js} +0 -0
- /package/examples/controls/{scs-tree.js → __old/scs-tree.js} +0 -0
- /package/examples/controls/{scs-year-arrow-selector.js → __old/scs-year-arrow-selector.js} +0 -0
|
@@ -0,0 +1,389 @@
|
|
|
1
|
+
// Advanced in terms of being able to split CSS and JS from JS.
|
|
2
|
+
const {obs} = require('fnl');
|
|
3
|
+
const esbuild = require('esbuild')
|
|
4
|
+
const Core_JS_Non_Minifying_Bundler_Using_ESBuild = require('./Core_JS_Non_Minifying_Bundler_Using_ESBuild');
|
|
5
|
+
const Bundler_Using_ESBuild = require('./Bundler_Using_ESBuild');
|
|
6
|
+
const {is_array} = require('lang-tools');
|
|
7
|
+
|
|
8
|
+
const Core_JS_Single_File_Minifying_Bundler_Using_ESBuild = require('./Core_JS_Single_File_Minifying_Bundler_Using_ESBuild');
|
|
9
|
+
|
|
10
|
+
//const CSS_Extractor = require('./_Old_CSS_Extractor');
|
|
11
|
+
|
|
12
|
+
// Use a different CSS extractor.
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
const Bundle = require('../../bundle');
|
|
16
|
+
|
|
17
|
+
const CSS_And_JS_From_JS_String_Extractor = require('../../../extractors/js/css_and_js/CSS_And_JS_From_JS_String_Extractor');
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
class Advanced_JS_Bundler_Using_ESBuild extends Bundler_Using_ESBuild {
|
|
21
|
+
constructor(spec) {
|
|
22
|
+
super(spec);
|
|
23
|
+
|
|
24
|
+
if (spec.debug !== undefined) this.debug = spec.debug;
|
|
25
|
+
|
|
26
|
+
//this.css_extractor = new CSS_Extractor();
|
|
27
|
+
|
|
28
|
+
|
|
29
|
+
this.non_minifying_bundler = new Core_JS_Non_Minifying_Bundler_Using_ESBuild({
|
|
30
|
+
debug: this.debug
|
|
31
|
+
});
|
|
32
|
+
|
|
33
|
+
|
|
34
|
+
this.css_and_js_from_js_string_extractor = new CSS_And_JS_From_JS_String_Extractor();
|
|
35
|
+
|
|
36
|
+
|
|
37
|
+
// Probably don't use that minifying bundler in debug mode.
|
|
38
|
+
this.minifying_js_single_file_bundler = new Core_JS_Single_File_Minifying_Bundler_Using_ESBuild();
|
|
39
|
+
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
bundle(js_file_path) {
|
|
43
|
+
const {non_minifying_bundler, css_and_js_from_js_string_extractor, minifying_js_single_file_bundler} = this;
|
|
44
|
+
|
|
45
|
+
// Maybe this should get them positioned absolutely when removed from the grid?
|
|
46
|
+
// But then what about the space they leave?
|
|
47
|
+
|
|
48
|
+
// This is just a simple principle demo though.
|
|
49
|
+
// Maybe want a simple and explicit option to change behaviour like I specify.
|
|
50
|
+
|
|
51
|
+
|
|
52
|
+
|
|
53
|
+
const res_obs = obs(async(next, complete, error) => {
|
|
54
|
+
|
|
55
|
+
//console.log('Advanced_JS_Bundler_Using_ESBuild bundle js_file_path:', js_file_path);
|
|
56
|
+
|
|
57
|
+
const res_nmb = await non_minifying_bundler.bundle(js_file_path);
|
|
58
|
+
|
|
59
|
+
//console.log('res_nmb', res_nmb);
|
|
60
|
+
|
|
61
|
+
if (res_nmb.length === 1) {
|
|
62
|
+
const js_bundle = res_nmb[0];
|
|
63
|
+
const js_bundle_arr = js_bundle._arr;
|
|
64
|
+
if (js_bundle_arr) {
|
|
65
|
+
if (js_bundle_arr.length === 1) {
|
|
66
|
+
const bundle_item = js_bundle_arr[0];
|
|
67
|
+
//console.log('bundle_item', bundle_item);
|
|
68
|
+
|
|
69
|
+
if (bundle_item.type === 'JavaScript') {
|
|
70
|
+
|
|
71
|
+
// But in debug mode don't minify it.
|
|
72
|
+
// Maybe create and add the sourcemap here instead....?
|
|
73
|
+
|
|
74
|
+
const {text} = bundle_item;
|
|
75
|
+
// Then use the css and js from js extractor.
|
|
76
|
+
|
|
77
|
+
const res_extract_css_and_js_from_js = await css_and_js_from_js_string_extractor.extract(text);
|
|
78
|
+
const {css, js} = res_extract_css_and_js_from_js;
|
|
79
|
+
|
|
80
|
+
if (this.debug) {
|
|
81
|
+
|
|
82
|
+
// sourcemap: 'inline'
|
|
83
|
+
|
|
84
|
+
// Don't minify the js.
|
|
85
|
+
|
|
86
|
+
// Make res bundle items that include the CSS and the non-minified JS.
|
|
87
|
+
|
|
88
|
+
// Including the source map would be better still.
|
|
89
|
+
|
|
90
|
+
const res_bundle = new Bundle();
|
|
91
|
+
// Add the non-minified JS (as a bundle item object)
|
|
92
|
+
|
|
93
|
+
const o_js_bundle_item = {
|
|
94
|
+
type: 'JavaScript',
|
|
95
|
+
extension: 'JS',
|
|
96
|
+
text: js
|
|
97
|
+
}
|
|
98
|
+
res_bundle.add(o_js_bundle_item);
|
|
99
|
+
const o_css_bundle_item = {
|
|
100
|
+
type: 'CSS',
|
|
101
|
+
extension: 'css',
|
|
102
|
+
text: css
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
res_bundle.push(o_css_bundle_item);
|
|
106
|
+
next(res_bundle);
|
|
107
|
+
complete(res_bundle);
|
|
108
|
+
|
|
109
|
+
|
|
110
|
+
|
|
111
|
+
|
|
112
|
+
|
|
113
|
+
|
|
114
|
+
|
|
115
|
+
|
|
116
|
+
} else {
|
|
117
|
+
|
|
118
|
+
|
|
119
|
+
const minified_js = await minifying_js_single_file_bundler.bundle(js);
|
|
120
|
+
|
|
121
|
+
//console.log('minified_js', minified_js);
|
|
122
|
+
//console.log('minified_js.length', minified_js.length);
|
|
123
|
+
|
|
124
|
+
// it's an array....
|
|
125
|
+
|
|
126
|
+
if (is_array(minified_js)) {
|
|
127
|
+
|
|
128
|
+
if (minified_js.length === 1) {
|
|
129
|
+
|
|
130
|
+
|
|
131
|
+
// Should put it all in a single res bundle though....
|
|
132
|
+
// Though merging / concating bundles will be fine too.
|
|
133
|
+
|
|
134
|
+
|
|
135
|
+
|
|
136
|
+
const minified_js_bundle_collection = minified_js[0];
|
|
137
|
+
|
|
138
|
+
|
|
139
|
+
|
|
140
|
+
const o_css_bundle_item = {
|
|
141
|
+
type: 'CSS',
|
|
142
|
+
extension: 'css',
|
|
143
|
+
text: css
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
minified_js_bundle_collection.push(o_css_bundle_item);
|
|
147
|
+
|
|
148
|
+
|
|
149
|
+
// Maybe will provide the class / class instance that processes CSS or SASS/SCSS / whatever else.
|
|
150
|
+
|
|
151
|
+
|
|
152
|
+
|
|
153
|
+
// Could add the extracted CSS here.
|
|
154
|
+
|
|
155
|
+
|
|
156
|
+
|
|
157
|
+
next(minified_js_bundle_collection);
|
|
158
|
+
|
|
159
|
+
// But create a CSS bundle item...
|
|
160
|
+
|
|
161
|
+
|
|
162
|
+
|
|
163
|
+
|
|
164
|
+
|
|
165
|
+
// And also the CSS...
|
|
166
|
+
|
|
167
|
+
|
|
168
|
+
|
|
169
|
+
|
|
170
|
+
|
|
171
|
+
complete(minified_js_bundle_collection);
|
|
172
|
+
|
|
173
|
+
|
|
174
|
+
|
|
175
|
+
const unneeded_looking_into_the_js_bundle = () => {
|
|
176
|
+
if (minified_js_bundle_collection._arr) {
|
|
177
|
+
|
|
178
|
+
if (minified_js_bundle_collection._arr.length === 1) {
|
|
179
|
+
|
|
180
|
+
const minified_js_bundle_item = minified_js_bundle_collection._arr[0];
|
|
181
|
+
console.log('minified_js_bundle_item', minified_js_bundle_item);
|
|
182
|
+
|
|
183
|
+
|
|
184
|
+
if (minified_js_bundle_item.type === 'JavaScript') {
|
|
185
|
+
|
|
186
|
+
//const str_minified_js = minified_js_bundle_item.text;
|
|
187
|
+
|
|
188
|
+
//const res =
|
|
189
|
+
|
|
190
|
+
|
|
191
|
+
|
|
192
|
+
|
|
193
|
+
|
|
194
|
+
} else {
|
|
195
|
+
|
|
196
|
+
console.trace();
|
|
197
|
+
throw 'NYI';
|
|
198
|
+
|
|
199
|
+
}
|
|
200
|
+
|
|
201
|
+
|
|
202
|
+
// Could even check it's js here...?
|
|
203
|
+
|
|
204
|
+
|
|
205
|
+
console.trace();
|
|
206
|
+
throw 'NYI';
|
|
207
|
+
|
|
208
|
+
|
|
209
|
+
} else {
|
|
210
|
+
console.trace();
|
|
211
|
+
throw 'NYI';
|
|
212
|
+
}
|
|
213
|
+
|
|
214
|
+
} else {
|
|
215
|
+
|
|
216
|
+
console.trace();
|
|
217
|
+
throw 'NYI';
|
|
218
|
+
|
|
219
|
+
}
|
|
220
|
+
|
|
221
|
+
}
|
|
222
|
+
|
|
223
|
+
|
|
224
|
+
|
|
225
|
+
} else {
|
|
226
|
+
console.trace();
|
|
227
|
+
throw 'stop';
|
|
228
|
+
}
|
|
229
|
+
|
|
230
|
+
} else {
|
|
231
|
+
|
|
232
|
+
console.trace();
|
|
233
|
+
throw 'stop';
|
|
234
|
+
}
|
|
235
|
+
|
|
236
|
+
|
|
237
|
+
}
|
|
238
|
+
|
|
239
|
+
|
|
240
|
+
|
|
241
|
+
|
|
242
|
+
|
|
243
|
+
|
|
244
|
+
|
|
245
|
+
|
|
246
|
+
|
|
247
|
+
|
|
248
|
+
|
|
249
|
+
//console.trace();
|
|
250
|
+
//throw 'stop';
|
|
251
|
+
|
|
252
|
+
// And put things into a res bundle.
|
|
253
|
+
// Though possibly this could (even) bundle things into compressed files (with headers) ready to be
|
|
254
|
+
// served.
|
|
255
|
+
|
|
256
|
+
// Though there may be a class (or bunch of them), maybe in the Publisher, that determine and
|
|
257
|
+
// carry out adding references and using static routes, or putting the CSS and JS inline within the HTML.
|
|
258
|
+
// References seem very much better but want control of this to be as clear as possible.
|
|
259
|
+
|
|
260
|
+
|
|
261
|
+
|
|
262
|
+
|
|
263
|
+
// Maybe that will be a Ready_To_Serve_Static_Bundle
|
|
264
|
+
|
|
265
|
+
|
|
266
|
+
|
|
267
|
+
|
|
268
|
+
|
|
269
|
+
// Though it needs to provide (a bundle of?) both JS and CSS.
|
|
270
|
+
// Better to use a standard bundle class (collection) to transfer these objects.
|
|
271
|
+
|
|
272
|
+
// .css or .get('css') perhaps???
|
|
273
|
+
|
|
274
|
+
// Array does seem simpler, esp as it does not really have to be a 'bundle' object.
|
|
275
|
+
// Maybe a Bundle class instance would help here in some ways.
|
|
276
|
+
|
|
277
|
+
// Then will apply minifying compression to the JS.
|
|
278
|
+
// ESBuild is really fast for this.
|
|
279
|
+
|
|
280
|
+
// Likely to have different publisher options for how the HTML and CSS is included in the page.
|
|
281
|
+
// With the most sensible defaults used.
|
|
282
|
+
// Serving the files as static, and referenced from within the HTML.
|
|
283
|
+
// Will look into options / setups for efficient serving of websites where there is
|
|
284
|
+
// varying client side logic for each page, but can reference built components which don't change.
|
|
285
|
+
|
|
286
|
+
// Or basically just initialise everything on the client page.
|
|
287
|
+
|
|
288
|
+
// Will have moderately to very structure of classes, very specific in terms of what they do and how they do it.
|
|
289
|
+
|
|
290
|
+
|
|
291
|
+
|
|
292
|
+
|
|
293
|
+
|
|
294
|
+
|
|
295
|
+
|
|
296
|
+
|
|
297
|
+
|
|
298
|
+
|
|
299
|
+
|
|
300
|
+
|
|
301
|
+
|
|
302
|
+
|
|
303
|
+
|
|
304
|
+
|
|
305
|
+
//console.log('res_extract_css_and_js_from_js', res_extract_css_and_js_from_js);
|
|
306
|
+
|
|
307
|
+
//console.trace();
|
|
308
|
+
//throw 'stop';
|
|
309
|
+
|
|
310
|
+
|
|
311
|
+
} else {
|
|
312
|
+
console.trace();
|
|
313
|
+
throw 'NYI';
|
|
314
|
+
}
|
|
315
|
+
|
|
316
|
+
//console.trace();
|
|
317
|
+
//throw 'stop';
|
|
318
|
+
} else {
|
|
319
|
+
console.trace();
|
|
320
|
+
throw 'NYI';
|
|
321
|
+
}
|
|
322
|
+
} else {
|
|
323
|
+
console.trace();
|
|
324
|
+
throw 'NYI';
|
|
325
|
+
}
|
|
326
|
+
|
|
327
|
+
|
|
328
|
+
} else {
|
|
329
|
+
console.trace();
|
|
330
|
+
throw 'NYI';
|
|
331
|
+
}
|
|
332
|
+
|
|
333
|
+
//console.trace();
|
|
334
|
+
//throw 'stop';
|
|
335
|
+
|
|
336
|
+
|
|
337
|
+
|
|
338
|
+
// Need to use a non minifying bundler (first).
|
|
339
|
+
|
|
340
|
+
|
|
341
|
+
const _old_code = async() => {
|
|
342
|
+
|
|
343
|
+
const css_extractor_res = await css_extractor.separate_css_and_js(js_file_path)
|
|
344
|
+
|
|
345
|
+
console.log('css_extractor_res', css_extractor_res);
|
|
346
|
+
|
|
347
|
+
/*
|
|
348
|
+
|
|
349
|
+
let result = await esbuild.build({
|
|
350
|
+
entryPoints: ['js_file_path'],
|
|
351
|
+
//sourcemap: 'external',
|
|
352
|
+
write: false,
|
|
353
|
+
outdir: 'out',
|
|
354
|
+
})
|
|
355
|
+
console.log('result.outputFiles:\n\n');
|
|
356
|
+
for (let out of result.outputFiles) {
|
|
357
|
+
console.log('out.path, out.contents, out.hash, out.text', out.path, out.contents, out.hash, out.text)
|
|
358
|
+
}
|
|
359
|
+
|
|
360
|
+
*/
|
|
361
|
+
|
|
362
|
+
// Should use (an instance of?) the core bundler.
|
|
363
|
+
// Or the CSS extractor even.
|
|
364
|
+
|
|
365
|
+
|
|
366
|
+
|
|
367
|
+
console.trace();
|
|
368
|
+
throw 'NYI';
|
|
369
|
+
|
|
370
|
+
}
|
|
371
|
+
|
|
372
|
+
|
|
373
|
+
|
|
374
|
+
|
|
375
|
+
|
|
376
|
+
});
|
|
377
|
+
return res_obs;
|
|
378
|
+
|
|
379
|
+
// The bundle result should have a few things, makes sense to make it an object or class, not too complicated.
|
|
380
|
+
|
|
381
|
+
|
|
382
|
+
|
|
383
|
+
}
|
|
384
|
+
|
|
385
|
+
|
|
386
|
+
|
|
387
|
+
}
|
|
388
|
+
|
|
389
|
+
module.exports = Advanced_JS_Bundler_Using_ESBuild;
|
package/resources/processors/bundlers/js/esbuild/Core_JS_Non_Minifying_Bundler_Using_ESBuild.js
ADDED
|
@@ -0,0 +1,186 @@
|
|
|
1
|
+
|
|
2
|
+
// This won't deal with CSS, maybe will have some options for it.
|
|
3
|
+
|
|
4
|
+
const {obs} = require('fnl');
|
|
5
|
+
const esbuild = require('esbuild')
|
|
6
|
+
|
|
7
|
+
const Bundle = require('../../bundle');
|
|
8
|
+
const Bundler_Using_ESBuild = require('./Bundler_Using_ESBuild');
|
|
9
|
+
// extends Bundler ???
|
|
10
|
+
// extends Core_Bundler?
|
|
11
|
+
// exends Base_Bundler???
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
class Core_JS_Non_Minifying_Bundler_Using_ESBuild extends Bundler_Using_ESBuild {
|
|
17
|
+
constructor(spec) {
|
|
18
|
+
super(spec);
|
|
19
|
+
|
|
20
|
+
if (spec.debug !== undefined) this.debug = spec.debug;
|
|
21
|
+
|
|
22
|
+
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
// And the options....
|
|
26
|
+
|
|
27
|
+
// May want to have it do minification by default?
|
|
28
|
+
// Or even call a specific minifier class later on....
|
|
29
|
+
|
|
30
|
+
// Making classes with very specific responsibilities to do very specific things may help.
|
|
31
|
+
|
|
32
|
+
// Core_JS_Non_Minifying_Bundler_Using_ESBuild for example....
|
|
33
|
+
|
|
34
|
+
// Really specific class names for specific functionality to call reqlly quickly and interchange really quickly.
|
|
35
|
+
|
|
36
|
+
// Probably use the non-minifying bundler, and then use a minifier afterwards.
|
|
37
|
+
// And here the minifier is ESBuild, as is the bundler.
|
|
38
|
+
|
|
39
|
+
|
|
40
|
+
|
|
41
|
+
|
|
42
|
+
|
|
43
|
+
|
|
44
|
+
|
|
45
|
+
bundle(js_file_path) {
|
|
46
|
+
|
|
47
|
+
|
|
48
|
+
const res_obs = obs(async(next, complete, error) => {
|
|
49
|
+
|
|
50
|
+
//console.log('Core_JS_Bundler_Using_ESBuild bundle js_file_path:', js_file_path);
|
|
51
|
+
|
|
52
|
+
// Looks like we need better linking build options....
|
|
53
|
+
|
|
54
|
+
const o_build = {
|
|
55
|
+
entryPoints: [js_file_path],
|
|
56
|
+
bundle: true,
|
|
57
|
+
|
|
58
|
+
// Possibly no minification here....
|
|
59
|
+
// Want to use non-minified or only partially minified version to separate the JS and the CSS.
|
|
60
|
+
|
|
61
|
+
treeShaking: true,
|
|
62
|
+
|
|
63
|
+
//sourcemap: 'external',
|
|
64
|
+
write: false,
|
|
65
|
+
outdir: 'out',
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
if (this.debug) {
|
|
69
|
+
o_build.sourcemap = 'inline';
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
|
|
73
|
+
|
|
74
|
+
let result = await esbuild.build(o_build);
|
|
75
|
+
//console.log('result.outputFiles:\n\n');
|
|
76
|
+
//for (let out of result.outputFiles) {
|
|
77
|
+
//console.log('out.path, out.contents, out.hash, out.text', out.path, out.contents, out.hash, out.text)
|
|
78
|
+
//}
|
|
79
|
+
|
|
80
|
+
//console.log('result.outputFiles.length', result.outputFiles.length);
|
|
81
|
+
|
|
82
|
+
|
|
83
|
+
if (result.outputFiles.length === 1) {
|
|
84
|
+
|
|
85
|
+
const output_file = result.outputFiles[0];
|
|
86
|
+
|
|
87
|
+
//console.log('output_file.text.length', output_file.text.length);
|
|
88
|
+
//console.log('output_file.text', output_file.text);
|
|
89
|
+
|
|
90
|
+
//console.log('Object.keys(output_file)', Object.keys(output_file));
|
|
91
|
+
|
|
92
|
+
// The Bundle is a subclass of Collection.
|
|
93
|
+
// Maybe its better to make it an Object class that assigns all properties from spec.
|
|
94
|
+
|
|
95
|
+
// May be much simpler and more flexible for the moment.
|
|
96
|
+
// Or an array (or collection) of BundleItem instances???
|
|
97
|
+
|
|
98
|
+
// Maybe don't have the Bundle extend Collection?
|
|
99
|
+
// Maybe overhaul Collection?
|
|
100
|
+
|
|
101
|
+
// Or use Collection and possibly get onto improving it.
|
|
102
|
+
// Need to be careful as Collection is integral to Controls.
|
|
103
|
+
|
|
104
|
+
// The Bundle should have items, like a collection.
|
|
105
|
+
// Maybe indexed by paths???
|
|
106
|
+
|
|
107
|
+
const res_bundle = new Bundle();
|
|
108
|
+
|
|
109
|
+
// Really flexible Bundle_Item perhaps....?
|
|
110
|
+
// The Bundle_Item will need to be able to represent data in different stages of preparation.
|
|
111
|
+
|
|
112
|
+
|
|
113
|
+
// Just the text?
|
|
114
|
+
const o_bundle_item = {
|
|
115
|
+
type: 'JavaScript',
|
|
116
|
+
extension: 'js',
|
|
117
|
+
text: output_file.text
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
res_bundle.push(o_bundle_item);
|
|
121
|
+
|
|
122
|
+
next(res_bundle);
|
|
123
|
+
complete();
|
|
124
|
+
|
|
125
|
+
|
|
126
|
+
|
|
127
|
+
|
|
128
|
+
|
|
129
|
+
|
|
130
|
+
|
|
131
|
+
// Spec_Property_Assigner class???
|
|
132
|
+
|
|
133
|
+
|
|
134
|
+
|
|
135
|
+
// Think we do have the (full?) output here.
|
|
136
|
+
|
|
137
|
+
// prob leave out the hash???
|
|
138
|
+
|
|
139
|
+
//console.log('output_file.contents', output_file.contents);
|
|
140
|
+
|
|
141
|
+
//const
|
|
142
|
+
|
|
143
|
+
// Bundle_Result or Bundle class?
|
|
144
|
+
|
|
145
|
+
// always have Bundlers return a Bundle?
|
|
146
|
+
|
|
147
|
+
|
|
148
|
+
|
|
149
|
+
|
|
150
|
+
|
|
151
|
+
|
|
152
|
+
|
|
153
|
+
|
|
154
|
+
//console.trace();
|
|
155
|
+
//throw 'NYI';
|
|
156
|
+
|
|
157
|
+
} else {
|
|
158
|
+
|
|
159
|
+
|
|
160
|
+
console.trace();
|
|
161
|
+
throw 'NYI';
|
|
162
|
+
|
|
163
|
+
}
|
|
164
|
+
|
|
165
|
+
|
|
166
|
+
// The core bundler....
|
|
167
|
+
// Maybe later even use a Static_Response_Preparer???
|
|
168
|
+
// And have the relevant Publisher use it?
|
|
169
|
+
|
|
170
|
+
|
|
171
|
+
|
|
172
|
+
|
|
173
|
+
|
|
174
|
+
|
|
175
|
+
});
|
|
176
|
+
return res_obs;
|
|
177
|
+
|
|
178
|
+
// The bundle result should have a few things, makes sense to make it an object or class, not too complicated.
|
|
179
|
+
|
|
180
|
+
|
|
181
|
+
|
|
182
|
+
}
|
|
183
|
+
|
|
184
|
+
}
|
|
185
|
+
|
|
186
|
+
module.exports = Core_JS_Non_Minifying_Bundler_Using_ESBuild;
|