elegance-js 1.11.16 → 1.11.18

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/dist/build.mjs CHANGED
@@ -723,7 +723,7 @@ async function handleStaticRequest(root, pathname, req, res, DIST_DIR) {
723
723
  let isDynamic = false;
724
724
  let handlerPath = filePath;
725
725
  if (stats && stats.isDirectory()) {
726
- const pageMjsPath = join(filePath, "page.cjs");
726
+ const pageMjsPath = join(filePath, "page.mjs");
727
727
  try {
728
728
  await fs2.access(pageMjsPath);
729
729
  handlerPath = pageMjsPath;
@@ -726,7 +726,7 @@ async function handleStaticRequest(root, pathname, req, res, DIST_DIR) {
726
726
  let isDynamic = false;
727
727
  let handlerPath = filePath;
728
728
  if (stats && stats.isDirectory()) {
729
- const pageMjsPath = join(filePath, "page.cjs");
729
+ const pageMjsPath = join(filePath, "page.mjs");
730
730
  try {
731
731
  await fs2.access(pageMjsPath);
732
732
  handlerPath = pageMjsPath;
@@ -687,31 +687,24 @@ var buildPage = async (DIST_DIR2, directory, filePath, name) => {
687
687
  pageElements = page;
688
688
  metadata = pageMetadata;
689
689
  if (isDynamicPage === true) {
690
- const parsed = path.parse(filePath);
691
690
  await esbuild.build({
692
691
  entryPoints: [filePath],
693
- outfile: path.join(parsed.dir, parsed.name + ".cjs"),
694
- // necessary because we're mutilating the original
692
+ outfile: filePath,
695
693
  allowOverwrite: true,
696
- // dont bundle because the origina build handles moduleresolution
697
694
  bundle: false,
698
- format: "cjs",
699
- // Important
695
+ format: "esm",
700
696
  plugins: [
701
697
  {
702
- name: "wrap-cjs",
698
+ name: "wrap-esm",
703
699
  setup(build2) {
704
700
  build2.onEnd(async () => {
705
701
  const fs2 = await import("fs/promises");
706
702
  const code = await fs2.readFile(build2.initialOptions.outfile, "utf8");
707
- const wrapped = `export function construct() {
703
+ const wrapped = `export async function construct() {
708
704
  const exports = {};
709
- const module = { exports };
710
- (function(exports, module) {
711
- ${code.split("\n").map((l) => " " + l).join("\n")}
712
- })(exports, module);
705
+ ${code.replace(/export\s+(const|let|var|function|class)\s+(\w+)/g, "exports.$2 = $2; $1 $2").split("\n").map((l) => " " + l).join("\n")}
713
706
 
714
- return module.exports;
707
+ return exports;
715
708
  }
716
709
  `;
717
710
  await fs2.writeFile(build2.initialOptions.outfile, wrapped);
@@ -715,7 +715,7 @@ async function handleStaticRequest(root, pathname, req, res, DIST_DIR) {
715
715
  let isDynamic = false;
716
716
  let handlerPath = filePath;
717
717
  if (stats && stats.isDirectory()) {
718
- const pageMjsPath = join(filePath, "page.cjs");
718
+ const pageMjsPath = join(filePath, "page.mjs");
719
719
  try {
720
720
  await fs2.access(pageMjsPath);
721
721
  handlerPath = pageMjsPath;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "elegance-js",
3
- "version": "1.11.16",
3
+ "version": "1.11.18",
4
4
  "description": "Web-Framework",
5
5
  "type": "module",
6
6
  "bin": {