@normed/bundle 4.0.0 → 4.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/CHANGELOG.md +5 -0
- package/bundles/bin/cli.js +85 -20
- package/bundles/bin/cli.js.map +3 -3
- package/bundles/esbuild-plugins/log_esbuild.d.ts +3 -0
- package/bundles/index.js +53 -14
- package/bundles/index.js.map +2 -2
- package/package.json +3 -3
package/CHANGELOG.md
CHANGED
|
@@ -6,6 +6,11 @@ Given a version number MAJOR.MINOR.PATCH, increment the:
|
|
|
6
6
|
2. MINOR version when you add functionality in a backwards compatible manner, and
|
|
7
7
|
3. PATCH version when you make backwards compatible bug fixes.
|
|
8
8
|
|
|
9
|
+
# 4.1.0
|
|
10
|
+
|
|
11
|
+
* MINOR: fixes building of entypoint pug files.
|
|
12
|
+
* MINOR: updates error formatting to print less information, better.
|
|
13
|
+
|
|
9
14
|
# 4.0.0
|
|
10
15
|
|
|
11
16
|
* MAJOR: moves to a new package.json format
|
package/bundles/bin/cli.js
CHANGED
|
@@ -69035,33 +69035,49 @@ async function loadAsText2(_filepath) {
|
|
|
69035
69035
|
// as well - its probably faster than us doing it in JS.
|
|
69036
69036
|
};
|
|
69037
69037
|
}
|
|
69038
|
-
async function loadAsJS2(filepath) {
|
|
69038
|
+
async function loadAsJS2(filepath, options2) {
|
|
69039
69039
|
const fileData = await import_fs4.default.promises.readFile(filepath, "utf8");
|
|
69040
|
-
const contents = "export default " + import_pug.default.compileClient(fileData, {
|
|
69040
|
+
const contents = "export default " + import_pug.default.compileClient(fileData, {
|
|
69041
|
+
name: "render",
|
|
69042
|
+
filename: filepath,
|
|
69043
|
+
basedir: options2.outbase
|
|
69044
|
+
});
|
|
69041
69045
|
return {
|
|
69042
69046
|
contents,
|
|
69043
69047
|
loader: "js"
|
|
69044
69048
|
};
|
|
69045
69049
|
}
|
|
69046
|
-
async function loadAsHtml(filepath) {
|
|
69050
|
+
async function loadAsHtml(filepath, options2) {
|
|
69047
69051
|
const fileData = await import_fs4.default.promises.readFile(filepath, "utf8");
|
|
69048
|
-
const contents = import_pug.default.render(fileData, {
|
|
69052
|
+
const contents = import_pug.default.render(fileData, {
|
|
69053
|
+
name: "render",
|
|
69054
|
+
filename: filepath,
|
|
69055
|
+
basedir: options2.outbase
|
|
69056
|
+
});
|
|
69049
69057
|
return {
|
|
69050
69058
|
contents,
|
|
69051
69059
|
loader: "js"
|
|
69052
69060
|
};
|
|
69053
69061
|
}
|
|
69054
|
-
async function loadAsCopy(filepath) {
|
|
69062
|
+
async function loadAsCopy(filepath, options2) {
|
|
69055
69063
|
const fileData = await import_fs4.default.promises.readFile(filepath, "utf8");
|
|
69056
|
-
const contents = import_pug.default.render(fileData, {
|
|
69064
|
+
const contents = import_pug.default.render(fileData, {
|
|
69065
|
+
filename: filepath,
|
|
69066
|
+
basedir: options2.outbase,
|
|
69067
|
+
name: "render"
|
|
69068
|
+
});
|
|
69057
69069
|
return {
|
|
69058
69070
|
contents,
|
|
69059
69071
|
loader: "copy"
|
|
69060
69072
|
};
|
|
69061
69073
|
}
|
|
69062
|
-
async function loadAsFile(filepath) {
|
|
69074
|
+
async function loadAsFile(filepath, options2) {
|
|
69063
69075
|
const fileData = await import_fs4.default.promises.readFile(filepath, "utf8");
|
|
69064
|
-
const contents = import_pug.default.render(fileData, {
|
|
69076
|
+
const contents = import_pug.default.render(fileData, {
|
|
69077
|
+
name: "render",
|
|
69078
|
+
filename: filepath,
|
|
69079
|
+
basedir: options2.outbase
|
|
69080
|
+
});
|
|
69065
69081
|
return {
|
|
69066
69082
|
contents,
|
|
69067
69083
|
loader: "file"
|
|
@@ -69100,7 +69116,7 @@ var plugin2 = {
|
|
|
69100
69116
|
}) => {
|
|
69101
69117
|
const isEntryPoint = pluginData?.[name2]?.entrypoint;
|
|
69102
69118
|
if (isEntryPoint) {
|
|
69103
|
-
return loadAsCopy(filepath);
|
|
69119
|
+
return loadAsCopy(filepath, build2.initialOptions);
|
|
69104
69120
|
}
|
|
69105
69121
|
const type = withArg?.["type"] ?? "js";
|
|
69106
69122
|
switch (type) {
|
|
@@ -69108,7 +69124,7 @@ var plugin2 = {
|
|
|
69108
69124
|
// This gives a string of the pug already rendered to html
|
|
69109
69125
|
// TODO: could support passing options to pug.render via the with clause
|
|
69110
69126
|
case "html":
|
|
69111
|
-
return loadAsHtml(filepath);
|
|
69127
|
+
return loadAsHtml(filepath, build2.initialOptions);
|
|
69112
69128
|
// Load pug as a text file by doing "import template from './file.pug' with { type: 'text' }"
|
|
69113
69129
|
// This gives a string of the raw pug file, which can be used as pug - e.g. as a template string
|
|
69114
69130
|
case "pug":
|
|
@@ -69117,12 +69133,12 @@ var plugin2 = {
|
|
|
69117
69133
|
// Load pug as a render function by doing "import render from './file.pug' with { type: 'js' }"
|
|
69118
69134
|
// This is the default behaviour if no with clause is used, or no type is specified.
|
|
69119
69135
|
case "js":
|
|
69120
|
-
return loadAsJS2(filepath);
|
|
69136
|
+
return loadAsJS2(filepath, build2.initialOptions);
|
|
69121
69137
|
// Load pug as a file by doing "import template from './file.pug' with { type: 'file' }"
|
|
69122
69138
|
// This will render the pug file to a file, and return the path to that file.
|
|
69123
69139
|
// The path is going to contain a hash, so it is not going to be the same as the original file.
|
|
69124
69140
|
case "file":
|
|
69125
|
-
return loadAsFile(filepath);
|
|
69141
|
+
return loadAsFile(filepath, build2.initialOptions);
|
|
69126
69142
|
// In the case that the type is not recognised, throw an error
|
|
69127
69143
|
default:
|
|
69128
69144
|
throw new Error(`Unsupported type: ${type}`);
|
|
@@ -69290,7 +69306,9 @@ var esbuilder = {
|
|
|
69290
69306
|
entryPoints: build2.map(({ infile }) => infile.absolute),
|
|
69291
69307
|
outdir,
|
|
69292
69308
|
outbase: indir,
|
|
69293
|
-
write: false
|
|
69309
|
+
write: false,
|
|
69310
|
+
logLevel: "silent"
|
|
69311
|
+
// TODO: add a specific variable for this
|
|
69294
69312
|
};
|
|
69295
69313
|
log_default.debug(
|
|
69296
69314
|
`Final config:`,
|
|
@@ -69301,6 +69319,13 @@ var esbuilder = {
|
|
|
69301
69319
|
)
|
|
69302
69320
|
);
|
|
69303
69321
|
const codeBuild = esbuild.build(finalConfig).then(async (result) => {
|
|
69322
|
+
if (result.errors.length || result.warnings.length) {
|
|
69323
|
+
log_default.info(`Build completed with errors or warnings:`, {
|
|
69324
|
+
errors: result.errors.length,
|
|
69325
|
+
warnings: result.warnings.length
|
|
69326
|
+
});
|
|
69327
|
+
throw result;
|
|
69328
|
+
}
|
|
69304
69329
|
log_default.debug(
|
|
69305
69330
|
`Got output files:`,
|
|
69306
69331
|
result.outputFiles.map((f) => import_path7.default.relative(outdir, f.path))
|
|
@@ -69369,6 +69394,20 @@ var esbuilder = {
|
|
|
69369
69394
|
}
|
|
69370
69395
|
}
|
|
69371
69396
|
await Promise.all(writers);
|
|
69397
|
+
}).catch((err) => {
|
|
69398
|
+
const errors = err.errors || [];
|
|
69399
|
+
const warnings = err.warnings || [];
|
|
69400
|
+
if (!errors.length && !warnings.length) {
|
|
69401
|
+
log_default.error(
|
|
69402
|
+
`Build failed with no errors or warnings, but an unknown error occurred.`
|
|
69403
|
+
);
|
|
69404
|
+
throw err;
|
|
69405
|
+
} else {
|
|
69406
|
+
log_default.error(
|
|
69407
|
+
`Build failed with ${errors.length} errors and ${warnings.length} warnings.`
|
|
69408
|
+
);
|
|
69409
|
+
throw [...errors, ...warnings];
|
|
69410
|
+
}
|
|
69372
69411
|
});
|
|
69373
69412
|
promises.push(codeBuild);
|
|
69374
69413
|
if (exampleFile.entryconfig.declarations) {
|
|
@@ -70474,7 +70513,7 @@ async function bundle(options2 = {}) {
|
|
|
70474
70513
|
})().catch((e) => e)
|
|
70475
70514
|
)
|
|
70476
70515
|
);
|
|
70477
|
-
const errors = results.filter(
|
|
70516
|
+
const errors = results.filter(Boolean).concat(missingBuilders);
|
|
70478
70517
|
if (errors.length) return Promise.reject(errors);
|
|
70479
70518
|
return;
|
|
70480
70519
|
}
|
|
@@ -70612,15 +70651,41 @@ if (optBuild) {
|
|
|
70612
70651
|
log_default.info(`Building`);
|
|
70613
70652
|
tasks.push(bundle2(options));
|
|
70614
70653
|
}
|
|
70615
|
-
|
|
70616
|
-
|
|
70617
|
-
|
|
70618
|
-
|
|
70619
|
-
|
|
70654
|
+
function errorPrinter(error, index) {
|
|
70655
|
+
if (Array.isArray(error)) {
|
|
70656
|
+
for (const err of error) {
|
|
70657
|
+
index = errorPrinter(err, index);
|
|
70658
|
+
}
|
|
70659
|
+
return index;
|
|
70660
|
+
}
|
|
70661
|
+
if (error instanceof Error) {
|
|
70662
|
+
log_default.error(`(${index}) Error:`, error.message);
|
|
70663
|
+
log_default.debug(error.stack);
|
|
70664
|
+
index++;
|
|
70665
|
+
} else {
|
|
70666
|
+
if (error && typeof error === "object") {
|
|
70667
|
+
if (error.text && error.notes && error.detail) {
|
|
70668
|
+
log_default.error(`(${index}) Error: ${error.text}`);
|
|
70669
|
+
for (const note of error.notes) {
|
|
70670
|
+
log_default.verbose(`Note: ${note.text}`);
|
|
70671
|
+
if (note.location) {
|
|
70672
|
+
log_default.verbose(
|
|
70673
|
+
`Location: ${note.location.file}:${note.location.line}:${note.location.column}`
|
|
70674
|
+
);
|
|
70675
|
+
}
|
|
70676
|
+
}
|
|
70677
|
+
} else {
|
|
70678
|
+
log_default.error(`(${index}) Error:`, error);
|
|
70679
|
+
}
|
|
70620
70680
|
} else {
|
|
70621
|
-
log_default.error(
|
|
70681
|
+
log_default.error(`(${index}) Error:`, String(error));
|
|
70622
70682
|
}
|
|
70623
70683
|
}
|
|
70684
|
+
return index;
|
|
70685
|
+
}
|
|
70686
|
+
Promise.all(tasks).catch((_errors) => {
|
|
70687
|
+
let errors = Array.isArray(_errors) ? _errors : [_errors];
|
|
70688
|
+
errorPrinter(errors, 1);
|
|
70624
70689
|
exitCode = 1;
|
|
70625
70690
|
}).finally(() => {
|
|
70626
70691
|
const endTime = Date.now();
|