@normed/bundle 4.7.1 → 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.
@@ -23672,31 +23672,31 @@ var require_abstract_plugin_loader = __commonJS({
23672
23672
  }
23673
23673
  return pluginObj;
23674
23674
  };
23675
- AbstractPluginLoader2.prototype.trySetOptions = function(plugin4, filename, name3, options2) {
23676
- if (options2 && !plugin4.setOptions) {
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
- plugin4.setOptions && plugin4.setOptions(options2);
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(plugin4, filename, name3) {
23688
- if (plugin4) {
23689
- if (typeof plugin4 === "function") {
23690
- plugin4 = new plugin4();
23687
+ AbstractPluginLoader2.prototype.validatePlugin = function(plugin3, filename, name3) {
23688
+ if (plugin3) {
23689
+ if (typeof plugin3 === "function") {
23690
+ plugin3 = new plugin3();
23691
23691
  }
23692
- if (plugin4.minVersion) {
23693
- if (this.compareVersion(plugin4.minVersion, this.less.version) < 0) {
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(plugin4.minVersion))
23695
+ message: "Plugin ".concat(name3, " requires version ").concat(this.versionToString(plugin3.minVersion))
23696
23696
  });
23697
23697
  }
23698
23698
  }
23699
- return plugin4;
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 plugin4 = plugins[i];
23725
- if (plugin4.printUsage) {
23726
- plugin4.printUsage();
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(plugin4, filename, functionRegistry) {
25014
- this.installedPlugins.push(plugin4);
25013
+ PluginManager2.prototype.addPlugin = function(plugin3, filename, functionRegistry) {
25014
+ this.installedPlugins.push(plugin3);
25015
25015
  if (filename) {
25016
- this.pluginCache[filename] = plugin4;
25016
+ this.pluginCache[filename] = plugin3;
25017
25017
  }
25018
- if (plugin4.install) {
25019
- plugin4.install(this.less, this, functionRegistry || this.less.functions.functionRegistry);
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 plugin4;
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
- plugin4 = pluginLoader.evalPlugin(contents, newEnv, importManager, importOptions.pluginArgs, newFileInfo);
25500
- if (plugin4 instanceof less_error_1.default) {
25501
- fileParsedFunc(plugin4, null, resolvedFilename);
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, plugin4, resolvedFilename);
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(plugin4) {
25618
+ options2.plugins.forEach(function(plugin3) {
25619
25619
  var evalResult, contents;
25620
- if (plugin4.fileContent) {
25621
- contents = plugin4.fileContent.replace(/^\uFEFF/, "");
25622
- evalResult = pluginManager_1.Loader.evalPlugin(contents, context_1, imports_1, plugin4.options, plugin4.filename);
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(plugin4);
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 plugin4 = this.plugins[i];
33355
- if (plugin4[func] && plugin4[func].apply(plugin4, pluginArgs)) {
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 plugin4 = this.plugins[i];
33669
- if (plugin4[context] && plugin4[context][tok.type]) {
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 = plugin4[context];
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(plugin4, name3) {
38648
+ getPluginOption(plugin3, name3) {
38649
38649
  var _this$plugins$get;
38650
- return (_this$plugins$get = this.plugins.get(plugin4)) == null ? void 0 : _this$plugins$get[name3];
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 plugin4 = plugins.find((plugin5) => {
47137
- if (Array.isArray(plugin5)) {
47138
- return plugin5[0] === name3;
47136
+ const plugin3 = plugins.find((plugin4) => {
47137
+ if (Array.isArray(plugin4)) {
47138
+ return plugin4[0] === name3;
47139
47139
  } else {
47140
- return plugin5 === name3;
47140
+ return plugin4 === name3;
47141
47141
  }
47142
47142
  });
47143
- if (plugin4 && Array.isArray(plugin4) && plugin4.length > 1) {
47144
- return plugin4[1][option];
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 plugin4 of plugins) {
50947
- const [name3, options2] = Array.isArray(plugin4) ? plugin4 : [plugin4, {}];
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 plugin4 of pluginList) {
51016
- cls = mixinPlugins[plugin4](cls);
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, plugin4) {
67747
- return plugin4[name3] ? plugin4[name3](value2, options2) : value2;
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(plugin4) {
67752
- return plugin4[name3];
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(plugin4) {
67776
- return !!plugin4.lex;
67777
- }).map(function(plugin4) {
67778
- return plugin4.lex;
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(plugin4) {
67811
- return !!plugin4.parse;
67812
- }).map(function(plugin4) {
67813
- return plugin4.parse;
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
- async function processHtmlAssets(html, pugFilePath, options2) {
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
- let htmlPath;
69162
- if (publicPath) {
69163
- htmlPath = publicPath.replace(/\/$/, "") + "/" + hashedFilename;
69164
- } else {
69165
- htmlPath = path5.relative(htmlOutputDir, absoluteOutput);
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
- let htmlPath;
69203
- if (publicPath) {
69204
- htmlPath = publicPath.replace(/\/$/, "") + "/" + hashedFilename;
69205
- } else {
69206
- htmlPath = path5.relative(htmlOutputDir, absoluteOutput);
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,
@@ -69364,7 +69386,7 @@ async function loadAsHtml(filepath, options2) {
69364
69386
  loader: "js"
69365
69387
  };
69366
69388
  }
69367
- async function loadAsEntrypoint(filepath, options2) {
69389
+ async function loadAsEntrypoint(filepath, options2, webRoot) {
69368
69390
  const fileData = await fs6.promises.readFile(filepath, "utf8");
69369
69391
  let contents = import_pug.default.render(fileData, {
69370
69392
  filename: filepath,
@@ -69385,7 +69407,7 @@ async function loadAsEntrypoint(filepath, options2) {
69385
69407
  lessReferences,
69386
69408
  scriptReferences,
69387
69409
  packageCssReferences
69388
- } = await processHtmlAssets(contents, filepath, options2);
69410
+ } = await processHtmlAssets(contents, filepath, options2, webRoot);
69389
69411
  contents = processedHtml;
69390
69412
  if (pugReferences.length > 0) {
69391
69413
  discoveredPugReferences.set(filepath, pugReferences);
@@ -69422,70 +69444,72 @@ async function loadAsFile(filepath, options2) {
69422
69444
  };
69423
69445
  }
69424
69446
  var name2 = "load_pug";
69425
- var plugin2 = {
69426
- name: name2,
69427
- setup(build2) {
69428
- const filter2 = /.*\.pug$/;
69429
- build2.onResolve(
69430
- { filter: filter2 },
69431
- async (args) => {
69432
- const resolvedPath = path5.resolve(args.resolveDir, args.path);
69433
- if (fs6.existsSync(resolvedPath)) {
69434
- return {
69435
- sideEffects: false,
69436
- path: path5.resolve(args.resolveDir, args.path),
69437
- pluginData: Object.assign({}, args.pluginData, {
69438
- [name2]: {
69439
- entrypoint: args.kind === "entry-point"
69440
- }
69441
- })
69442
- };
69443
- } else {
69444
- return {};
69445
- }
69446
- }
69447
- );
69448
- build2.onLoad(
69449
- { filter: filter2 },
69450
- async ({
69451
- path: filepath,
69452
- with: withArg,
69453
- pluginData
69454
- }) => {
69455
- const isEntryPoint = pluginData?.[name2]?.entrypoint;
69456
- if (isEntryPoint) {
69457
- 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
+ }
69458
69470
  }
69459
- const type = withArg?.["type"] ?? "js";
69460
- switch (type) {
69461
- // Load pug as html by doing "import template from './file.pug' with { type: 'html' }"
69462
- // This gives a string of the pug already rendered to html
69463
- // TODO: could support passing options to pug.render via the with clause
69464
- case "html":
69465
- return loadAsHtml(filepath, build2.initialOptions);
69466
- // Load pug as a text file by doing "import template from './file.pug' with { type: 'text' }"
69467
- // This gives a string of the raw pug file, which can be used as pug - e.g. as a template string
69468
- case "pug":
69469
- case "text":
69470
- return loadAsText2(filepath);
69471
- // Load pug as a render function by doing "import render from './file.pug' with { type: 'js' }"
69472
- // This is the default behaviour if no with clause is used, or no type is specified.
69473
- case "js":
69474
- return loadAsJS2(filepath, build2.initialOptions);
69475
- // Load pug as a file by doing "import template from './file.pug' with { type: 'file' }"
69476
- // This will render the pug file to a file, and return the path to that file.
69477
- // The path is going to contain a hash, so it is not going to be the same as the original file.
69478
- case "file":
69479
- return loadAsFile(filepath, build2.initialOptions);
69480
- // In the case that the type is not recognised, throw an error
69481
- default:
69482
- throw new Error(`Unsupported type: ${type}`);
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
+ }
69483
69508
  }
69484
- }
69485
- );
69486
- }
69487
- };
69488
- var load_pug_default = plugin2;
69509
+ );
69510
+ }
69511
+ };
69512
+ }
69489
69513
 
69490
69514
  // pnp:/builds/normed/bundle/packages/bundle/src/esbuild-plugins/load_ts_js.ts
69491
69515
  import fs7 from "fs";
@@ -69512,7 +69536,7 @@ function quoteString(string) {
69512
69536
  function regexEscape(s) {
69513
69537
  return s.replace(/[-\/\\^$*+?.()|[\]{}]/g, "\\$&");
69514
69538
  }
69515
- var plugin3 = (options2) => {
69539
+ var plugin2 = (options2) => {
69516
69540
  const { sourceRelativeDirnameFilename, basedir } = Object.assign(
69517
69541
  {
69518
69542
  sourceRelativeDirnameFilename: true
@@ -69553,7 +69577,7 @@ var plugin3 = (options2) => {
69553
69577
  }
69554
69578
  };
69555
69579
  };
69556
- var load_ts_js_default = plugin3;
69580
+ var load_ts_js_default = plugin2;
69557
69581
 
69558
69582
  // pnp:/builds/normed/bundle/packages/bundle/src/esbuild-plugins/css_external_urls.ts
69559
69583
  function createCssExternalUrlsPlugin(patterns) {
@@ -69769,7 +69793,9 @@ var esbuilder = {
69769
69793
  plugins: [
69770
69794
  ...baseConfig.plugins ?? [],
69771
69795
  load_less_default,
69772
- load_pug_default,
69796
+ createLoadPugPlugin(
69797
+ exampleFile.entryconfig.webRoot ? { webRoot: exampleFile.entryconfig.webRoot } : void 0
69798
+ ),
69773
69799
  load_ts_js_default({ sourceRelativeDirnameFilename: true, basedir: indir }),
69774
69800
  ...externalUrlsPlugin ? [externalUrlsPlugin] : [],
69775
69801
  createCssUrlResolverPlugin(),
@@ -71447,6 +71473,33 @@ async function getBuildConfig(options2) {
71447
71473
  buildConfig.modifiers = newModifiers;
71448
71474
  buildConfig.baseConfig = newBaseConfig;
71449
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
+ }
71450
71503
  }
71451
71504
  log_default.verbose(
71452
71505
  "Build Config - post reading package.json",
@@ -71488,6 +71541,11 @@ async function bundle(options2 = {}, plugins = {}) {
71488
71541
  "Failed to discover entrypoints"
71489
71542
  );
71490
71543
  }
71544
+ if (buildConfig.webRoot) {
71545
+ for (const ep of entrypoints) {
71546
+ ep.entryconfig.webRoot = buildConfig.webRoot;
71547
+ }
71548
+ }
71491
71549
  let grouped = keyBy(entrypoints, {
71492
71550
  builder: (entrypoint) => entrypoint.builder
71493
71551
  });