@normed/bundle 4.7.0 → 4.8.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 +8 -0
- package/README.md +38 -24
- package/bundles/bin/cli.js +203 -144
- package/bundles/bin/cli.js.map +3 -3
- package/bundles/esbuild-plugins/index.d.ts +1 -1
- package/bundles/esbuild-plugins/load_pug.d.ts +22 -2
- package/bundles/index.js +203 -144
- package/bundles/index.js.map +3 -3
- package/bundles/readConfigs.d.ts +3 -0
- package/bundles/types.d.ts +7 -0
- package/package.json +1 -1
package/bundles/bin/cli.js
CHANGED
|
@@ -23672,31 +23672,31 @@ var require_abstract_plugin_loader = __commonJS({
|
|
|
23672
23672
|
}
|
|
23673
23673
|
return pluginObj;
|
|
23674
23674
|
};
|
|
23675
|
-
AbstractPluginLoader2.prototype.trySetOptions = function(
|
|
23676
|
-
if (options2 && !
|
|
23675
|
+
AbstractPluginLoader2.prototype.trySetOptions = function(plugin3, filename, name3, options2) {
|
|
23676
|
+
if (options2 && !plugin3.setOptions) {
|
|
23677
23677
|
return new less_error_1.default({
|
|
23678
23678
|
message: "Options have been provided but the plugin ".concat(name3, " does not support any options.")
|
|
23679
23679
|
});
|
|
23680
23680
|
}
|
|
23681
23681
|
try {
|
|
23682
|
-
|
|
23682
|
+
plugin3.setOptions && plugin3.setOptions(options2);
|
|
23683
23683
|
} catch (e) {
|
|
23684
23684
|
return new less_error_1.default(e);
|
|
23685
23685
|
}
|
|
23686
23686
|
};
|
|
23687
|
-
AbstractPluginLoader2.prototype.validatePlugin = function(
|
|
23688
|
-
if (
|
|
23689
|
-
if (typeof
|
|
23690
|
-
|
|
23687
|
+
AbstractPluginLoader2.prototype.validatePlugin = function(plugin3, filename, name3) {
|
|
23688
|
+
if (plugin3) {
|
|
23689
|
+
if (typeof plugin3 === "function") {
|
|
23690
|
+
plugin3 = new plugin3();
|
|
23691
23691
|
}
|
|
23692
|
-
if (
|
|
23693
|
-
if (this.compareVersion(
|
|
23692
|
+
if (plugin3.minVersion) {
|
|
23693
|
+
if (this.compareVersion(plugin3.minVersion, this.less.version) < 0) {
|
|
23694
23694
|
return new less_error_1.default({
|
|
23695
|
-
message: "Plugin ".concat(name3, " requires version ").concat(this.versionToString(
|
|
23695
|
+
message: "Plugin ".concat(name3, " requires version ").concat(this.versionToString(plugin3.minVersion))
|
|
23696
23696
|
});
|
|
23697
23697
|
}
|
|
23698
23698
|
}
|
|
23699
|
-
return
|
|
23699
|
+
return plugin3;
|
|
23700
23700
|
}
|
|
23701
23701
|
return null;
|
|
23702
23702
|
};
|
|
@@ -23721,9 +23721,9 @@ var require_abstract_plugin_loader = __commonJS({
|
|
|
23721
23721
|
};
|
|
23722
23722
|
AbstractPluginLoader2.prototype.printUsage = function(plugins) {
|
|
23723
23723
|
for (var i = 0; i < plugins.length; i++) {
|
|
23724
|
-
var
|
|
23725
|
-
if (
|
|
23726
|
-
|
|
23724
|
+
var plugin3 = plugins[i];
|
|
23725
|
+
if (plugin3.printUsage) {
|
|
23726
|
+
plugin3.printUsage();
|
|
23727
23727
|
}
|
|
23728
23728
|
}
|
|
23729
23729
|
};
|
|
@@ -25010,13 +25010,13 @@ var require_plugin_manager = __commonJS({
|
|
|
25010
25010
|
}
|
|
25011
25011
|
}
|
|
25012
25012
|
};
|
|
25013
|
-
PluginManager2.prototype.addPlugin = function(
|
|
25014
|
-
this.installedPlugins.push(
|
|
25013
|
+
PluginManager2.prototype.addPlugin = function(plugin3, filename, functionRegistry) {
|
|
25014
|
+
this.installedPlugins.push(plugin3);
|
|
25015
25015
|
if (filename) {
|
|
25016
|
-
this.pluginCache[filename] =
|
|
25016
|
+
this.pluginCache[filename] = plugin3;
|
|
25017
25017
|
}
|
|
25018
|
-
if (
|
|
25019
|
-
|
|
25018
|
+
if (plugin3.install) {
|
|
25019
|
+
plugin3.install(this.less, this, functionRegistry || this.less.functions.functionRegistry);
|
|
25020
25020
|
}
|
|
25021
25021
|
};
|
|
25022
25022
|
PluginManager2.prototype.get = function(filename) {
|
|
@@ -25478,7 +25478,7 @@ var require_import_manager = __commonJS({
|
|
|
25478
25478
|
return;
|
|
25479
25479
|
}
|
|
25480
25480
|
var loadFileCallback = function(loadedFile2) {
|
|
25481
|
-
var
|
|
25481
|
+
var plugin3;
|
|
25482
25482
|
var resolvedFilename = loadedFile2.filename;
|
|
25483
25483
|
var contents = loadedFile2.contents.replace(/^\uFEFF/, "");
|
|
25484
25484
|
newFileInfo.currentDirectory = fileManager.getPath(resolvedFilename);
|
|
@@ -25496,11 +25496,11 @@ var require_import_manager = __commonJS({
|
|
|
25496
25496
|
newFileInfo.reference = true;
|
|
25497
25497
|
}
|
|
25498
25498
|
if (importOptions.isPlugin) {
|
|
25499
|
-
|
|
25500
|
-
if (
|
|
25501
|
-
fileParsedFunc(
|
|
25499
|
+
plugin3 = pluginLoader.evalPlugin(contents, newEnv, importManager, importOptions.pluginArgs, newFileInfo);
|
|
25500
|
+
if (plugin3 instanceof less_error_1.default) {
|
|
25501
|
+
fileParsedFunc(plugin3, null, resolvedFilename);
|
|
25502
25502
|
} else {
|
|
25503
|
-
fileParsedFunc(null,
|
|
25503
|
+
fileParsedFunc(null, plugin3, resolvedFilename);
|
|
25504
25504
|
}
|
|
25505
25505
|
} else if (importOptions.inline) {
|
|
25506
25506
|
fileParsedFunc(null, contents, resolvedFilename);
|
|
@@ -25615,16 +25615,16 @@ var require_parse2 = __commonJS({
|
|
|
25615
25615
|
var imports_1 = new ImportManager(this, context_1, rootFileInfo);
|
|
25616
25616
|
this.importManager = imports_1;
|
|
25617
25617
|
if (options2.plugins) {
|
|
25618
|
-
options2.plugins.forEach(function(
|
|
25618
|
+
options2.plugins.forEach(function(plugin3) {
|
|
25619
25619
|
var evalResult, contents;
|
|
25620
|
-
if (
|
|
25621
|
-
contents =
|
|
25622
|
-
evalResult = pluginManager_1.Loader.evalPlugin(contents, context_1, imports_1,
|
|
25620
|
+
if (plugin3.fileContent) {
|
|
25621
|
+
contents = plugin3.fileContent.replace(/^\uFEFF/, "");
|
|
25622
|
+
evalResult = pluginManager_1.Loader.evalPlugin(contents, context_1, imports_1, plugin3.options, plugin3.filename);
|
|
25623
25623
|
if (evalResult instanceof less_error_1.default) {
|
|
25624
25624
|
return callback(evalResult);
|
|
25625
25625
|
}
|
|
25626
25626
|
} else {
|
|
25627
|
-
pluginManager_1.addPlugin(
|
|
25627
|
+
pluginManager_1.addPlugin(plugin3);
|
|
25628
25628
|
}
|
|
25629
25629
|
});
|
|
25630
25630
|
}
|
|
@@ -33351,8 +33351,8 @@ var require_pug_lexer = __commonJS({
|
|
|
33351
33351
|
}
|
|
33352
33352
|
var pluginArgs = [this].concat(rest);
|
|
33353
33353
|
for (var i = 0; i < this.plugins.length; i++) {
|
|
33354
|
-
var
|
|
33355
|
-
if (
|
|
33354
|
+
var plugin3 = this.plugins[i];
|
|
33355
|
+
if (plugin3[func] && plugin3[func].apply(plugin3, pluginArgs)) {
|
|
33356
33356
|
return true;
|
|
33357
33357
|
}
|
|
33358
33358
|
}
|
|
@@ -33665,13 +33665,13 @@ var require_pug_parser = __commonJS({
|
|
|
33665
33665
|
}
|
|
33666
33666
|
var pluginContext;
|
|
33667
33667
|
for (var i = 0; i < this.plugins.length; i++) {
|
|
33668
|
-
var
|
|
33669
|
-
if (
|
|
33668
|
+
var plugin3 = this.plugins[i];
|
|
33669
|
+
if (plugin3[context] && plugin3[context][tok.type]) {
|
|
33670
33670
|
if (pluginContext)
|
|
33671
33671
|
throw new Error(
|
|
33672
33672
|
"Multiple plugin handlers found for context " + JSON.stringify(context) + ", token type " + JSON.stringify(tok.type)
|
|
33673
33673
|
);
|
|
33674
|
-
pluginContext =
|
|
33674
|
+
pluginContext = plugin3[context];
|
|
33675
33675
|
}
|
|
33676
33676
|
}
|
|
33677
33677
|
if (pluginContext)
|
|
@@ -38645,9 +38645,9 @@ var require_lib7 = __commonJS({
|
|
|
38645
38645
|
return true;
|
|
38646
38646
|
}
|
|
38647
38647
|
}
|
|
38648
|
-
getPluginOption(
|
|
38648
|
+
getPluginOption(plugin3, name3) {
|
|
38649
38649
|
var _this$plugins$get;
|
|
38650
|
-
return (_this$plugins$get = this.plugins.get(
|
|
38650
|
+
return (_this$plugins$get = this.plugins.get(plugin3)) == null ? void 0 : _this$plugins$get[name3];
|
|
38651
38651
|
}
|
|
38652
38652
|
};
|
|
38653
38653
|
function setTrailingComments(node, comments) {
|
|
@@ -47133,15 +47133,15 @@ var require_lib7 = __commonJS({
|
|
|
47133
47133
|
});
|
|
47134
47134
|
}
|
|
47135
47135
|
function getPluginOption(plugins, name3, option) {
|
|
47136
|
-
const
|
|
47137
|
-
if (Array.isArray(
|
|
47138
|
-
return
|
|
47136
|
+
const plugin3 = plugins.find((plugin4) => {
|
|
47137
|
+
if (Array.isArray(plugin4)) {
|
|
47138
|
+
return plugin4[0] === name3;
|
|
47139
47139
|
} else {
|
|
47140
|
-
return
|
|
47140
|
+
return plugin4 === name3;
|
|
47141
47141
|
}
|
|
47142
47142
|
});
|
|
47143
|
-
if (
|
|
47144
|
-
return
|
|
47143
|
+
if (plugin3 && Array.isArray(plugin3) && plugin3.length > 1) {
|
|
47144
|
+
return plugin3[1][option];
|
|
47145
47145
|
}
|
|
47146
47146
|
return null;
|
|
47147
47147
|
}
|
|
@@ -50943,8 +50943,8 @@ var require_lib7 = __commonJS({
|
|
|
50943
50943
|
};
|
|
50944
50944
|
function pluginsMap(plugins) {
|
|
50945
50945
|
const pluginMap = /* @__PURE__ */ new Map();
|
|
50946
|
-
for (const
|
|
50947
|
-
const [name3, options2] = Array.isArray(
|
|
50946
|
+
for (const plugin3 of plugins) {
|
|
50947
|
+
const [name3, options2] = Array.isArray(plugin3) ? plugin3 : [plugin3, {}];
|
|
50948
50948
|
if (!pluginMap.has(name3)) pluginMap.set(name3, options2 || {});
|
|
50949
50949
|
}
|
|
50950
50950
|
return pluginMap;
|
|
@@ -51012,8 +51012,8 @@ var require_lib7 = __commonJS({
|
|
|
51012
51012
|
let cls = parserClassCache[key];
|
|
51013
51013
|
if (!cls) {
|
|
51014
51014
|
cls = Parser;
|
|
51015
|
-
for (const
|
|
51016
|
-
cls = mixinPlugins[
|
|
51015
|
+
for (const plugin3 of pluginList) {
|
|
51016
|
+
cls = mixinPlugins[plugin3](cls);
|
|
51017
51017
|
}
|
|
51018
51018
|
parserClassCache[key] = cls;
|
|
51019
51019
|
}
|
|
@@ -67743,13 +67743,13 @@ var require_lib14 = __commonJS({
|
|
|
67743
67743
|
exports.runtime = runtime;
|
|
67744
67744
|
exports.cache = {};
|
|
67745
67745
|
function applyPlugins(value, options2, plugins, name3) {
|
|
67746
|
-
return plugins.reduce(function(value2,
|
|
67747
|
-
return
|
|
67746
|
+
return plugins.reduce(function(value2, plugin3) {
|
|
67747
|
+
return plugin3[name3] ? plugin3[name3](value2, options2) : value2;
|
|
67748
67748
|
}, value);
|
|
67749
67749
|
}
|
|
67750
67750
|
function findReplacementFunc(plugins, name3) {
|
|
67751
|
-
var eligiblePlugins = plugins.filter(function(
|
|
67752
|
-
return
|
|
67751
|
+
var eligiblePlugins = plugins.filter(function(plugin3) {
|
|
67752
|
+
return plugin3[name3];
|
|
67753
67753
|
});
|
|
67754
67754
|
if (eligiblePlugins.length > 1) {
|
|
67755
67755
|
throw new Error("Two or more plugins all implement " + name3 + " method.");
|
|
@@ -67772,10 +67772,10 @@ var require_lib14 = __commonJS({
|
|
|
67772
67772
|
Object.keys(options3).forEach(function(key) {
|
|
67773
67773
|
lexOptions[key] = options3[key];
|
|
67774
67774
|
});
|
|
67775
|
-
lexOptions.plugins = plugins.filter(function(
|
|
67776
|
-
return !!
|
|
67777
|
-
}).map(function(
|
|
67778
|
-
return
|
|
67775
|
+
lexOptions.plugins = plugins.filter(function(plugin3) {
|
|
67776
|
+
return !!plugin3.lex;
|
|
67777
|
+
}).map(function(plugin3) {
|
|
67778
|
+
return plugin3.lex;
|
|
67779
67779
|
});
|
|
67780
67780
|
var contents = applyPlugins(
|
|
67781
67781
|
str2,
|
|
@@ -67807,10 +67807,10 @@ var require_lib14 = __commonJS({
|
|
|
67807
67807
|
Object.keys(options3).forEach(function(key) {
|
|
67808
67808
|
parseOptions[key] = options3[key];
|
|
67809
67809
|
});
|
|
67810
|
-
parseOptions.plugins = plugins.filter(function(
|
|
67811
|
-
return !!
|
|
67812
|
-
}).map(function(
|
|
67813
|
-
return
|
|
67810
|
+
parseOptions.plugins = plugins.filter(function(plugin3) {
|
|
67811
|
+
return !!plugin3.parse;
|
|
67812
|
+
}).map(function(plugin3) {
|
|
67813
|
+
return plugin3.parse;
|
|
67814
67814
|
});
|
|
67815
67815
|
return applyPlugins(
|
|
67816
67816
|
applyPlugins(
|
|
@@ -68348,6 +68348,9 @@ var refinePackageJSONBuildConfig = makePartialRefinement({
|
|
|
68348
68348
|
root: (0, import_refinements2.refineAny)(import_refinements2.refineUndefined, import_refinements2.refineString)
|
|
68349
68349
|
})
|
|
68350
68350
|
),
|
|
68351
|
+
webRoot: (0, import_refinements2.refineAny)(import_refinements2.refineUndefined, import_refinements2.refineString),
|
|
68352
|
+
publicPath: (0, import_refinements2.refineAny)(import_refinements2.refineUndefined, import_refinements2.refineString),
|
|
68353
|
+
assetNames: (0, import_refinements2.refineAny)(import_refinements2.refineUndefined, import_refinements2.refineString),
|
|
68351
68354
|
// TODO: this shouldn't need to be casted to remove the undefined from the Value portion ({[modifier: string]: EntryConfig} | undefined})
|
|
68352
68355
|
modifiers: (0, import_refinements2.refineObjectOf)(
|
|
68353
68356
|
import_refinements2.refineString,
|
|
@@ -68892,7 +68895,18 @@ function applyAssetNamesTemplate(template, originalPath, hash, baseDir) {
|
|
|
68892
68895
|
const relativeDir = dir.startsWith(baseDir) ? dir.slice(baseDir.length).replace(/^\//, "") : dir;
|
|
68893
68896
|
return template.replace(/\[name\]/g, name3).replace(/\[hash\]/g, hash).replace(/\[ext\]/g, ext).replace(/\[dir\]/g, relativeDir) + "." + ext;
|
|
68894
68897
|
}
|
|
68895
|
-
|
|
68898
|
+
function computeHtmlAssetPath(opts) {
|
|
68899
|
+
if (opts.webRoot) {
|
|
68900
|
+
const webRootDir = path5.join(opts.outdir, opts.webRoot);
|
|
68901
|
+
const prefix = (opts.publicPath || "/").replace(/\/$/, "");
|
|
68902
|
+
return prefix + "/" + path5.relative(webRootDir, opts.absoluteOutput);
|
|
68903
|
+
}
|
|
68904
|
+
if (opts.publicPath) {
|
|
68905
|
+
return opts.publicPath.replace(/\/$/, "") + "/" + opts.hashedFilename;
|
|
68906
|
+
}
|
|
68907
|
+
return path5.relative(opts.htmlOutputDir, opts.absoluteOutput);
|
|
68908
|
+
}
|
|
68909
|
+
async function processHtmlAssets(html, pugFilePath, options2, webRoot) {
|
|
68896
68910
|
const assets = [];
|
|
68897
68911
|
const pugReferences = [];
|
|
68898
68912
|
const lessReferences = [];
|
|
@@ -68955,7 +68969,8 @@ async function processHtmlAssets(html, pugFilePath, options2) {
|
|
|
68955
68969
|
assetNames,
|
|
68956
68970
|
publicPath,
|
|
68957
68971
|
assets,
|
|
68958
|
-
processedAssets
|
|
68972
|
+
processedAssets,
|
|
68973
|
+
webRoot
|
|
68959
68974
|
);
|
|
68960
68975
|
if (hashedPath) {
|
|
68961
68976
|
newParts.push(
|
|
@@ -69052,7 +69067,8 @@ async function processHtmlAssets(html, pugFilePath, options2) {
|
|
|
69052
69067
|
assetNames,
|
|
69053
69068
|
publicPath,
|
|
69054
69069
|
assets,
|
|
69055
|
-
processedAssets
|
|
69070
|
+
processedAssets,
|
|
69071
|
+
webRoot
|
|
69056
69072
|
);
|
|
69057
69073
|
if (hashedPath) {
|
|
69058
69074
|
newValue = hashedPath;
|
|
@@ -69097,7 +69113,8 @@ async function processHtmlAssets(html, pugFilePath, options2) {
|
|
|
69097
69113
|
assetNames,
|
|
69098
69114
|
publicPath,
|
|
69099
69115
|
assets,
|
|
69100
|
-
processedAssets
|
|
69116
|
+
processedAssets,
|
|
69117
|
+
webRoot
|
|
69101
69118
|
);
|
|
69102
69119
|
if (hashedPath) {
|
|
69103
69120
|
newValue = hashedPath;
|
|
@@ -69113,7 +69130,8 @@ async function processHtmlAssets(html, pugFilePath, options2) {
|
|
|
69113
69130
|
assetNames,
|
|
69114
69131
|
publicPath,
|
|
69115
69132
|
assets,
|
|
69116
|
-
processedAssets
|
|
69133
|
+
processedAssets,
|
|
69134
|
+
webRoot
|
|
69117
69135
|
);
|
|
69118
69136
|
if (hashedPath) {
|
|
69119
69137
|
newValue = hashedPath;
|
|
@@ -69133,7 +69151,7 @@ async function processHtmlAssets(html, pugFilePath, options2) {
|
|
|
69133
69151
|
packageCssReferences
|
|
69134
69152
|
};
|
|
69135
69153
|
}
|
|
69136
|
-
async function processAsset(assetPath, pugDir, pugFilePath, outdir, outbase, assetNames, publicPath, assets, processedAssets) {
|
|
69154
|
+
async function processAsset(assetPath, pugDir, pugFilePath, outdir, outbase, assetNames, publicPath, assets, processedAssets, webRoot) {
|
|
69137
69155
|
const absoluteSource = path5.resolve(pugDir, assetPath);
|
|
69138
69156
|
if (processedAssets.has(absoluteSource)) {
|
|
69139
69157
|
return processedAssets.get(absoluteSource);
|
|
@@ -69158,12 +69176,14 @@ async function processAsset(assetPath, pugDir, pugFilePath, outdir, outbase, ass
|
|
|
69158
69176
|
const pugRelativeToOutbase = path5.relative(outbase, pugFilePath);
|
|
69159
69177
|
const htmlOutputPath = path5.join(outdir, pugRelativeToOutbase);
|
|
69160
69178
|
const htmlOutputDir = path5.dirname(htmlOutputPath);
|
|
69161
|
-
|
|
69162
|
-
|
|
69163
|
-
|
|
69164
|
-
|
|
69165
|
-
|
|
69166
|
-
|
|
69179
|
+
const htmlPath = computeHtmlAssetPath({
|
|
69180
|
+
absoluteOutput,
|
|
69181
|
+
hashedFilename,
|
|
69182
|
+
htmlOutputDir,
|
|
69183
|
+
outdir,
|
|
69184
|
+
publicPath,
|
|
69185
|
+
webRoot
|
|
69186
|
+
});
|
|
69167
69187
|
assets.push({
|
|
69168
69188
|
originalPath: assetPath,
|
|
69169
69189
|
hashedPath: htmlPath,
|
|
@@ -69176,7 +69196,7 @@ async function processAsset(assetPath, pugDir, pugFilePath, outdir, outbase, ass
|
|
|
69176
69196
|
return null;
|
|
69177
69197
|
}
|
|
69178
69198
|
}
|
|
69179
|
-
async function processPackageAsset(absoluteSource, packageSpecifier, pugFilePath, outdir, outbase, assetNames, publicPath, assets, processedAssets) {
|
|
69199
|
+
async function processPackageAsset(absoluteSource, packageSpecifier, pugFilePath, outdir, outbase, assetNames, publicPath, assets, processedAssets, webRoot) {
|
|
69180
69200
|
if (processedAssets.has(absoluteSource)) {
|
|
69181
69201
|
return processedAssets.get(absoluteSource);
|
|
69182
69202
|
}
|
|
@@ -69199,12 +69219,14 @@ async function processPackageAsset(absoluteSource, packageSpecifier, pugFilePath
|
|
|
69199
69219
|
const pugRelativeToOutbase = path5.relative(outbase, pugFilePath);
|
|
69200
69220
|
const htmlOutputPath = path5.join(outdir, pugRelativeToOutbase);
|
|
69201
69221
|
const htmlOutputDir = path5.dirname(htmlOutputPath);
|
|
69202
|
-
|
|
69203
|
-
|
|
69204
|
-
|
|
69205
|
-
|
|
69206
|
-
|
|
69207
|
-
|
|
69222
|
+
const htmlPath = computeHtmlAssetPath({
|
|
69223
|
+
absoluteOutput,
|
|
69224
|
+
hashedFilename,
|
|
69225
|
+
htmlOutputDir,
|
|
69226
|
+
outdir,
|
|
69227
|
+
publicPath,
|
|
69228
|
+
webRoot
|
|
69229
|
+
});
|
|
69208
69230
|
assets.push({
|
|
69209
69231
|
originalPath: packageSpecifier,
|
|
69210
69232
|
hashedPath: htmlPath,
|
|
@@ -69286,6 +69308,7 @@ function createRebaseAssetsPlugin(entryFilePath) {
|
|
|
69286
69308
|
}
|
|
69287
69309
|
const assetAttrs = ASSET_ATTRIBUTES[node.name];
|
|
69288
69310
|
if (!assetAttrs) continue;
|
|
69311
|
+
if (!node.attrs) continue;
|
|
69289
69312
|
for (const attr of node.attrs) {
|
|
69290
69313
|
if (!assetAttrs.includes(attr.name)) continue;
|
|
69291
69314
|
const sourceFile = attr.filename || node.filename;
|
|
@@ -69363,7 +69386,7 @@ async function loadAsHtml(filepath, options2) {
|
|
|
69363
69386
|
loader: "js"
|
|
69364
69387
|
};
|
|
69365
69388
|
}
|
|
69366
|
-
async function loadAsEntrypoint(filepath, options2) {
|
|
69389
|
+
async function loadAsEntrypoint(filepath, options2, webRoot) {
|
|
69367
69390
|
const fileData = await fs6.promises.readFile(filepath, "utf8");
|
|
69368
69391
|
let contents = import_pug.default.render(fileData, {
|
|
69369
69392
|
filename: filepath,
|
|
@@ -69384,7 +69407,7 @@ async function loadAsEntrypoint(filepath, options2) {
|
|
|
69384
69407
|
lessReferences,
|
|
69385
69408
|
scriptReferences,
|
|
69386
69409
|
packageCssReferences
|
|
69387
|
-
} = await processHtmlAssets(contents, filepath, options2);
|
|
69410
|
+
} = await processHtmlAssets(contents, filepath, options2, webRoot);
|
|
69388
69411
|
contents = processedHtml;
|
|
69389
69412
|
if (pugReferences.length > 0) {
|
|
69390
69413
|
discoveredPugReferences.set(filepath, pugReferences);
|
|
@@ -69421,70 +69444,72 @@ async function loadAsFile(filepath, options2) {
|
|
|
69421
69444
|
};
|
|
69422
69445
|
}
|
|
69423
69446
|
var name2 = "load_pug";
|
|
69424
|
-
|
|
69425
|
-
|
|
69426
|
-
|
|
69427
|
-
|
|
69428
|
-
build2
|
|
69429
|
-
|
|
69430
|
-
|
|
69431
|
-
|
|
69432
|
-
|
|
69433
|
-
|
|
69434
|
-
|
|
69435
|
-
|
|
69436
|
-
|
|
69437
|
-
|
|
69438
|
-
|
|
69439
|
-
|
|
69440
|
-
|
|
69441
|
-
|
|
69442
|
-
|
|
69443
|
-
|
|
69444
|
-
|
|
69445
|
-
|
|
69446
|
-
|
|
69447
|
-
build2.onLoad(
|
|
69448
|
-
{ filter: filter2 },
|
|
69449
|
-
async ({
|
|
69450
|
-
path: filepath,
|
|
69451
|
-
with: withArg,
|
|
69452
|
-
pluginData
|
|
69453
|
-
}) => {
|
|
69454
|
-
const isEntryPoint = pluginData?.[name2]?.entrypoint;
|
|
69455
|
-
if (isEntryPoint) {
|
|
69456
|
-
return loadAsEntrypoint(filepath, build2.initialOptions);
|
|
69447
|
+
function createLoadPugPlugin(opts) {
|
|
69448
|
+
const webRoot = opts?.webRoot;
|
|
69449
|
+
return {
|
|
69450
|
+
name: name2,
|
|
69451
|
+
setup(build2) {
|
|
69452
|
+
const filter2 = /.*\.pug$/;
|
|
69453
|
+
build2.onResolve(
|
|
69454
|
+
{ filter: filter2 },
|
|
69455
|
+
async (args) => {
|
|
69456
|
+
const resolvedPath = path5.resolve(args.resolveDir, args.path);
|
|
69457
|
+
if (fs6.existsSync(resolvedPath)) {
|
|
69458
|
+
return {
|
|
69459
|
+
sideEffects: false,
|
|
69460
|
+
path: path5.resolve(args.resolveDir, args.path),
|
|
69461
|
+
pluginData: Object.assign({}, args.pluginData, {
|
|
69462
|
+
[name2]: {
|
|
69463
|
+
entrypoint: args.kind === "entry-point"
|
|
69464
|
+
}
|
|
69465
|
+
})
|
|
69466
|
+
};
|
|
69467
|
+
} else {
|
|
69468
|
+
return {};
|
|
69469
|
+
}
|
|
69457
69470
|
}
|
|
69458
|
-
|
|
69459
|
-
|
|
69460
|
-
|
|
69461
|
-
|
|
69462
|
-
|
|
69463
|
-
|
|
69464
|
-
|
|
69465
|
-
|
|
69466
|
-
|
|
69467
|
-
|
|
69468
|
-
|
|
69469
|
-
|
|
69470
|
-
|
|
69471
|
-
|
|
69472
|
-
|
|
69473
|
-
|
|
69474
|
-
|
|
69475
|
-
|
|
69476
|
-
|
|
69477
|
-
|
|
69478
|
-
|
|
69479
|
-
|
|
69480
|
-
|
|
69481
|
-
|
|
69471
|
+
);
|
|
69472
|
+
build2.onLoad(
|
|
69473
|
+
{ filter: filter2 },
|
|
69474
|
+
async ({
|
|
69475
|
+
path: filepath,
|
|
69476
|
+
with: withArg,
|
|
69477
|
+
pluginData
|
|
69478
|
+
}) => {
|
|
69479
|
+
const isEntryPoint = pluginData?.[name2]?.entrypoint;
|
|
69480
|
+
if (isEntryPoint) {
|
|
69481
|
+
return loadAsEntrypoint(filepath, build2.initialOptions, webRoot);
|
|
69482
|
+
}
|
|
69483
|
+
const type = withArg?.["type"] ?? "js";
|
|
69484
|
+
switch (type) {
|
|
69485
|
+
// Load pug as html by doing "import template from './file.pug' with { type: 'html' }"
|
|
69486
|
+
// This gives a string of the pug already rendered to html
|
|
69487
|
+
// TODO: could support passing options to pug.render via the with clause
|
|
69488
|
+
case "html":
|
|
69489
|
+
return loadAsHtml(filepath, build2.initialOptions);
|
|
69490
|
+
// Load pug as a text file by doing "import template from './file.pug' with { type: 'text' }"
|
|
69491
|
+
// This gives a string of the raw pug file, which can be used as pug - e.g. as a template string
|
|
69492
|
+
case "pug":
|
|
69493
|
+
case "text":
|
|
69494
|
+
return loadAsText2(filepath);
|
|
69495
|
+
// Load pug as a render function by doing "import render from './file.pug' with { type: 'js' }"
|
|
69496
|
+
// This is the default behaviour if no with clause is used, or no type is specified.
|
|
69497
|
+
case "js":
|
|
69498
|
+
return loadAsJS2(filepath, build2.initialOptions);
|
|
69499
|
+
// Load pug as a file by doing "import template from './file.pug' with { type: 'file' }"
|
|
69500
|
+
// This will render the pug file to a file, and return the path to that file.
|
|
69501
|
+
// The path is going to contain a hash, so it is not going to be the same as the original file.
|
|
69502
|
+
case "file":
|
|
69503
|
+
return loadAsFile(filepath, build2.initialOptions);
|
|
69504
|
+
// In the case that the type is not recognised, throw an error
|
|
69505
|
+
default:
|
|
69506
|
+
throw new Error(`Unsupported type: ${type}`);
|
|
69507
|
+
}
|
|
69482
69508
|
}
|
|
69483
|
-
|
|
69484
|
-
|
|
69485
|
-
}
|
|
69486
|
-
}
|
|
69487
|
-
var load_pug_default = plugin2;
|
|
69509
|
+
);
|
|
69510
|
+
}
|
|
69511
|
+
};
|
|
69512
|
+
}
|
|
69488
69513
|
|
|
69489
69514
|
// pnp:/builds/normed/bundle/packages/bundle/src/esbuild-plugins/load_ts_js.ts
|
|
69490
69515
|
import fs7 from "fs";
|
|
@@ -69511,7 +69536,7 @@ function quoteString(string) {
|
|
|
69511
69536
|
function regexEscape(s) {
|
|
69512
69537
|
return s.replace(/[-\/\\^$*+?.()|[\]{}]/g, "\\$&");
|
|
69513
69538
|
}
|
|
69514
|
-
var
|
|
69539
|
+
var plugin2 = (options2) => {
|
|
69515
69540
|
const { sourceRelativeDirnameFilename, basedir } = Object.assign(
|
|
69516
69541
|
{
|
|
69517
69542
|
sourceRelativeDirnameFilename: true
|
|
@@ -69552,7 +69577,7 @@ var plugin3 = (options2) => {
|
|
|
69552
69577
|
}
|
|
69553
69578
|
};
|
|
69554
69579
|
};
|
|
69555
|
-
var load_ts_js_default =
|
|
69580
|
+
var load_ts_js_default = plugin2;
|
|
69556
69581
|
|
|
69557
69582
|
// pnp:/builds/normed/bundle/packages/bundle/src/esbuild-plugins/css_external_urls.ts
|
|
69558
69583
|
function createCssExternalUrlsPlugin(patterns) {
|
|
@@ -69768,7 +69793,9 @@ var esbuilder = {
|
|
|
69768
69793
|
plugins: [
|
|
69769
69794
|
...baseConfig.plugins ?? [],
|
|
69770
69795
|
load_less_default,
|
|
69771
|
-
|
|
69796
|
+
createLoadPugPlugin(
|
|
69797
|
+
exampleFile.entryconfig.webRoot ? { webRoot: exampleFile.entryconfig.webRoot } : void 0
|
|
69798
|
+
),
|
|
69772
69799
|
load_ts_js_default({ sourceRelativeDirnameFilename: true, basedir: indir }),
|
|
69773
69800
|
...externalUrlsPlugin ? [externalUrlsPlugin] : [],
|
|
69774
69801
|
createCssUrlResolverPlugin(),
|
|
@@ -71446,6 +71473,33 @@ async function getBuildConfig(options2) {
|
|
|
71446
71473
|
buildConfig.modifiers = newModifiers;
|
|
71447
71474
|
buildConfig.baseConfig = newBaseConfig;
|
|
71448
71475
|
}
|
|
71476
|
+
if (bundle3.webRoot !== void 0) {
|
|
71477
|
+
buildConfig.webRoot = bundle3.webRoot;
|
|
71478
|
+
}
|
|
71479
|
+
const esbuildConfig = buildConfig.baseConfig.javascript?.esbuild;
|
|
71480
|
+
const hasEsbuildObj = typeof esbuildConfig === "object" && esbuildConfig !== null;
|
|
71481
|
+
if (bundle3.publicPath !== void 0) {
|
|
71482
|
+
buildConfig.publicPath = bundle3.publicPath;
|
|
71483
|
+
if (hasEsbuildObj) {
|
|
71484
|
+
esbuildConfig["publicPath"] = bundle3.publicPath;
|
|
71485
|
+
}
|
|
71486
|
+
} else if (hasEsbuildObj && esbuildConfig["publicPath"] !== void 0) {
|
|
71487
|
+
log_default.warn(
|
|
71488
|
+
"bundle.baseConfig.javascript.esbuild.publicPath is deprecated. Use bundle.publicPath instead."
|
|
71489
|
+
);
|
|
71490
|
+
buildConfig.publicPath = esbuildConfig["publicPath"];
|
|
71491
|
+
}
|
|
71492
|
+
if (bundle3.assetNames !== void 0) {
|
|
71493
|
+
buildConfig.assetNames = bundle3.assetNames;
|
|
71494
|
+
if (hasEsbuildObj) {
|
|
71495
|
+
esbuildConfig["assetNames"] = bundle3.assetNames;
|
|
71496
|
+
}
|
|
71497
|
+
} else if (hasEsbuildObj && esbuildConfig["assetNames"] !== void 0) {
|
|
71498
|
+
log_default.warn(
|
|
71499
|
+
"bundle.baseConfig.javascript.esbuild.assetNames is deprecated. Use bundle.assetNames instead."
|
|
71500
|
+
);
|
|
71501
|
+
buildConfig.assetNames = esbuildConfig["assetNames"];
|
|
71502
|
+
}
|
|
71449
71503
|
}
|
|
71450
71504
|
log_default.verbose(
|
|
71451
71505
|
"Build Config - post reading package.json",
|
|
@@ -71487,6 +71541,11 @@ async function bundle(options2 = {}, plugins = {}) {
|
|
|
71487
71541
|
"Failed to discover entrypoints"
|
|
71488
71542
|
);
|
|
71489
71543
|
}
|
|
71544
|
+
if (buildConfig.webRoot) {
|
|
71545
|
+
for (const ep of entrypoints) {
|
|
71546
|
+
ep.entryconfig.webRoot = buildConfig.webRoot;
|
|
71547
|
+
}
|
|
71548
|
+
}
|
|
71490
71549
|
let grouped = keyBy(entrypoints, {
|
|
71491
71550
|
builder: (entrypoint) => entrypoint.builder
|
|
71492
71551
|
});
|